From 2ba09868ba6c931a6ef3a1ec87ddaaab253c8c69 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:11:58 -0300 Subject: [PATCH] feat(cpu): implement ARM SUB in data processing --- src/cpu/arm/data_processing.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cpu/arm/data_processing.zig b/src/cpu/arm/data_processing.zig index 57d64aa..4f05ca1 100644 --- a/src/cpu/arm/data_processing.zig +++ b/src/cpu/arm/data_processing.zig @@ -29,6 +29,18 @@ pub fn dataProcessing(comptime I: bool, comptime S: bool, comptime instrKind: u4 } 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 => { // ADD var result: u32 = undefined;