From fa211fa77e54222bca0817b2731a5bc9ec94628c Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Tue, 10 Sep 2019 01:01:49 +0300 Subject: [PATCH] Fix thumb NEG instruction. Finally pass armwrestler! This one took me quite a bit. :/ Former-commit-id: f08537dda5a62076c3faff31a898c0a585102526 --- src/core/arm7tdmi/thumb/exec.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/arm7tdmi/thumb/exec.rs b/src/core/arm7tdmi/thumb/exec.rs index 5e77ff7..20f33b5 100644 --- a/src/core/arm7tdmi/thumb/exec.rs +++ b/src/core/arm7tdmi/thumb/exec.rs @@ -1,5 +1,6 @@ use crate::core::arm7tdmi::bus::Bus; use crate::core::arm7tdmi::cpu::{Core, CpuExecResult}; +use crate::core::arm7tdmi::alu::AluOpCode; use crate::core::arm7tdmi::*; use crate::core::sysbus::SysBus; @@ -98,7 +99,11 @@ impl Core { let rd = insn.rd(); let (arm_alu_op, shft) = insn.alu_opcode(); - let op1 = self.get_reg(rd) as i32; + let op1 = if arm_alu_op == AluOpCode::RSB { + self.get_reg(insn.rs()) as i32 + } else { + self.get_reg(rd) as i32 + }; let op2 = if let Some(shft) = shft { self.get_barrel_shifted_value(shft) } else {