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|
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.
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.
8AH ---> 1000 1011 1100 0101 --->C5H (Last bit 1 is copied to Cy bit) (And initial Cy=1 bit at the MS place)
|2003||1F||RAR||Rotate Accumulator Right|
Note that Accumulator value is not halved in this case because Cy=1 before rotation.
The timing diagram against this instruction RAR execution is as follows −
Summary − So this instruction RAR requires 1-Byte, 1-Machine Cycle (Opcode Fetch) and 4 T-States for execution as shown in the timing diagram.