From 9bb39fe1350a39cbce516827835ec5a8a1adbe53 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Fri, 15 May 2020 16:23:42 +0300 Subject: [PATCH] Fix gba-suite arm test #530 Fixes edge-case in STMDA with empty rlist Former-commit-id: 5f43fa19e0faad7d27d022480d856ab0c52f1d56 Former-commit-id: 8e2392e1dd34fb161aa1b2c3445272f06f432316 --- rustboyadvance-core/src/arm7tdmi/arm/exec.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rustboyadvance-core/src/arm7tdmi/arm/exec.rs b/rustboyadvance-core/src/arm7tdmi/arm/exec.rs index 50fb107..e00e282 100644 --- a/rustboyadvance-core/src/arm7tdmi/arm/exec.rs +++ b/rustboyadvance-core/src/arm7tdmi/arm/exec.rs @@ -626,9 +626,20 @@ impl Core { self.reload_pipeline32(sb); result = CpuAction::FlushPipeline; } else { + // block data store with empty rlist + let addr = match (ascending, full) { + (false, false) => addr.wrapping_sub(0x3c), + (false, true) => addr.wrapping_sub(0x40), + (true, false) => addr, + (true, true) => addr.wrapping_add(4), + }; self.write_32(addr, self.pc + 4, sb); } - addr = addr.wrapping_add(0x40); + addr = if ascending { + addr.wrapping_add(0x40) + } else { + addr.wrapping_sub(0x40) + }; } if user_bank_transfer {