The <strong>Cortex</strong>-<strong>M0+</strong> Instruction Set3.5.3 ASR, LSL, LSR, and RORArithmetic Shift Right, Logical Shift Left, Logical Shift Right, and Rotate Right.SyntaxASRS {Rd,} Rm, RsASRS {Rd,} Rm, #immLSLS {Rd,} Rm, RsLSLS {Rd,} Rm, #immLSRS {Rd,} Rm, RsLSRS {Rd,} Rm, #immRORS {Rd,} Rm, Rswhere:RdRmRsimmIs the destination register. If Rd is omitted, it is assumed to take the same value asRm.Is the register holding the value to be shifted.Is the register holding the shift length to apply to the value in Rm.Is the shift length. The range of shift length depends on the instruction:ASR shift length from 1 to 32LSL shift length from 0 to 31LSR shift length from 1 to 32.NoteMOVS Rd, Rm is a pseudonym for LSLS Rd, Rm, #0.OperationASR, LSL, LSR, and ROR perform an arithmetic-shift-left, logical-shift-left, logical-shift-right or aright-rotation of the bits in the register Rm by the number of places specified by the immediateimm or the value in the least-significant byte of the register specified by Rs.For details of what result is generated by the different instructions, see Shift operations onpage 3-6.RestrictionsIn these instructions, Rd, Rm, and Rs must only specify R0-R7. For non-immediate instructions,Rd and Rm must specify the same register.Condition flagsThese instructions update the N and Z flags according to the result.The C flag is updated to the last bit shifted out, except when the shift length is 0, see Shiftoperations on page 3-6. The V flag is left unmodified.ARM DUI 0662A Copyright © 2012 ARM. All rights reserved. 3-24ID041812Non-Confidential
The <strong>Cortex</strong>-<strong>M0+</strong> Instruction SetExamplesASRS R7, R5, #9 ; Arithmetic shift right by 9 bitsLSLS R1, R2, #3 ; Logical shift left by 3 bits with flag updateLSRS R4, R5, #6 ; Logical shift right by 6 bitsRORS R4, R4, R6 ; Rotate right by the value in the bottom byte of R6.ARM DUI 0662A Copyright © 2012 ARM. All rights reserved. 3-25ID041812Non-Confidential