From 980e4ff5ddf2632a138030362818c85196155a86 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:06 -0300 Subject: [PATCH] fix(cpu): properly decode THUMB PUSH and POP at comptime --- src/cpu.zig | 4 ++-- src/cpu/thumb/format14.zig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cpu.zig b/src/cpu.zig index 75cefdf..65058df 100644 --- a/src/cpu.zig +++ b/src/cpu.zig @@ -394,8 +394,8 @@ fn thumbPopulate() [0x400]ThumbInstrFn { } if (i >> 6 & 0xF == 0b1011 and i >> 3 & 0x3 == 0b10) { - const L = i >> 11 & 1 == 1; - const R = i >> 8 & 1 == 1; + const L = i >> 5 & 1 == 1; + const R = i >> 2 & 1 == 1; lut[i] = format14(L, R); } diff --git a/src/cpu/thumb/format14.zig b/src/cpu/thumb/format14.zig index 25f64eb..651f882 100644 --- a/src/cpu/thumb/format14.zig +++ b/src/cpu/thumb/format14.zig @@ -44,7 +44,7 @@ pub fn format14(comptime L: bool, comptime R: bool) InstrFn { } } - cpu.r[13] = address; + cpu.r[13] = address + if (!L) 4 else 0; } }.inner; }