Rotate Instructions
RLC, RRC, RAL, RAR usage.
The 8085 provides four rotate instructions that shift all 8 bits of the Accumulator (A) one position to the left or right in a circular fashion. These instructions are fundamental for tasks like serial data processing, bit manipulation, multiplication and division by powers of two, and CRC computation. Two of the four rotate instructions involve the Carry flag as part of the rotation loop, making them useful for multi-byte shift operations. GATE exams test the exact bit movement and flag behavior of each rotate instruction.
RLC: Rotate Accumulator Left
The RLC (Rotate Left Circular) instruction shifts each bit of the Accumulator one position to the left. The Most Significant Bit (b7) wraps around and is placed into the Least Significant Bit position (b0). The same b7 bit is also copied into the Carry flag (CY). The operation is equivalent to an 8-bit circular rotation where the carry gets a copy of the exiting bit, but the carry is not part of the rotation ring itself.
Mathematical equivalent: if A = 1010 0010b (A2H), after RLC, A = 0100 0101b (45H) and CY = 1 (original b7). This instruction is equivalent to multiplying the accumulator by 2 when there is no overflow (when b7 was 0). When b7 is 1, the multiplication overflows and the extra bit appears in CY.
RRC: Rotate Accumulator Right
The RRC (Rotate Right Circular) instruction shifts each bit of the Accumulator one position to the right. The Least Significant Bit (b0) wraps around and is placed into the Most Significant Bit position (b7). The same b0 bit is also copied into the Carry flag. Like RLC, the carry receives a copy of the exiting bit but is not itself part of the circular ring.
RRC is equivalent to dividing the accumulator by 2 when b0 was 0. If b0 was 1, the division is inexact and the remainder appears in CY. For A = A2H = 1010 0010b: after RRC, A = 0101 0001b = 51H and CY = 0 (original b0 = 0).
RAL: Rotate Left Through Carry
The RAL (Rotate Accumulator Left through Carry) instruction forms a 9-bit circular ring using all 8 bits of the Accumulator and the Carry flag together. Each bit shifts one position to the left. The b7 bit exits into CY, and the old CY value enters b0. This is a true 9-bit rotation, not an 8-bit rotation with a copy to carry.
RAL is extremely useful for multi-byte shift operations. To shift a 16-bit number stored in registers A and B left by one bit, you would execute RAL on the lower byte (A), which shifts b7 of A into CY, and then execute RAL on the upper byte (B), which shifts the old carry (the overflowed b7 of A) into b0 of B. This chains the shifts across register boundaries.
RAR: Rotate Right Through Carry
The RAR (Rotate Accumulator Right through Carry) instruction forms the same 9-bit circular ring as RAL but rotates in the right direction. b0 exits into CY, and the old CY value enters b7. This is the right-shift version of RAL and is equally important for multi-byte right shifts. For example, to right-shift a 16-bit value in B (high) and A (low), execute RAR on B first (shifting B's b0 into CY) and then RAR on A (the old carry enters A's b7).
Flag Effects and Properties
All four rotate instructions share the same properties: they are 1-byte instructions requiring 4 T-states. Only the Carry flag (CY) is affected. The Sign (S), Zero (Z), Auxiliary Carry (AC), and Parity (P) flags are completely unaffected by any rotate instruction. This makes rotate instructions unique because most ALU operations change S, Z, AC, and P. GATE questions specifically test this flag behavior.
Given:
Initial Accumulator A = 96H = 1001 0110b
Initial Carry CY = 1
Instructions: RAL executed twice
Why this formula applies:
RAL: 9-bit rotation. New A = (A << 1) | old_CY. New CY = old b7.
Formula:
New b7..b1 = old b6..b0
New b0 = old CY
New CY = old b7
First RAL:
A = 1001 0110b, CY = 1
b7 = 1 → new CY = 1
Shift left: 001 0110 _ → fill b0 with old CY = 1
New A = 0010 1101b = 2DH
New CY = 1
Second RAL:
A = 0010 1101b = 2DH, CY = 1
b7 = 0 → new CY = 0
Shift left: 010 1101 _ → fill b0 with old CY = 1
New A = 0101 1011b = 5BH
New CY = 0
Final Answer:
After two RAL operations: A = 5BH, CY = 0.
S, Z, AC, P flags remain unchanged throughout.Exam Tip: RLC and RRC are 8-bit rings that copy the exiting bit to CY. RAL and RAR are 9-bit rings where CY is part of the ring. Only CY is affected by rotate instructions; S, Z, AC, P are never changed. This distinction eliminates half the wrong options in rotate-related GATE questions.
- RLC: 8-bit left rotation. b7 → b0 and b7 → CY. CY gets a copy of b7 but is not in the ring.
- RRC: 8-bit right rotation. b0 → b7 and b0 → CY. CY gets a copy of b0 but is not in the ring.
- RAL: 9-bit left rotation through CY. b7 → CY, old CY → b0. CY is part of the rotation ring.
- RAR: 9-bit right rotation through CY. b0 → CY, old CY → b7. CY is part of the rotation ring.
- All rotate instructions: 1 byte, 4 T-states, only CY flag is affected, S/Z/AC/P remain unchanged.
- Multi-byte shift: use RAL/RAR in sequence across register pairs, carry acts as the inter-byte link bit.
Quick Revision
- Four rotate instructions: RLC, RRC (8-bit ring), RAL, RAR (9-bit ring with CY).
- RLC equivalent: multiply by 2 (b7 must be 0 for exact result); CY catches overflow bit.
- RRC equivalent: divide by 2 (b0 must be 0 for exact result); CY catches remainder bit.
- RAL and RAR use old CY as the incoming bit; essential for multi-byte shifts.
- Only CY flag changes after rotate; S, Z, AC, P are never touched.
- All four: 1 byte, 4 T-states.
- Exam trap: Do not confuse RLC (CY gets copy of b7, not part of ring) with RAL (CY is inside the 9-bit ring and also gets updated).
Rotate Instructions Quiz
Test your understanding of RLC, RRC, RAL, and RAR bit rotation mechanics in the 8085.
Q1.If the accumulator contains B6H (1011 0110) and the RLC instruction is executed, what is the new value in the accumulator and the Carry flag?
Related Articles
Instruction Set Groups
Data transfer, Arithmetic, Logical, Branching.
8 min read
Addressing Modes
Immediate, Register, Direct, Indirect, Implied.
11 min read
SIMD Instructions
MMX, SSE, AVX overview.
12 min read
String Instructions
MOVS, CMPS, SCAS, LODS, STOS with REP.
7 min read
Instruction Queue
Pipelining fetch and execute benefits.
7 min read