2 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
3 // DEBUG.C - Debugging Messages
4 // Copyright (C) 199x Landon Dyer, 2011-2012 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source Utilised with the Kind Permission of Landon Dyer
17 static int siztab[4] = { 3, 5, 9, 9 };
25 if (c < 0x20 || c >= 0x7F)
35 // Print expression, return ptr to just past the ENDEXPR
37 TOKEN * printexpr(TOKEN * tp)
41 while (*tp != ENDEXPR)
46 // printf("`%s' ", ((SYM *)*tp)->sname);
47 printf("`%s' ", symbolPtr[*tp]->sname);
51 printf("$%X ", *tp++);
54 printf("ACONST=($%X,$%X) ", *tp, tp[1]);
58 printf("%c ", (char)tp[-1]);
70 // Dump data in a chunk (and maybe others) in the appropriate format
72 int chdump(CHUNK * ch, int format)
76 printf("chloc=$%08X, chsize=$%X\n", ch->chloc, ch->ch_size);
77 mdump(ch->chptr, ch->ch_size, format, ch->chloc);
86 // Dump fixup records in printable format
88 int fudump(CHUNK * ch)
99 ep = ch->chptr + ch->ch_size;
108 printf("$%04X $%08X %d.%d: ", (int)attr, loc, (int)file, (int)line);
113 printf("(%d long) ", (int)esiz);
114 p.tk = printexpr(p.tk);
118 printf("`%s' ;", (*p.sy)->sname);
122 if ((attr & 0x0F00) == FU_JR)
124 printf(" *=$%X", *p.lp);
152 for(mch=firstmch; mch!=NULL; mch=mch->mcnext)
154 printf("mch=$%p mcptr=$%08X mcalloc=$%X mcused=$%X\n",
155 mch, (mch->mcptr.lw), mch->mcalloc, (mch->mcused));
175 printf("m=$%04X to=%d loc=$%X from=%d siz=%s",
176 w, w & 0x00FF, loc, from, (w & MLONG) ? "long" : "word");
179 printf(" sym=`%s'", symbol->sname);
190 // Dump memory from 'start' for 'count' bytes; `flg' is the following ORed together:
195 // if `base' is not -1, then print it at the start of each line, incremented accordingly.
197 int mdump(char * start, LONG count, int flg, LONG base)
202 for(i=0; i<(int)count;)
219 printf("%08X ", base);
225 printf("%02X ", start[i] & 0xff);
229 printf("%02X%02X ", start[i] & 0xff, start[i+1] & 0xff);
233 printf("%02X%02X%02X%02X ", start[i] & 0xff, start[i+1] & 0xff,
234 start[i+2] & 0xff, start[i+3] & 0xff);
242 base += 1 << (flg & 3);
245 // Print remaining bit of ascii; the hairy expression computes the number of
246 // spaces to print to make the ascii line up nicely.
249 k = ((16 - (i - j)) / (1 << (flg & 3))) * siztab[flg & 3];
267 // Dump list of tokens on stdout in printable form
269 int dumptok(TOKEN * tk)
280 printf("REG=%u", *tk++ - 128);
286 case CONST: // CONST <value>
287 printf("CONST=%u", *tk++);
289 case STRING: // STRING <address>
290 printf("STRING='%s'", string[*tk++]);
292 case SYMBOL: // SYMBOL <address>
293 printf("SYMBOL='%s'", string[*tk++]);
295 case EOL: // End of line
298 case TKEOF: // End of file (or macro)
323 printf("%c", (int)tk[-1]);
337 int dump_everything(void)
341 for(i=1; i<NSECTS; i++)
343 if (sect[i].scattr & SUSED)
345 printf("Section %d sloc=$%X\n", i, sect[i].sloc);
347 chdump(sect[i].sfcode, 1);
350 fudump(sect[i].sffix);
356 printf("\nMarks:\n");
357 mudump(); // Dump marks
358 // printf("Total memory allocated=$%X\n", amemtot);