From 5c7539cd26ded7e5c2e723f326eb2d5a71e71572 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:00 -0300 Subject: [PATCH] feat(cpu): implement CMN --- src/cpu/arm/data_processing.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cpu/arm/data_processing.zig b/src/cpu/arm/data_processing.zig index 3e193ed..b4a38b6 100644 --- a/src/cpu/arm/data_processing.zig +++ b/src/cpu/arm/data_processing.zig @@ -24,6 +24,7 @@ pub fn dataProcessing(comptime I: bool, comptime S: bool, comptime instrKind: u4 switch (instrKind) { 0x0 => { + // AND const result = op1 & op2; cpu.r[rd] = result; @@ -103,6 +104,16 @@ pub fn dataProcessing(comptime I: bool, comptime S: bool, comptime instrKind: u4 cpu.cpsr.c.write(op2 <= op1); cpu.cpsr.v.write(((op1 ^ result) & (~op2 ^ result)) >> 31 & 1 == 1); }, + 0xB => { + // CMN + var result: u32 = undefined; + const didOverflow = @addWithOverflow(u32, op1, op2, &result); + + cpu.cpsr.n.write(result >> 31 & 1 == 1); + cpu.cpsr.z.write(result == 0); + cpu.cpsr.c.write(didOverflow); + cpu.cpsr.v.write(((op1 ^ result) & (op2 ^ result)) >> 31 & 1 == 1); + }, 0xC => { // ORR const result = op1 | op2;