From 9c321c30c2b5d0d5c0ca43a21e308361937e2580 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 1 Nov 2020 02:22:09 -0800 Subject: [PATCH] ARM: Fix Addressing mode 1 shifter on rs == pc (fixes #1926) --- CHANGES | 4 ++++ src/arm/isa-arm.c | 24 ++++-------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index 5abfb8e2a..5c36e4e08 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +0.8.5: (Future) +Emulation fixes: + - ARM: Fix Addressing mode 1 shifter on rs == pc (fixes mgba.io/i/1926) + 0.8.4: (2020-10-29) Emulation fixes: - GB Audio: Fix initial sweep state diff --git a/src/arm/isa-arm.c b/src/arm/isa-arm.c index 68a9726dc..f1acaf81a 100644 --- a/src/arm/isa-arm.c +++ b/src/arm/isa-arm.c @@ -19,15 +19,11 @@ static inline void _shiftLSL(struct ARMCore* cpu, uint32_t opcode) { if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; int32_t shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; if (!shift) { cpu->shifterOperand = shiftVal; cpu->shifterCarryOut = cpu->cpsr.c; @@ -58,15 +54,11 @@ static inline void _shiftLSR(struct ARMCore* cpu, uint32_t opcode) { if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; uint32_t shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; if (!shift) { cpu->shifterOperand = shiftVal; cpu->shifterCarryOut = cpu->cpsr.c; @@ -97,15 +89,11 @@ static inline void _shiftASR(struct ARMCore* cpu, uint32_t opcode) { if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; int shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; if (!shift) { cpu->shifterOperand = shiftVal; cpu->shifterCarryOut = cpu->cpsr.c; @@ -136,15 +124,11 @@ static inline void _shiftROR(struct ARMCore* cpu, uint32_t opcode) { if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; int shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; int rotate = shift & 0x1F; if (!shift) { cpu->shifterOperand = shiftVal;