8085 instruction RLC,RRC,RAL,RAR

Thread Starter

Swag

Joined Apr 10, 2015
8
Q: After we use "RLC" instruction, can we restore the original accumulator content using "RRC" ?

or is it that we have to use "RAL" and restore the orginal content using "RAR" [since we are dealing with the Carry bit over here....which is not the case for above]
 

Thread Starter

Swag

Joined Apr 10, 2015
8
[1st case - understood this concept from book]
say CY=0 and u got binary number N1=1000 0001 . when u use RAL , the binary number changes to N2=0000 0010; The CY flag now will store the 1[bit D7 of N1]; The previous value of CY moves to D0th spot of new binary number N2.
Then when u execute RAR to N2, the CY flag gets modified with D0th bit of N2 ie 0; and the previous value of CY moves to D7th spot of new binary number ; thus the new number N3=1000 0001 which is equal to N1. Thus the original number gets restored.

[2nd case - dont really know whether its right/wrong?]
Initially CY=0 and number N1=1000 0001. But when ur using RLC to N1 u get N2 as 0000 0011; the D7th bit moves to D0th spot; and CY flag is 1[bit D7 of N1].
Now if we use RRC to N2; CY flag stays at 1 coz D0th bit of N2 =1; and the D0th bit of N2 moves to D7th spot of new binary number ; thus the new number N3=1000 0001 which is equal to N1.

Just wanted to know from u guys
(1)whether the 2nd case (dealing with RLC & RRC)- is right or wrong
(2) does CY flag gets modified when ur using RLC and RRC ?
(3)For the Question: using ROTATE can we restore the original number [can we use either 1st or 2nd case]

In the book it says for "checking sign with ROTATE" we need to use RAL-RAR coz they plays with CY flag ; eg:CY=1[negative no.]
But i cant figure out whats wrong in using RLC-RRC..do they really use CY flag or no?
 

LDC3

Joined Apr 27, 2013
924
All f
[1st case - understood this concept from book]
say CY=0 and u got binary number N1=1000 0001 . when u use RAL , the binary number changes to N2=0000 0010; The CY flag now will store the 1[bit D7 of N1]; The previous value of CY moves to D0th spot of new binary number N2.
Then when u execute RAR to N2, the CY flag gets modified with D0th bit of N2 ie 0; and the previous value of CY moves to D7th spot of new binary number ; thus the new number N3=1000 0001 which is equal to N1. Thus the original number gets restored.

[2nd case - dont really know whether its right/wrong?]
Initially CY=0 and number N1=1000 0001. But when ur using RLC to N1 u get N2 as 0000 0011; the D7th bit moves to D0th spot; and CY flag is 1[bit D7 of N1].
Now if we use RRC to N2; CY flag stays at 1 coz D0th bit of N2 =1; and the D0th bit of N2 moves to D7th spot of new binary number ; thus the new number N3=1000 0001 which is equal to N1.

Just wanted to know from u guys
(1)whether the 2nd case (dealing with RLC & RRC)- is right or wrong
(2) does CY flag gets modified when ur using RLC and RRC ?
(3)For the Question: using ROTATE can we restore the original number [can we use either 1st or 2nd case]

In the book it says for "checking sign with ROTATE" we need to use RAL-RAR coz they plays with CY flag ; eg:CY=1[negative no.]
But i cant figure out whats wrong in using RLC-RRC..do they really use CY flag or no?
All four instructions modify the carry flag according to this web site.
 

WBahn

Joined Mar 31, 2012
30,088
The original question only asks that the contents of the accumulator be restored and doesn't indicate whether the flags should be restored. This is an important distinction because sometime you don't care of the flags are corrupted and sometimes you do.
 

Thread Starter

Swag

Joined Apr 10, 2015
8
So for a binary number 1000 0001, what happens after we execute these 2 steps in succession--1st step:RLC, 2nd step: RRC.

I guess this complies with the original question...and just to let u know --u started asking this question:"Well, what do those instructions do compared to what you need to accomplish?" thats why i wrote the stuff related to CY flags
 
Top