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.)

64-bit Shift by Constant
Revised: Thursday, 23-Jun-2022 20:37:50 PDT
Shift Type:
Operands User Input ARM Assembly
64-bit Source (Hex): LDR R0,=source64
LDRD R0,R1,[R0]
Shift Constant (Decimal):
User
Entry
Intermediate
32-bit Value
Final 64-bit
Result
Reference: https://gcc.godbolt.org/z/VcbBmR