From 477b4f45fdffe8f1db290c776b9db6e470d826ec Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Sat, 27 Jul 2019 20:25:59 +0300 Subject: [PATCH] Fix thumb MUL not setting the flags Former-commit-id: b43e35a7fa2894fcc5cef7eeae9d74123e40219b --- src/core/arm7tdmi/arm/exec.rs | 2 ++ src/core/arm7tdmi/thumb/exec.rs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/arm7tdmi/arm/exec.rs b/src/core/arm7tdmi/arm/exec.rs index bd5c427..1ef58a3 100644 --- a/src/core/arm7tdmi/arm/exec.rs +++ b/src/core/arm7tdmi/arm/exec.rs @@ -448,6 +448,8 @@ impl Core { if insn.set_cond_flag() { self.cpsr.set_N((result as i32) < 0); self.cpsr.set_Z(result == 0); + self.cpsr.set_C(false); + self.cpsr.set_V(false); } Ok(()) diff --git a/src/core/arm7tdmi/thumb/exec.rs b/src/core/arm7tdmi/thumb/exec.rs index 6fd3ae3..691cb4f 100644 --- a/src/core/arm7tdmi/thumb/exec.rs +++ b/src/core/arm7tdmi/thumb/exec.rs @@ -85,7 +85,10 @@ impl Core { for _ in 0..m { self.add_cycle(); } - self.gpr[insn.rd()] = op1.wrapping_mul(op2) as u32; + let result = op1.wrapping_mul(op2) as u32; + self.cpsr.set_N((result as i32) < 0); + self.cpsr.set_Z(result == 0); + self.gpr[insn.rd()] = result; Ok(()) }