From ebcb344d647dc767b6ef50fb2ba2d3812d248441 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 8 May 2015 01:23:44 -0700 Subject: [PATCH] ARM7: Handle writeback for PC in addressing modes 2 and 3 --- CHANGES | 1 + src/arm/isa-arm.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 1c800631c..dab8d3eae 100644 --- a/CHANGES +++ b/CHANGES @@ -45,6 +45,7 @@ Bugfixes: - SDL: Fix boundary conditions for joystick adjustments - Util: Fix a null-pointer issue when attempting to delete a key - SDL: Allocate properly sized input maps + - ARM7: Handle writeback for PC in addressing modes 2 and 3 Misc: - Qt: Show multiplayer numbers in window title - Qt: Handle saving input settings better diff --git a/src/arm/isa-arm.c b/src/arm/isa-arm.c index fe691b1d9..802d91a81 100644 --- a/src/arm/isa-arm.c +++ b/src/arm/isa-arm.c @@ -233,7 +233,12 @@ static inline void _immediate(struct ARMCore* cpu, uint32_t opcode) { #define ADDR_MODE_2_RM (cpu->gprs[rm]) #define ADDR_MODE_2_IMMEDIATE (opcode & 0x00000FFF) #define ADDR_MODE_2_INDEX(U_OP, M) (cpu->gprs[rn] U_OP M) -#define ADDR_MODE_2_WRITEBACK(ADDR) (cpu->gprs[rn] = ADDR) +#define ADDR_MODE_2_WRITEBACK(ADDR) \ + cpu->gprs[rn] = ADDR; \ + if (UNLIKELY(rn == ARM_PC)) { \ + ARM_WRITE_PC; \ + } + #define ADDR_MODE_2_LSL (cpu->gprs[rm] << ADDR_MODE_2_I) #define ADDR_MODE_2_LSR (ADDR_MODE_2_I_TEST ? ((uint32_t) cpu->gprs[rm]) >> ADDR_MODE_2_I : 0) #define ADDR_MODE_2_ASR (ADDR_MODE_2_I_TEST ? ((int32_t) cpu->gprs[rm]) >> ADDR_MODE_2_I : ((int32_t) cpu->gprs[rm]) >> 31)