1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Simplify range.

This commit is contained in:
Thomas Harte 2024-04-03 07:23:14 -04:00
parent b19dcfd6dc
commit dd127f64fe

View File

@ -96,10 +96,12 @@ void shift(uint32_t &source, uint32_t amount, typename Carry<set_carry>::type ca
// "ROR by 32 has result equal to Rm, carry out equal to bit 31 ... // "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 // [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" // until the amount is in the range 1 to 32"
amount = ((amount - 1) & 31) + 1; amount &= 31;
if(amount) {
if constexpr (set_carry) carry = source & (1 << (amount - 1)); if constexpr (set_carry) carry = source & (1 << (amount - 1));
if(amount != 32) {
source = (source >> amount) | (source << (32 - amount)); source = (source >> amount) | (source << (32 - amount));
} else {
if constexpr (set_carry) carry = source & 0x8000'0000;
} }
} break; } break;