fix(cpu): account for overflow in THUMB alu MUL

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:12:10 -03:00
parent 152dafbdf7
commit 8d841ead50
1 changed files with 2 additions and 1 deletions

View File

@ -90,7 +90,8 @@ pub fn format4(comptime op: u4) InstrFn {
}, },
0xD => { 0xD => {
// MUL // MUL
const result = cpu.r[rs] * cpu.r[rd]; const temp = @as(u64, cpu.r[rs]) * @as(u64, cpu.r[rd]);
const result = @truncate(u32, temp);
cpu.r[rd] = result; cpu.r[rd] = result;
cpu.cpsr.n.write(result >> 31 & 1 == 1); cpu.cpsr.n.write(result >> 31 & 1 == 1);