12
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

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

Embed Size (px)

DESCRIPTION

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

Citation preview

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

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

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

1. Review on Rotate OperationsRotateRotate the contents of the accumulator one position to the left or right.

• RLC Rotate the accumulator left. Bit 7 goes to bit 0 AND the Carry flag.

• RAL Rotate the accumulator left through the carry. Bit 7 goes to the carry and carry goes to bit 0.

• RRC Rotate the accumulator right. Bit 0 goes to bit 7 AND the Carry flag.

• RAR Rotate the accumulator right through the carry. Bit 0 goes to the carry and carry goes to bit 7.

2

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

2. Rotate instructions examplesMVI A,FAh A = 1111 1010RLC 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

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

2. Rotate instructions examplesMVI A,FAh A = 1111 1010RAL 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

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

3. Applications of Rotate InstructionsThe 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 = 08H1. By rotating right, A will be (A) = 0000 0100 = 04HThis means that A is divided by 2.2. By rotating left, A will be (A)= 0001 0000 = 10HThis 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

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

3.1 Applications of Rotate Instructions2. Serial data transfer: the data can be transferred serially through rotating the content of the accumulator left or right. MVI A, 10000000BRARWhen 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

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

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,10LXI H,20AAHLXI B,2000hNEXT: MOV A,MRALJC REJECTRARSTAX binx binx hJz end; jump when the last iteration of d is equal to zero to avoid error in the loop when d isJNZ NEXT further decremented.REJECT: inx hdcr dJNZ NEXTEnd: 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.

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

Program.

8

FACTORIAL OF 8 BIT NUMBER

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

4. Delay loopsSome 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 NumLOOP 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

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

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

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

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

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

12

End of lecture 14