| |||
| Home > Thumb Instruction Reference > Thumb general data processing instructions > ASR, LSL, LSR, and ROR | |||
Shift and rotate operations. These instructions can use a value contained in a register, or an immediate shift value.
opRd,Rs
opRd,Rm, #expr
where:
opis one of:
ASRArithmetic Shift Right. Register contents are treatedas two’s complement signed integers. The sign bit is copied into vacated bits.
LSLLogical Shift Left. Vacated bits are cleared.
LSRLogical Shift Right. Vacated bits are cleared.
RORRotate Right. Bits moved out of the right-hand end of the register are rotated back into the left-hand end.
ROR can only be used with a register-controlled
shift.
Rdis the destination register. It is also the source
register for register-controlled shifts. must
be in the range Rdr0-r7.
Rsis the register containing the shift value for register-controlled
shifts. must
be in the range Rmr0-r7.
Rmis the source register for immediate shifts. must
be in the range Rmr0-r7.
expris the immediate shift value. It is an expression evaluating (at assembly time) to an integer in the range:
0-31 if is opLSL
1-32 otherwise.
These instructions take the value from ,
apply the shift to it, and place the result back into Rd.Rd
Only the least significant byte of is
used for the shift value.Rs
For all these instructions except ROR:
if the shift is
32, is cleared,
and the last bit shifted out remains in the C flagRd
if the shift is greater than 32, and
the C flag are cleared.Rd
These instructions take the value from ,
apply the shift to it, and place the result into Rm.Rd
These instructions update the N and Z flags according to the result. The V flag is not affected.
The C flag:
is unaffected if the shift value is zero
otherwise, contains the last bit shifted out of the source register.
ASR r3,r5
LSR r0,r2,#6
LSR r5,r5,av ; av must evaluate, at assembly time, to an
; integer in the range 1-32.
LSL r0,r4,#0 ; same as MOV r0,r4 except that C and V
; flags are not affected