diff --git a/src/cpu/thumb/data_transfer.zig b/src/cpu/thumb/data_transfer.zig index 6d09719..3b18d2b 100644 --- a/src/cpu/thumb/data_transfer.zig +++ b/src/cpu/thumb/data_transfer.zig @@ -28,26 +28,28 @@ pub fn format78(comptime op: u2, comptime T: bool) InstrFn { const address = cpu.r[rb] + cpu.r[ro]; if (T) { + // Format 8 switch (op) { 0b00 => { // STRH bus.write16(address & 0xFFFF_FFFE, @truncate(u16, cpu.r[rd])); }, 0b01 => { + // LDSB + cpu.r[rd] = u32SignExtend(8, @as(u32, bus.read8(address))); + }, + 0b10 => { // LDRH const value = bus.read16(address & 0xFFFF_FFFE); cpu.r[rd] = std.math.rotr(u32, @as(u32, value), 8 * (address & 1)); }, - 0b10 => { - // LDSB - cpu.r[rd] = u32SignExtend(8, @as(u32, bus.read8(address))); - }, 0b11 => { // LDSH cpu.r[rd] = u32SignExtend(16, @as(u32, bus.read16(address & 0xFFFF_FFFE))); }, } } else { + // Format 7 switch (op) { 0b00 => { // STR