From 058c02150c4e49b0b078283c6d19827a9ab9850e Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:11 -0300 Subject: [PATCH] fix(cpu): op == 0b00 decodes to add in format 5 --- src/cpu/thumb/format5.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpu/thumb/format5.zig b/src/cpu/thumb/format5.zig index 33fb5b7..5c50bb2 100644 --- a/src/cpu/thumb/format5.zig +++ b/src/cpu/thumb/format5.zig @@ -5,6 +5,7 @@ const Arm7tdmi = @import("../../cpu.zig").Arm7tdmi; const InstrFn = @import("../../cpu.zig").ThumbInstrFn; const cmp = @import("../arm/data_processing.zig").cmp; +const add = @import("../arm/data_processing.zig").add; pub fn format5(comptime op: u2, comptime h1: u1, comptime h2: u1) InstrFn { return struct { @@ -13,6 +14,7 @@ pub fn format5(comptime op: u2, comptime h1: u1, comptime h2: u1) InstrFn { const dst = @as(u4, h1) << 3 | (opcode & 0x7); switch (op) { + 0b00 => cpu.r[dst] = add(false, cpu, cpu.r[dst], cpu.r[src]), // ADD 0b01 => cmp(cpu, cpu.r[dst], cpu.r[src]), // CMP 0b10 => cpu.r[dst] = cpu.r[src], // MOV 0b11 => { @@ -20,7 +22,6 @@ pub fn format5(comptime op: u2, comptime h1: u1, comptime h2: u1) InstrFn { cpu.cpsr.t.write(cpu.r[src] & 1 == 1); cpu.r[15] = cpu.r[src] & 0xFFFF_FFFE; }, - else => cpu.panic("[CPU|THUMB|Fmt5] {} is an invalid op", .{op}), } } }.inner;