From dd127f64fed2f346b34b0db69270954614ce044d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 3 Apr 2024 07:23:14 -0400 Subject: [PATCH] Simplify range. --- InstructionSets/ARM/BarrelShifter.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/InstructionSets/ARM/BarrelShifter.hpp b/InstructionSets/ARM/BarrelShifter.hpp index 7a52c5a2d..575388c7e 100644 --- a/InstructionSets/ARM/BarrelShifter.hpp +++ b/InstructionSets/ARM/BarrelShifter.hpp @@ -96,10 +96,12 @@ void shift(uint32_t &source, uint32_t amount, typename Carry::type ca // "ROR by 32 has result equal to Rm, carry out equal to bit 31 ... // [for] ROR by n where n is greater than 32 ... repeatedly subtract 32 from n // until the amount is in the range 1 to 32" - amount = ((amount - 1) & 31) + 1; - if constexpr (set_carry) carry = source & (1 << (amount - 1)); - if(amount != 32) { + amount &= 31; + if(amount) { + if constexpr (set_carry) carry = source & (1 << (amount - 1)); source = (source >> amount) | (source << (32 - amount)); + } else { + if constexpr (set_carry) carry = source & 0x8000'0000; } } break;