64-bit Shift by a Constant Number of Bits
Shifting a 64-bit operand on a processor with 32-bit registers always
requires a sequence of two or more instructions. Of course shifting
is always simpler when the number of bit positions to shift is a constant.
Shifting by 1 or 32 bits are special cases that have simple solutions.
Shifting by 2 to 31 bits requires a different approach than shifting
by 33 to 63 bits.
Shifting by 0 bits is never useful. A logical shift left (
LSL
) or right (
LSR
) by
more than 63 bits always produces all 0's. An arithmetic right shift
by more than 63 bits always produces either all 0's or all 1's. A
rotation by N bits, where N≥64 is the same as a rotation by
N%64 bits.
(Click anywhere to remove this message.)