From 52e367d24afc68edec9d3eb7f83d1e81f9ebdcb1 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 1 Jan 2022 21:57:52 -0600 Subject: [PATCH] fix(cpu): purposely overflow when calculating PC during branch --- src/cpu.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu.zig b/src/cpu.zig index 07f2a99..bb1a2d5 100644 --- a/src/cpu.zig +++ b/src/cpu.zig @@ -213,7 +213,7 @@ fn comptimeBranch(comptime L: bool) InstrFn { cpu.r[14] = cpu.r[15] - 4; } - cpu.r[15] = cpu.fakePC() + util.u32SignExtend(24, opcode << 2); + cpu.r[15] = cpu.fakePC() +% util.u32SignExtend(24, opcode << 2); } }.branch; }