Warn if link!=offset in detokenizer

This commit is contained in:
Vince Weaver 2012-05-18 17:22:02 -04:00
parent a3df27d6f3
commit e5ea444c99

View File

@ -30,6 +30,7 @@ int main(int argc, char **argv) {
int line1,line2; int line1,line2;
int link1,link2,link; int link1,link2,link;
int debug=0; int debug=0;
int offset=0x801;
/* read size, first two bytes */ /* read size, first two bytes */
size1=fgetc(stdin); size1=fgetc(stdin);
@ -43,7 +44,9 @@ int main(int argc, char **argv) {
/* assumes asoft program starts at address $801 */ /* assumes asoft program starts at address $801 */
link1=fgetc(stdin); link1=fgetc(stdin);
link2=fgetc(stdin); link2=fgetc(stdin);
link=(link1<<8)|link2; link=(link2<<8)|link1;
offset+=2;
/* link==0 indicates EOF */ /* link==0 indicates EOF */
if (link==0) goto the_end; if (link==0) goto the_end;
@ -52,9 +55,11 @@ int main(int argc, char **argv) {
line2=fgetc(stdin); line2=fgetc(stdin);
if (feof(stdin)) goto the_end; if (feof(stdin)) goto the_end;
printf("%4d ",((line2)<<8)+line1); printf("%4d ",((line2)<<8)+line1);
offset+=2;
/* repeat until EOL character (0) */ /* repeat until EOL character (0) */
while( (ch1=fgetc(stdin))!=0 ) { while( (ch1=fgetc(stdin))!=0 ) {
offset++;
/* if > 0x80 it's a token */ /* if > 0x80 it's a token */
if (ch1>=0x80) { if (ch1>=0x80) {
fputc(' ',stdout); fputc(' ',stdout);
@ -69,7 +74,10 @@ int main(int argc, char **argv) {
} }
} }
offset++;
printf("\n"); printf("\n");
if (link!=offset) fprintf(stderr,"WARNING! link!=offset %x %x\n",
link,offset);
} }
the_end:; the_end:;
return 0; return 0;