From 9cb4ebaa7fcaac2798487c8d0d2375a755767ef7 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:08 -0300 Subject: [PATCH] fix(cpu): perform MUL with u64s, throw away upper 32 bits --- src/cpu/arm/multiply.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpu/arm/multiply.zig b/src/cpu/arm/multiply.zig index f3f3721..a34f9f1 100644 --- a/src/cpu/arm/multiply.zig +++ b/src/cpu/arm/multiply.zig @@ -12,7 +12,8 @@ pub fn multiply(comptime A: bool, comptime S: bool) InstrFn { const rs = opcode >> 8 & 0xF; const rm = opcode & 0xF; - const result = cpu.r[rm] * cpu.r[rs] + if (A) cpu.r[rn] else 0; + const temp: u64 = @as(u64, cpu.r[rm]) * @as(u64, cpu.r[rs]) + if (A) cpu.r[rn] else 0; + const result = @truncate(u32, temp); cpu.r[rd] = result; if (S) {