| |||
| Home > ARM and Thumb Instructions > General data processing instructions > ASR, LSL, LSR, ROR, and RRX | |||
Arithmetic Shift Right, Logical Shift Left, Logical Shift Right, Rotate Right, and Rotate Right with Extend.
These instructions are the preferred synonyms for MOV instructions
with shifted register operands.
op{S}{cond}Rd,Rm,Rs
op{S}{cond}Rd,Rm, #sh
RRX{S}{cond} Rd, Rm
where:
opis one of ASR, LSL, LSR,
or ROR.
Sis
an optional suffix. If S is specified, the
condition code flags are updated on the result of the operation.
Rdis the destination register.
Rmis the register holding the first operand. This operand is shifted right.
Rsis a register holding a shift value to apply to
the value in . Only
the least significant byte is used.Rm
shis a constant shift. The range of values permitted depends on the instruction:
ASRpermitted shifts 1-32
LSLpermitted shifts 0-31
LSRpermitted shifts 1-32
RORpermitted shifts 1-31.
ASR provides the signed value of the contents
of a register divided by a power of two. It copies the sign bit
into vacated bit positions on the left.
LSL provides the value of a register multiplied
by a power of two. LSR provides the unsigned value
of a register divided by a variable power of two. Both instructions
insert zeros into the vacated bit positions.
ROR provides the value of the contents of a register
rotated by a value. The bits that are rotated off the right end
are inserted into the vacated bit positions on the left.
RRX provides the value of the contents of a register
shifted right one bit. The old carry flag is shifted into bit[31].
If the S suffix is present, the old bit[0] is
placed in the carry flag.
You can use SP in these ARM instructions but these are deprecated in ARMv6T2 and above.
You cannot use PC in instructions with the op{S}{cond}
Rd, Rm, Rs syntax. You can use PC for R and dR in
the other syntaxes, but these are deprecated in ARMv6T2 and above. m
If you use PC as ,
the value used is the address of the instruction plus 8.Rm
If you use PC as :Rd
Execution branches to the address corresponding to the result.
If you use the S suffix,
the SPSR of the current mode is copied to the CPSR. You can use this
to return from exceptions.
The ARM instructions and opS{cond}
pc,Rm,#shRRXS{cond} pc,Rm always disassemble
to the preferred form MOVS{.cond}
pc,Rm{,shift}
Do not use the S suffix when using
PC as in User
mode or System mode. The effect of such an instruction is unpredictable,
but the assembler cannot warn you at assembly time.Rd
You cannot use PC for or
any operand in any of these instructions if they have a register-controlled
shift.Rd
If S is specified, these instructions
update the N and Z flags according to the result.
The C flag is unaffected if the shift value is 0. Otherwise, the C flag is updated to the last bit shifted out.
The following forms of these instructions are available in Thumb code, and are 16-bit instructions:
ASRS Rd, Rm,
#sh and Rd must
both be Lo registers.Rm
ASRS Rd, Rd, Rs and Rd must
both be Lo registers.Rs
LSLS Rd, Rm,
#sh and Rd must
both be Lo registers.Rm
LSLS Rd, Rd, Rs and Rd must
both be Lo registers.Rs
LSRS Rd, Rm,
#sh and Rd must
both be Lo registers.Rm
LSRS Rd, Rd, Rs and Rd must
both be Lo registers.Rs
RORS Rd, Rd, Rs and Rd must
both be Lo registers.Rs
These ARM instructions are available in all architectures.
These 32-bit Thumb instructions are available in ARMv6T2 and above.
These 16-bit Thumb instructions are available in ARMv4T and above.
There is no 16-bit Thumb RRX instruction.