all repos — mgba @ 10884de57abe52f8094a7d099381089c984d2ea4

mGBA Game Boy Advance Emulator

Add ability to print current instruction
Jeffrey Pfau jeffrey@endrift.com
Sat, 13 Apr 2013 00:22:27 -0700
commit

10884de57abe52f8094a7d099381089c984d2ea4

parent

67750e351b484d0898ee03e1886216b86607fbb8

1 files changed, 19 insertions(+), 0 deletions(-)

jump to
M src/debugger.csrc/debugger.c

@@ -52,6 +52,17 @@ kill(getpid(), SIGTRAP);

signal(SIGTRAP, oldSignal); } +static inline void _printLine(struct ARMDebugger* debugger, uint32_t address, enum ExecutionMode mode) { + // TODO: write a disassembler + if (mode == MODE_ARM) { + uint32_t instruction = debugger->cpu->memory->load32(debugger->cpu->memory, address); + printf("%08X\n", instruction); + } else { + uint16_t instruction = debugger->cpu->memory->loadU16(debugger->cpu->memory, address); + printf("%04X\n", instruction); + } +} + static void _printStatus(struct ARMDebugger* debugger) { int r; for (r = 0; r < 4; ++r) {

@@ -62,6 +73,14 @@ debugger->cpu->gprs[(r << 2) + 2],

debugger->cpu->gprs[(r << 2) + 3]); } _printPSR(debugger->cpu->cpsr); + int instructionLength; + enum ExecutionMode mode = debugger->cpu->cpsr.t; + if (mode == MODE_ARM) { + instructionLength = WORD_SIZE_ARM; + } else { + instructionLength = WORD_SIZE_THUMB; + } + _printLine(debugger, debugger->cpu->gprs[ARM_PC] - instructionLength, mode); } static void _quit(struct ARMDebugger* debugger) {