fix(cpu): perform MUL with u64s, throw away upper 32 bits

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:12:08 -03:00
parent 3e4d7e7ed8
commit 9cb4ebaa7f
1 changed files with 2 additions and 1 deletions

View File

@ -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) {