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 ) \
|
2019-11-28 04:27:32 +00:00
|
|
|
if ( m6502.dbgLevel.trace ) { \
|
2019-09-22 08:31:09 +00:00
|
|
|
snprintf((to), 4, "%02X ", (b)); \
|
|
|
|
to += 3; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define disHexW( to, w ) \
|
2019-11-28 04:27:32 +00:00
|
|
|
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; \
|
2019-11-28 04:27:32 +00:00
|
|
|
if ( m6502.dbgLevel.trace ) { \
|
2019-09-22 08:31:09 +00:00
|
|
|
while ( (*(to)++ = *s++) ); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define disPrintf( to, fmt, args... ) { \
|
2019-11-28 04:27:32 +00:00
|
|
|
if ( m6502.dbgLevel.trace ) { \
|
2019-09-22 08:31:09 +00:00
|
|
|
snprintf( (to), sizeof(to), fmt, ##args ); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define disNewInstruction() { \
|
2019-11-28 04:27:32 +00:00
|
|
|
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'; \
|
2019-11-28 04:27:32 +00:00
|
|
|
*disassembly.oper = '\0'; \
|
2019-09-22 08:31:09 +00:00
|
|
|
*disassembly.comment = '\0'; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
INLINE void printDisassembly() {
|
2019-11-28 04:27:32 +00:00
|
|
|
if ( m6502.dbgLevel.trace ) {
|
2019-09-22 08:31:09 +00:00
|
|
|
printf("%s: %-14s%-6s%-14s%s\n",
|
|
|
|
disassembly.addr,
|
2019-11-28 04:27:32 +00:00
|
|
|
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 */
|