fix: respond to `@addWithOverflow` changes in latest zig
This commit is contained in:
parent
0cec779545
commit
5fa6917689
|
@ -62,7 +62,9 @@ pub fn dataProcessing(comptime I: bool, comptime S: bool, comptime kind: u4) Ins
|
||||||
if (rd == 0xF)
|
if (rd == 0xF)
|
||||||
return undefinedTestBehaviour(cpu);
|
return undefinedTestBehaviour(cpu);
|
||||||
|
|
||||||
overflow = @addWithOverflow(u32, op1, op2, &result);
|
const tmp = @addWithOverflow(op1, op2);
|
||||||
|
result = tmp[0];
|
||||||
|
overflow = tmp[1] == 0b1;
|
||||||
},
|
},
|
||||||
0xC => result = op1 | op2, // ORR
|
0xC => result = op1 | op2, // ORR
|
||||||
0xD => result = op2, // MOV
|
0xD => result = op2, // MOV
|
||||||
|
@ -163,18 +165,18 @@ pub fn sbc(left: u32, right: u32, old_carry: u1) u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(overflow: *bool, left: u32, right: u32) u32 {
|
pub fn add(overflow: *bool, left: u32, right: u32) u32 {
|
||||||
var ret: u32 = undefined;
|
const ret = @addWithOverflow(left, right);
|
||||||
overflow.* = @addWithOverflow(u32, left, right, &ret);
|
overflow.* = ret[1] == 0b1;
|
||||||
return ret;
|
|
||||||
|
return ret[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adc(overflow: *bool, left: u32, right: u32, old_carry: u1) u32 {
|
pub fn adc(overflow: *bool, left: u32, right: u32, old_carry: u1) u32 {
|
||||||
var ret: u32 = undefined;
|
const tmp = @addWithOverflow(left, right);
|
||||||
const first = @addWithOverflow(u32, left, right, &ret);
|
const ret = @addWithOverflow(tmp[0], old_carry);
|
||||||
const second = @addWithOverflow(u32, ret, old_carry, &ret);
|
overflow.* = (tmp[1] | ret[1]) == 0b1;
|
||||||
|
|
||||||
overflow.* = first or second;
|
return ret[0];
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn undefinedTestBehaviour(cpu: *Arm7tdmi) void {
|
fn undefinedTestBehaviour(cpu: *Arm7tdmi) void {
|
||||||
|
|
|
@ -34,7 +34,12 @@ pub fn fmt4(comptime op: u4) InstrFn {
|
||||||
0x8 => result = op1 & op2, // TST
|
0x8 => result = op1 & op2, // TST
|
||||||
0x9 => result = 0 -% op2, // NEG
|
0x9 => result = 0 -% op2, // NEG
|
||||||
0xA => result = op1 -% op2, // CMP
|
0xA => result = op1 -% op2, // CMP
|
||||||
0xB => overflow = @addWithOverflow(u32, op1, op2, &result), // CMN
|
0xB => {
|
||||||
|
// CMN
|
||||||
|
const tmp = @addWithOverflow(op1, op2);
|
||||||
|
result = tmp[0];
|
||||||
|
overflow = tmp[1] == 0b1;
|
||||||
|
},
|
||||||
0xC => result = op1 | op2, // ORR
|
0xC => result = op1 | op2, // ORR
|
||||||
0xD => result = @truncate(u32, @as(u64, op2) * @as(u64, op1)),
|
0xD => result = @truncate(u32, @as(u64, op2) * @as(u64, op1)),
|
||||||
0xE => result = op1 & ~op2,
|
0xE => result = op1 & ~op2,
|
||||||
|
|
Loading…
Reference in New Issue