The ARM architecture provides some shift and rotation operations:
| mnemonic | operation | action |
|---|---|---|
LSL #n | Logical Shift Left by n bits. | Signed or unsigned multiplication by . |
LSR #n | Logical Shift Right by n bits. | Unsigned division by . |
ASR #n | Arithmetic Shift Right by n bits. | Signed division by . |
ROR #n | Rotate Right by n bits. | Rotate bits around, and set Carry to LSB. |
RRX #n | Rotate Right Extended by n bits. | Rotate bits around through Carry. |
Using Shift and Rotation Operations
One of the inputs of any instruction can be shifted or rotated. For example:
MOV R0, R0, LSL #1 ; R0 <= R0 * 2 This can be used to make some operations more efficient. For example, consider the following two approaches to multiplication by 5:
MOV R1, #5 ; literals cannot be used with MUL
MUL R0, R1vs
ADD R0, R0, LSL #2