chore: modify type signature of util.sext

This commit is contained in:
2022-05-23 12:58:31 -03:00
parent f130d1991c
commit ff3f79801c
5 changed files with 19 additions and 14 deletions

View File

@@ -10,7 +10,7 @@ pub fn branch(comptime L: bool) InstrFn {
return struct {
fn inner(cpu: *Arm7tdmi, _: *Bus, opcode: u32) void {
if (L) cpu.r[14] = cpu.r[15];
cpu.r[15] = cpu.fakePC() +% (sext(24, opcode) << 2);
cpu.r[15] = cpu.fakePC() +% (sext(u32, u24, opcode) << 2);
}
}.inner;
}

View File

@@ -43,14 +43,14 @@ pub fn halfAndSignedDataTransfer(comptime P: bool, comptime U: bool, comptime I:
},
0b10 => {
// LDRSB
result = sext(8, bus.read(u8, address));
result = sext(u32, u8, bus.read(u8, address));
},
0b11 => {
// LDRSH
result = if (address & 1 == 1) blk: {
break :blk sext(8, bus.read(u8, address));
break :blk sext(u32, u8, bus.read(u8, address));
} else blk: {
break :blk sext(16, bus.read(u16, address));
break :blk sext(u32, u16, bus.read(u16, address));
};
},
0b00 => unreachable, // SWP