//
-// RMAC - Reboot's Macro Assembler for all Atari computers
+// RMAC - Macro Assembler for all Atari computers
// DEBUG.C - Debugging Messages
-// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
#include "debug.h"
+#include "6502.h"
#include "amode.h"
#include "direct.h"
+#include "expr.h"
#include "mark.h"
#include "sect.h"
#include "token.h"
static int siztab[4] = { 3, 5, 9, 9 };
+static PTR tp;
//
//
// Print expression, return ptr to just past the ENDEXPR
//
-TOKEN * printexpr(TOKEN * tp)
+TOKEN * printexpr(TOKEN * tokenptr)
{
- if (tp != NULL)
+ if (tokenptr != NULL)
{
- while (*tp != ENDEXPR)
+ while (*tokenptr != ENDEXPR)
{
- switch ((int)*tp++)
+ switch ((int)*tokenptr++)
{
case SYMBOL:
- printf("'%s' ", symbolPtr[*tp]->sname);
- tp++;
+ printf("'%s' ", symbolPtr[*tokenptr]->sname);
+ tokenptr++;
break;
case CONST:
- printf("$%X ", *tp++);
+ tp.u32 = tokenptr;
+ printf("$%lX ", *tp.u64++);
+ tokenptr = tp.u32;
break;
case ACONST:
- printf("ACONST=($%X,$%X) ", *tp, tp[1]);
- tp += 2;
+ printf("ACONST=($%X,$%X) ", *tokenptr, tokenptr[1]);
+ tokenptr += 2;
break;
default:
- printf("%c ", (char)tp[-1]);
+ printf("%c ", (char)tokenptr[-1]);
break;
}
}
}
- return tp + 1;
+ return tokenptr + 1;
}
//
// Dump fixup records in printable format
//
-int fudump(CHUNK * ch)
+int fudump(FIXUP * fup)
{
- PTR p;
-
- for(; ch!=NULL;)
+ for(; fup!=NULL;)
{
- p.cp = ch->chptr;
- uint8_t * ep = ch->chptr + ch->ch_size;
+ uint32_t attr = fup->attr;
+ uint32_t loc = fup->loc;
+ uint16_t file = fup->fileno;
+ uint16_t line = fup->lineno;
- while (p.cp < ep)
- {
- uint16_t attr = *p.wp++;
- uint32_t loc = *p.lp++;
- uint16_t file = *p.wp++;
- uint16_t line = *p.wp++;
+ printf("$%08X $%08X %d.%d: ", attr, loc, (int)file, (int)line);
- printf("$%04X $%08X %d.%d: ", (int)attr, loc, (int)file, (int)line);
-
- if (attr & FU_EXPR)
- {
- uint16_t esiz = *p.wp++;
- printf("(%d long) ", (int)esiz);
- p.tk = printexpr(p.tk);
- }
- else
- {
- printf("`%s' ;", (*p.sy)->sname);
- p.sy++;
- }
+ if (attr & FU_EXPR)
+ {
+ uint16_t esiz = ExpressionLength(fup->expr);
+ printf("(%d long) ", (int)esiz);
+ printexpr(fup->expr);
+ }
+ else
+ printf("`%s' ;", fup->symbol->sname);
- if ((attr & 0x0F00) == FU_JR)
- {
- printf(" *=$%X", *p.lp);
- p.lp++;
- }
+ if ((attr & FUMASKRISC) == FU_JR)
+ printf(" *=$%X", fup->orgaddr);
- printf("\n");
- }
+ printf("\n");
- ch = ch->chnext;
+ fup = fup->next;
}
return 0;
switch (flg & 3)
{
case 0:
- printf("%02X ", start[i] & 0xff);
+ printf("%02X ", start[i] & 0xFF);
i++;
break;
case 1:
- printf("%02X%02X ", start[i] & 0xff, start[i+1] & 0xff);
+ printf("%02X%02X ", start[i] & 0xFF, start[i+1] & 0xFF);
i += 2;
break;
case 2:
- printf("%02X%02X%02X%02X ", start[i] & 0xff, start[i+1] & 0xff,
- start[i+2] & 0xff, start[i+3] & 0xff);
+ printf("%02X%02X%02X%02X ", start[i] & 0xFF, start[i+1] & 0xFF,
+ start[i+2] & 0xFF, start[i+3] & 0xFF);
i += 4;
break;
- case 3:
- break;
}
if (base != -1)
switch ((int)*tk++)
{
case CONST: // CONST <value>
- printf("CONST=%u", *tk++);
+ tp.u32 = tk;
+ printf("CONST=%lu", *tp.u64++);
+ tk = tp.u32;
break;
case STRING: // STRING <address>
printf("STRING='%s'", string[*tk++]);
printf("[COLON]");
else if (*t == CONST)
{
- t++;
- printf("[CONST: $%X]", (uint32_t)*t);
+ tp.u32 = t + 1;
+ printf("[CONST: $%lX]", *tp.u64);
+ t += 2;
}
else if (*t == ACONST)
{
printf("[ENDEXPR]");
else if (*t == CR_ABSCOUNT)
printf("[CR_ABSCOUNT]");
+ else if (*t == CR_FILESIZE)
+ printf("[CR_FILESIZE]");
else if (*t == CR_DEFINED)
printf("[CR_DEFINED]");
else if (*t == CR_REFERENCED)
//
int dump_everything(void)
{
+ // FFS
+ if ((currentorg[1] - currentorg[0]) == 0)
+ sect[M6502].sfcode = NULL;
+
for(int i=1; i<NSECTS; i++)
{
if (sect[i].scattr & SUSED)