Reviewing - University of Kufa

Download Report

Transcript Reviewing - University of Kufa

Computer Architecture
Lecture 14
by
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 left
or right.
1.
RLC
2.
RAL
3.
RRC
4.
RAR
Rotate the accumulator left.
Bit 7 goes to bit 0 AND the Carry flag.
Rotate the accumulator left through the carry.
Bit 7 goes to the carry and carry goes to bit 0.
Rotate the accumulator right.
Bit 0 goes to bit 7 AND the Carry flag.
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
RLC
A = 1111 1010
A= 1111 0101
Carry flag
0
1
1
1
1
1
0
1
0
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
after RLC
1
1
1
1
0
1
0
1
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Carry flag
1
3
2. Rotate instructions examples
MVI A,FAh
RAL
A = 1111 1010
A= 1111 0100
Carry flag
0
1
1
1
1
1
0
1
0
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
After RAL
1
1
1
1
0
1
0
0
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Carry flag
1
4
3. Applications of Rotate
Instructions
The rotate operations are commonly used for arithmetic
multiply 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 rotated
left from D7 to D0 or vice versa.
Ex: if A= 80H, when rotated left it becomes 01H.
5
3.1 Applications of Rotate
Instructions
2. Serial data transfer: the data can be transferred serially
through rotating the content of the accumulator left or
right.
MVI A, 10000000B
RAR
When D7 is rotated into D6, the SOD (Serial Output Data
line) line is enabled and the content of carry are placed in
D7.
Q: Mention the purpose of SID and SOD lines.
Ans: SID (Serial input data line): It is an input line through
which the microprocessor accepts serial data. SOD (Serial
output data line): It is an output line through which the
microprocessor sends output serial data.
6
3.2 Applications of Rotate
Instructions
Q: A set of ten signed numbers stored in memory locations starting at
20AAH. The numbers are expected to be positive . Write a prog. to
check where it is positive or negative, reject the negative numbers and
store the positive numbers in 2000h.
MVI d,10
LXI H,20AAH
The data in 20AAH 28, D8, C2, 21, 24, 30, 2F, 19,F2,9F
LXI B,2000h
NEXT: MOV A,M
RAL
JC REJECT
Note: the D7 of the data is indicating the sign of the
RAR
signed numbers. So, we will check D7 by rotating it to
STAX b
carry flag.
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
Program.
FACTORIAL OF 8 BIT NUMBER
8
4. Delay loops
Some times we need to know the number of iterations on the
program. So, we have to reverse the way of calculating the
delay of the loop. If we knew that the frequency of the 8085
is 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 for
the 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 and
CALL instruction.
Ans: A JMP instruction permanently changes the program
counter. A CALL instruction leaves information of PC on the
stack so that the original program execution sequence can
be resumed.
11
End of lecture 14
12