feat(cpu): implement SUB in THUMB format 3
This commit is contained in:
parent
9098a55ae3
commit
85ffdf44f5
|
@ -28,6 +28,7 @@ pub fn format3(comptime op: u2, comptime rd: u3) InstrFn {
|
||||||
cpu.cpsr.v.write(((left ^ result) & (~offset ^ result)) >> 31 & 1 == 1);
|
cpu.cpsr.v.write(((left ^ result) & (~offset ^ result)) >> 31 & 1 == 1);
|
||||||
},
|
},
|
||||||
0b10 => {
|
0b10 => {
|
||||||
|
// ADD
|
||||||
const left = cpu.r[rd];
|
const left = cpu.r[rd];
|
||||||
|
|
||||||
var result: u32 = undefined;
|
var result: u32 = undefined;
|
||||||
|
@ -40,7 +41,15 @@ pub fn format3(comptime op: u2, comptime rd: u3) InstrFn {
|
||||||
cpu.cpsr.v.write(((left ^ result) & (offset ^ result)) >> 31 & 1 == 1);
|
cpu.cpsr.v.write(((left ^ result) & (offset ^ result)) >> 31 & 1 == 1);
|
||||||
},
|
},
|
||||||
0b11 => {
|
0b11 => {
|
||||||
std.debug.panic("TODO: Implement sub R{}, #0x{X:0>2}", .{ rd, offset });
|
// SUB
|
||||||
|
const left = cpu.r[rd];
|
||||||
|
const result = left -% offset;
|
||||||
|
cpu.r[rd] = result;
|
||||||
|
|
||||||
|
cpu.cpsr.n.write(result >> 31 & 1 == 1);
|
||||||
|
cpu.cpsr.z.write(result == 0);
|
||||||
|
cpu.cpsr.c.write(offset <= left);
|
||||||
|
cpu.cpsr.v.write(((left ^ result) & (~offset ^ result)) >> 31 & 1 == 1);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue