# Instruction type RAR in 8085 Microprocessor

Microprocessor8085

In 8085 Instruction set, RAR stands for “Rotate Accumulator Right involving Cy flag in rotation”. It rotates the Accumulator contents to the right by 1-bit position. From the following Fig. we are getting the operation details.

From the Fig. we can see that, during right rotate the least significant bit is coming out and will be copied on the Cy flag bit and the previous Cy flag bit will be moved to the most significant bit position of the Accumulator. It is 1-Byte instruction. And it is 9-bit rotation of Accumulator and Cy contents. Only Cy flag is affected by this instruction execution.

Mnemonics, Operand Opcode(in HEX) Bytes
RAR 1F 1

This instruction can be used in multiple case studies.

• After rotate as the least significant bit of the Accumulator is getting copied to Accumulator, so we can check its value and can infer whether Accumulator was holding even or odd values.

• It can be used to perform division by 2. We know that Accumulator’s content will have n-bits right shift if we divide the Accumulator by 2n.

• To insert a new bit value at the most significant bit position, putting this bit value in the Cy flag and then executing this instruction.

With the help of following examples, we can understand the operation better.

## Example 1

Before After

(A)

8AH 45H

(Cy)

0 0

8AH --->    1000 1010
0100 0101 ---> 45H (Last bit 0 is copied to Cy bit)
(And initial Cy=0 bit at the MS place)


2004 1F RAR Rotate Accumulator Right

Note that Accumulator value is halved.

## Example 2

Before After

(A)

8AH C5H

(Cy)

1 0

8AH --->    1000 1011
1100 0101 --->C5H (Last bit 1 is copied to Cy bit)
(And initial Cy=1 bit at the MS place)