From 1bacb927af43bcb4afb97ef91344d65a8f296bfc Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Mon, 8 Jul 2019 21:03:47 +0300 Subject: [PATCH] Fix ROR with amount > 32 Former-commit-id: 8f88de3c55c0e452266c40944ff920175b83627e --- src/arm7tdmi/alu.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arm7tdmi/alu.rs b/src/arm7tdmi/alu.rs index a3f013b..4598a85 100644 --- a/src/arm7tdmi/alu.rs +++ b/src/arm7tdmi/alu.rs @@ -176,9 +176,9 @@ impl Core { val } _ => { - let result = val.rotate_right(amount); - self.cpsr.set_C((result >> 1) & 1 == 1); - result + let amount = amount % 32; + self.cpsr.set_C(((val as u32) >> (amount - 1)) & 1 == 1); + val.rotate_right(amount) } } }