Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Architecture Lecture 14 by Engineer A. Lecturer Aymen Hasan AlAwady 14/4/2014 University of Kufa - Information Technology Research and Development.

Similar presentations


Presentation on theme: "Computer Architecture Lecture 14 by Engineer A. Lecturer Aymen Hasan AlAwady 14/4/2014 University of Kufa - Information Technology Research and Development."— Presentation transcript:

1 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

2 1. Review on Rotate Operations Rotate Rotate the contents of the accumulator one position to the left or 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

3 2. Rotate instructions examples MVI A,FAh A = 1111 1010 RLC A= 1111 0101 after RLC 3 11111010 Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0 11110101 Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0 0 Carry flag 1

4 2. Rotate instructions examples MVI A,FAh A = 1111 1010 RAL A= 1111 0100 After RAL 4 11111010 Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0 11110100 Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0 0 Carry flag 1

5 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

6 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

7 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 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 the signed numbers. So, we will check D7 by rotating it to carry flag.

8 Program. 8 FACTORIAL OF 8 BIT NUMBER

9 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 Delay T Delay = Tstat Delay X 0.5 μSec = 1.787 mSec) Tstat Delay= 1.787 10 -3 /0.5 10 -6 =3574 9

10 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 Delay T Delay = 3574 X 0.5 μSec = 1.787 mSec µSec (Microsecond)= 10 -6 mSec (Milisecond) = 10 -3 10

11 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

12 12 End of lecture 14


Download ppt "Computer Architecture Lecture 14 by Engineer A. Lecturer Aymen Hasan AlAwady 14/4/2014 University of Kufa - Information Technology Research and Development."

Similar presentations


Ads by Google