feat(cpu): implement ARM SUB in data processing

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-01-17 11:35:41 -04:00
parent c0d956ea95
commit 9098a55ae3
1 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,18 @@ pub fn dataProcessing(comptime I: bool, comptime S: bool, comptime instrKind: u4
} }
switch (instrKind) { switch (instrKind) {
0x2 => {
// SUB
const result = op1 -% op2;
cpu.r[rd] = result;
if (S and rd != 0xF) {
cpu.cpsr.n.write(result >> 31 & 1 == 1);
cpu.cpsr.z.write(result == 0);
cpu.cpsr.c.write(op2 <= op1);
cpu.cpsr.v.write(((op1 ^ result) & (~op2 ^ result)) >> 31 & 1 == 1);
}
},
0x4 => { 0x4 => {
// ADD // ADD
var result: u32 = undefined; var result: u32 = undefined;