ARM7: Add function for turning r15 into the address of the current instruction
Jeffrey Pfau jeffrey@endrift.com
Tue, 03 Feb 2015 01:23:49 -0800
2 files changed,
13 insertions(+),
2 deletions(-)
M
src/arm/isa-inlines.h
→
src/arm/isa-inlines.h
@@ -91,4 +91,15 @@ ARMSetPrivilegeMode(cpu, cpu->cpsr.priv);
cpu->irqh.readCPSR(cpu); } +static inline uint32_t _ARMPCAddress(struct ARMCore* cpu) { + int instructionLength; + enum ExecutionMode mode = cpu->cpsr.t; + if (mode == MODE_ARM) { + instructionLength = WORD_SIZE_ARM; + } else { + instructionLength = WORD_SIZE_THUMB; + } + return cpu->gprs[ARM_PC] - instructionLength * 2; +} + #endif
M
src/gba/gba.c
→
src/gba/gba.c
@@ -628,7 +628,7 @@ enum GBALogLevel level = GBA_LOG_FATAL;
if (gba->debugger) { level = GBA_LOG_STUB; struct DebuggerEntryInfo info = { - .address = cpu->gprs[ARM_PC], + .address = _ARMPCAddress(cpu), .opcode = opcode }; ARMDebuggerEnter(gba->debugger, DEBUGGER_ENTER_ILLEGAL_OP, &info);@@ -641,7 +641,7 @@ struct GBA* gba = (struct GBA*) cpu->master;
GBALog(gba, GBA_LOG_WARN, "Illegal opcode: %08x", opcode); if (gba->debugger) { struct DebuggerEntryInfo info = { - .address = cpu->gprs[ARM_PC], + .address = _ARMPCAddress(cpu), .opcode = opcode }; ARMDebuggerEnter(gba->debugger, DEBUGGER_ENTER_ILLEGAL_OP, &info);