Professional Documents
Culture Documents
Microprocessor System
Microprocessor Assembly Language Programming
What we will learn in this section:
In rotate right, as bits are shifted from left to right they exit from the right end (LSB)
and enter the left end (MSB). In addition, as each bit exits the LSB, a copy of it is given to
the carry flag. In other words, in ROR the LSB is moved to the MSB and is also copied to
C flag, as shown in the diagram.
RORS Rotate Right (update the flags)
The RORS instruction has the following format:
RORS Rd,Rm,Rn ;Rd=rotate Rm right Rn bit positions
As each bit of Rm register shifts from left to right, they exit from the right end (LSB) and
enter from the left end (MSB). In addition as each bit exits the LSB, a copy of it is given
to C flag.
The number of bits to be rotated right is given by Rn and the result is placed in Rd
register. The RORS updates the flags.
Example:
LDR R2,=0x00000010
RORS R0,R2,#8 ;R0=R2 is rotated right 8 times
;now, R0= 0x01000000, C=0, N=0, Z=0
TUTORIAL 6
1) Find the contents of R3 after executing the following code:
MOV R1,#0x08
ROR R2,R1,#2
2) Find the contents of R4 after executing the following code:
MOV R2,#0x3
LSL R5,R3,#2
3) Using rotate instruction, show how you rotate left the fixed value of 0x33
total of a) 4, b) 8, and c) 12 times. Also give the value in the register after
the rotation.
4) What is content of R1 after executing following instruction, assume R1
contain 0x00000500
a) LSL R1,R1,8 b) LSR R1,R1.4