ARM7: Add function for turning r15 into the address of the current instruction

This commit is contained in:
Jeffrey Pfau 2015-02-03 01:23:49 -08:00
parent 7149dd3102
commit 8caf58ee42
2 changed files with 13 additions and 2 deletions

View File

@ -91,4 +91,15 @@ static inline void _ARMReadCPSR(struct ARMCore* cpu) {
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

View File

@ -628,7 +628,7 @@ void GBAHitStub(struct ARMCore* cpu, uint32_t opcode) {
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 @@ void GBAIllegal(struct ARMCore* cpu, uint32_t opcode) {
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);