From e933d7e5c7b5114d47c7a29bbdff6e37bfefc988 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:17 -0300 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; } }