all repos — mgba @ 8caf58ee4291f9cc523bf459bbdfcd1d46ac8046

mGBA Game Boy Advance Emulator

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
commit

8caf58ee4291f9cc523bf459bbdfcd1d46ac8046

parent

7149dd3102a6bbb7f73cae7da0c01dc784b0f601

2 files changed, 13 insertions(+), 2 deletions(-)

jump to
M src/arm/isa-inlines.hsrc/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.csrc/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);