Bon, déjà supprime:
22: fputc(0x00,fp);
23: fputc(0x0C,fp); // (taille du 3e octet depose ... a la fin)
Les fonctions de
stdio.h mettent la taille automatiquement.
Ensuite, je déconseille d'utiliser les fonctions de
stdio.h, d'autant plus que tu stockes des données tokénisées.
vat.h est plus adapté. Mais ce n'est pas l'origine de ton problème.
Et enfin, ton problème est ça:
24: fputc(END_TAG,fp);
25: fputc(END_TAG,fp);
26: //fwrite(&ent,1,sizeof(short),fp);
27: fputc(0x04,fp);
28: fputc(0x03,fp);
29: fputc(LIST_TAG,fp);
30: fputc(END_TAG,fp);
31: fputc(0x02,fp);
32: fputc(0x01,fp);
33: fputc(LIST_TAG,fp);
34: fputc(LIST_TAG,fp);
C'est faux. Ça crée une matrice [q,r;s,t], pas [1,2;3,4]. La représentation tokénisée de [1,2;3,4] est:
E5 E5 04 01 1F 03 01 1F D9 E5 02 01 1F 01 01 1F D9 D9
pas:
E5 E5 04 03 D9 E5 02 01 D9 D9
Cf:
http://tigcc.ticalc.org/doc/estack.html#top_estack.
Je cite:
Each integer entry is stored as follows:
Bytes of the number in little endian format (i.e. the lowest byte is stored first); the number of bytes varies depending of the size of the number;
A byte which represents the number of the bytes which made the number (note that zero has zero-byte length);
Byte POSINT_TAG (0x1F) or NEGINT_TAG (0x20), depending whether the number is positive or negative (for negative numbers, previous bytes contain the absolute value).