diff --git a/src/cpu/half_signed_data_transfer.zig b/src/cpu/half_signed_data_transfer.zig index 95a9bfe..7adfb2a 100644 --- a/src/cpu/half_signed_data_transfer.zig +++ b/src/cpu/half_signed_data_transfer.zig @@ -34,18 +34,17 @@ pub fn comptimeHalfSignedDataTransfer(comptime P: bool, comptime U: bool, compti }, 0b01 => { // LDRH - const halfword = bus.read16(address); - cpu.r[rd] = @as(u32, halfword); + cpu.r[rd] = bus.read16(address); }, 0b10 => { // LDRSB - const byte = bus.read8(address); - cpu.r[rd] = util.u32SignExtend(8, @as(u32, byte)); + cpu.r[rd] = util.u32SignExtend(8, @as(u32, bus.read8(address))); + std.debug.panic("TODO: Affect the CPSR", .{}); }, 0b11 => { // LDRSH - const halfword = bus.read16(address); - cpu.r[rd] = util.u32SignExtend(16, @as(u32, halfword)); + cpu.r[rd] = util.u32SignExtend(16, @as(u32, bus.read16(address))); + std.debug.panic("TODO: Affect the CPSR", .{}); }, } } else { @@ -58,7 +57,7 @@ pub fn comptimeHalfSignedDataTransfer(comptime P: bool, comptime U: bool, compti } address = modified_base; - if (W and P) cpu.r[rn] = address; + if (W and P or !P) cpu.r[rn] = address; } }.halfSignedDataTransfer; } diff --git a/src/cpu/single_data_transfer.zig b/src/cpu/single_data_transfer.zig index 2febda2..acef639 100644 --- a/src/cpu/single_data_transfer.zig +++ b/src/cpu/single_data_transfer.zig @@ -40,7 +40,7 @@ pub fn comptimeSingleDataTransfer(comptime I: bool, comptime P: bool, comptime U } address = modified_base; - if (W and P or !W) cpu.r[rn] = address; + if (W and P or !P) cpu.r[rn] = address; // TODO: W-bit forces non-privledged mode for the transfer }