Computer Architecture
Lecture 14by
Engineer A. Lecturer Aymen Hasan AlAwady
14/4/2014
University of  Kufa - Information Technology Research and Development Center
1
1
1. Review on Rotate Operations
Rotate
Rotate the contents of the accumulator one position to the leftor right.
1.RLC               Rotate the accumulator left.                        Bit 7 goes to bit 0 AND the Carry flag.
2.RAL               Rotate the accumulator left through the carry.                        Bit 7 goes to the carry and carry goes to bit 0.
3.RRC              Rotate the accumulator right.                       Bit 0 goes to bit 7 AND the Carry flag.
4.RAR              Rotate the accumulator right through the carry.                     Bit 0 goes to the carry and carry goes to bit 7.
2
2. Rotate instructions examples
MVI A,FAh             A = 1111 1010
RLC                          A= 1111 0101
 after RLC
3
1
1
1
1
1
0
1
0
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
1
1
1
1
0
1
0
1
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
0
Carry flag
1
Carry flag
2. Rotate instructions examples
MVI A,FAh             A = 1111 1010
RAL                          A= 1111  0100
 After RAL
4
1
1
1
1
1
0
1
0
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
1
1
1
1
0
1
0
0
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
0
Carry flag
1
Carry flag
3. Applications of RotateInstructions
The rotate operations are commonly used for arithmeticmultiply and divide operations and for serial data transfer.
1. Arithmetic multiply and divide
EX: If A = 0000 1000 = 08H
1. By rotating right, A will be (A) = 0000 0100 04H
This means that A is divided by 2.
2. By rotating left, A will be (A)= 0001 0000 10H
This means that A is multiplied by 2.  (10H = 16D).
Note: These procedure are invalid when logic 1 is rotatedleft from D7 to D0 or vice versa.
Ex: if A= 80H, when rotated left it becomes 01H.
5
3.1 Applications of RotateInstructions
2. Serial data transfer: the data can be transferred seriallythrough rotating the content of the accumulator left orright.
MVI A, 10000000B
RAR
When D7 is rotated into D6, the SOD (Serial Output Dataline) line is enabled and the content of carry are placed inD7.
Q: Mention the purpose of SID and SOD lines.Ans: SID (Serial input data line): It is an input line throughwhich the microprocessor accepts serial dataSOD (Serialoutput data line): It is an output line through which themicroprocessor sends output serial data.
6
3.2 Applications of RotateInstructions
Q: A set of ten signed numbers stored in memory locations starting at20AAH. The numbers are expected to be positive . Write a prog. tocheck where it is positive or negative, reject the negative numbers andstore the positive numbers in 2000h.
MVI d,10
LXI H,20AAH
LXI B,2000h
NEXT: MOV A,M
RAL
JC REJECT
RAR
STAX b
inx b
inx h
Jz end; jump when the last iteration of d is equal to  zero to avoid error in the loop when d is
JNZ NEXT               further decremented.
REJECT: inx h
dcr d
JNZ NEXT
End: hlt
7
The data in 20AAH  28, D8, C2, 21, 24, 30, 2F, 19,F2,9F
Note: the D7 of the data is indicating the sign of thesigned numbers. So, we will check D7 by rotating it tocarry flag.
Program.
8
FACTORIAL OF 8 BIT NUMBER
4. Delay loops
Some times we need to know the number of iterations on theprogram. So, we have to reverse the way of calculating thedelay of the loop. If we knew that the frequency of the 8085is 2 MHz
Time Delay = No. of T-States / Frequency
The following is an example of a delay loop:
              MVI C, Num       7 T-States, we need to calculate Num
LOOP    DCR C                4 T-States
              JNZ    LOOP      10 T-States
If we knew that Time Delay 1.787 mSec
(Total DelayTDelay= Tstat Delay  X 0.5 μSec = 1.787 mSec)
Tstat Delay= 1.787 10-3 /0.5 10-6 =3574
9
4.1 Delay Loops (Contd.)
Using these formulas, we can calculate the time delay forthe previous example:
Tdelay= TO+ TL
TO= 7 T-States Delay of the MVI instruction
TL= (14 X Num) -3  = 3567 T-States
Tdelay= 14Num – 3+7= 3574 T-State
Y = 255 times or FFH
Total DelayTDelay= 3574  X 0.5 μSec = 1.787 mSec
µSec (Microsecond)= 10-6
mSec (Milisecond) = 10-3
10
JMP and Call!
Q: Explain the difference between a JMP instruction andCALL instruction.
Ans: A JMP instruction permanently changes the programcounter. A CALL instruction leaves information of PC on thestack so that the original program execution sequence canbe resumed.
11
12
End of lecture 14