Steve2/A2Mac/disassembler.h

76 lines
1.6 KiB
C
Raw Normal View History

2019-09-22 08:31:09 +00:00
//
// disassembler.h
// A2Mac
//
// Created by Tamas Rudnai on 9/21/19.
// Copyright © 2019 GameAlloy. All rights reserved.
//
#ifndef disassembler_h
#define disassembler_h
#ifdef DISASSEMBLER
#define disHexB( to, b ) \
if ( m6502.dbgLevel.trace ) { \
2019-09-22 08:31:09 +00:00
snprintf((to), 4, "%02X ", (b)); \
to += 3; \
}
#define disHexW( to, w ) \
if ( m6502.dbgLevel.trace ) { \
2019-09-22 08:31:09 +00:00
snprintf((to), 6, "%04X ", (w)); \
to += 5; \
}
#define disPuts( to, from ) { \
char * s = from; \
if ( m6502.dbgLevel.trace ) { \
2019-09-22 08:31:09 +00:00
while ( (*(to)++ = *s++) ); \
} \
}
#define disPrintf( to, fmt, args... ) { \
if ( m6502.dbgLevel.trace ) { \
2019-09-22 08:31:09 +00:00
snprintf( (to), sizeof(to), fmt, ##args ); \
} \
}
#define disNewInstruction() { \
if ( m6502.dbgLevel.trace ) { \
snprintf(disassembly.addr, 5, "%04X ", m6502.PC); \
*disassembly.opcode = '\0'; \
disassembly.pOpcode = disassembly.opcode; \
2019-09-22 08:31:09 +00:00
*disassembly.inst = '\0'; \
*disassembly.oper = '\0'; \
2019-09-22 08:31:09 +00:00
*disassembly.comment = '\0'; \
} \
}
INLINE void printDisassembly() {
if ( m6502.dbgLevel.trace ) {
2019-09-22 08:31:09 +00:00
printf("%s: %-14s%-6s%-14s%s\n",
disassembly.addr,
disassembly.opcode,
disassembly.inst,
disassembly.oper,
2019-09-22 08:31:09 +00:00
disassembly.comment
);
}
}
#else // DISASSEMBLER
#define disHexB( to, b )
#define disHexW( to, w )
#define disPuts( to, from )
#define disPrintf( to, fmt, args... )
#define disNewInstruction()
#define printDisassembly()
#endif // DISASSEMBLER
#endif /* disassembler_h */