ROTATE Instructions in 8085

28 Apr, 2022
ROTATE is a logical operation of the 8085 microprocessor. It is a 1-byte instruction. This instruction does not require any operand after the opcode. It operates the content of the accumulator and the result is also stored in the accumulator. The Rotate instruction is used to rotate the bits of accumulator. Types of ROTATE Instruction: There are 4 categories of the ROTATE instruction: Rotate accumulator left (RLC), Rotate accumulator left through carrying (RAL), Rotate accumulator right (RRC), Rotate accumulator right through carry (RAR). Among these four instructions; two are for rotating left and two are for rotating right. All of them are explained briefly in the following sections:
Rotate accumulator left (RLC) – In this instruction, each bit is shifted to the adjacent left position. Bit D7 becomes D0. Carry flag CY is modified according to the bit D7. For example:-
Rotate accumulator left (RLC) – In this instruction, each bit is shifted to the adjacent left position. Bit D7 becomes D0. Carry flag CY is modified according to the bit D7. For example:-
A = D7 D6 D5 D4 D3 D2 D1 D0

//before the instruction
A = 10101010; CY=0  

//after 1st RLC           
A = 01010101; CY=1      

//after 2nd RLC 
A = 10101010; CY=0 
Rotate accumulator left through carry (RAL) – In this instruction, each bit is shifted to the adjacent left position. Bit D7 becomes the carry bit and the carry bit is shifted into D0. Carry flag CY is modified according to the bit D7. For example:
Rotate accumulator left through carry (RAL) – In this instruction, each bit is shifted to the adjacent left position. Bit D7 becomes the carry bit and the carry bit is shifted into D0. Carry flag CY is modified according to the bit D7. For example:
A = D7 D6 D5 D4 D3 D2 D1 D0

//before the instruction
A = 10101010; CY=0 

//after 1st RAL
A = 01010100; CY=1

//after 2nd RAL
A = 10101001; CY=0 
Rotate accumulator right (RRC) – In this instruction, each bit is shifted to the adjacent right position. Bit D7 becomes D0. Carry flag CY is modified according to the bit D0. For example:
Rotate accumulator right (RRC) – In this instruction, each bit is shifted to the adjacent right position. Bit D7 becomes D0. Carry flag CY is modified according to the bit D0. For example:
A = D7 D6 D5 D4 D3 D2 D1 D0

//before the instruction
A = 10000001; CY=0     

//after 1st RRC        
A = 11000000; CY=1    

//after 2nd RRC         
A = 01100000; CY=0 
Rotate accumulator right through carry (RAR) – In this instruction, each bit is shifted to the adjacent right position. Bit D0 becomes the carry bit and the carry bit is shifted into D7. Carry flag CY is modified according to the bit D0. For example:
Rotate accumulator right through carry (RAR) – In this instruction, each bit is shifted to the adjacent right position. Bit D0 becomes the carry bit and the carry bit is shifted into D7. Carry flag CY is modified according to the bit D0. For example:
A = D7 D6 D5 D4 D3 D2 D1 D0

//before the instruction
A = 10000001; CY=0  

//after 1st RAR           
A = 01000000; CY=1   

//after 2nd RAR          
A = 10100000; CY=0 
Applications of ROTATE Instructions: The ROTATE instructions are primarily used in arithmetic multiply and divide operations and for serial data transfer. For example:
If A is 0000 1000 = 08H 

1. By rotating 08H right : A = 0000 0100 = 04H
    This is equivalent to dividing by 2.

2. By rotating 08H left : A = 0001 0000 = 10H
    This is equivalent to multiplying by 2. 
However, these procedures are invalid when logic 1 is rotated left from D7 to D0 or vice versa. For example, if 80H is rotated left it becomes 01H.
SakshamGoyal
rajuldubey
microprocessor
Computer Organization & Architecture
GATE CS
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Computer Architecture | Flynn's taxonomy
I2C Communication Protocol
Architecture of Distributed Shared Memory(DSM)
ARM processor and its Features
Direct Access Media (DMA) Controller in Computer Architecture
Layers of OSI Model
Three address code in Compiler
Types of Operating Systems
ACID Properties in DBMS
Page Replacement Algorithms in Operating Systems