From adfd501fc40b2862d8f8f46b0c33d27032ee5aff Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 5 Feb 2022 23:18:23 -0400 Subject: [PATCH] fix(cpu): force-align SWP reads and writes --- src/cpu/arm/single_data_swap.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpu/arm/single_data_swap.zig b/src/cpu/arm/single_data_swap.zig index c7b531a..f8e76cc 100644 --- a/src/cpu/arm/single_data_swap.zig +++ b/src/cpu/arm/single_data_swap.zig @@ -20,8 +20,8 @@ pub fn singleDataSwap(comptime B: bool) InstrFn { cpu.r[rd] = value; } else { // SWP - const value = std.math.rotr(u32, bus.read32(address), 8 * (address & 0x3)); - bus.write32(address, cpu.r[rm]); + const value = std.math.rotr(u32, bus.read32(address & 0xFFFF_FFFC), 8 * (address & 0x3)); + bus.write32(address & 0xFFFF_FFFC, cpu.r[rm]); cpu.r[rd] = value; } }