You are on page 1of 10

10/12/2023

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 1

QUIZ #4

Write the equivalent for each of the following


instructions using your knowledge up to now.

A) PUSH AX B) POP DX

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 2

1
10/12/2023

Instructions
for
INTEL 8086
Microprocessor
(2)
logical Group
Shift & Rotate Group
Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 3

Dr. Mazin H. Aziz 2nd-Class Microprocessor I

10/12/2023

2
10/12/2023

The reference for this


lecture is
chapter-5 /P.188-201
&
chapter-5 /P.206-210
of the textbook
Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 5

Dr. Mazin H. Aziz 2nd-Class Microprocessor I


10/12/2023

3
10/12/2023

Instructions Groups

(3)
(1) SHIFT
DATA &
Transfer ROTATION
Group (7)
Group
CONTROL
Group
(2) (4)
LOGICAL BRANCH
Group Group
(5) (6)
ARITHMATIC CHARRECTER
Group STRING
7
Group Dr. Mazin H. Aziz 2nd-Class
10/12/2023
Microprocessor I

LOGICAL GROUP

AND NEG
NOT
OR INC
TEST
XOR DEC
CMP

10/12/2023 8
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

4
10/12/2023

INST. OPERANDS FUNCTION


Very Useful in Bit Masking

Example:
AND REG, memory MOV AL, 'a' ; AL = 01100001b
AND AL, 11011111b ; AL = 01000001b
; ('A')
memory, REG
Example:
OR REG, REG MOV AL, 'A’
OR
; AL = 01000001b
AL, 00100000b ; AL = 01100001b
memory, immediate ;('a')

Example:
REG, immediate
XOR MOV AL, 'A’ ; AL = 01000001b

XOR AL, AL ; AL = ?
S, Z & P FLAGS are Affected
Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 9

INST. OPERANDS FUNCTION

source operand AND destination operand


REG, memory

memory, REG
Example:
TEST REG, REG MOV AL, 'a' ; AL = 01100001b
MOV BH, ‘A' ; BH = 01000001b
memory, immediate TEST AL,BH ; AL & BH
; dose not change
REG, immediate ; ONLY AFFECTS FLAGS

S, Z & P FLAGS are Affected


Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 10

10

5
10/12/2023

INST. OPERANDS FUNCTION

Example:
MOV AL, 77h ; AL = 77h
REG NOT AL ; AL =88h
NOT MOV AL, 7h ; AL = 7h

memory NOT AL ; AL = ?

NONE of the FLAGS are Affected

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 11

11

INST. OPERANDS FUNCTION


Example:
MOV AL, 5 ; AL = 05h
NEG NEG AL ; AL = 0FBh (-5)
NEG AL ; AL = 05h (5)

REG Example:
INC MOV AL, FF ; AL = FFh
INC AL ; AL = ?
memory Example:
DEC MOV AL, 0 ; AL =0
DEC AL ; AL = ?
S, Z, O, A & P FLAGS are Affected
10/12/2023 12
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

12

6
10/12/2023

INST. OPERANDS FUNCTION


Algorithm:
Compare.
operand1 - operand2
REG, memory Result is not stored anywhere,
memory, REG
flags are set or reset (OF, SF, ZF,
CMP REG, REG
memory, immediate AF, PF, CF) according to result.
REG, immediate Example:
MOV AL, 5
MOV BL, 5
CMP AL, BL
; AL = 5, ZF = 1 (so equal!)

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 13

13

HOMEWORK #3
Using Instructions from the Logical Group do the following:

1) Write a program to reset all the bits of all the general-purpose


registers.

2) Write a Program to reset the bit d5 only, of the register SI.

3) Write a Program to reset the word stored at the address 32350h.

4) Write a Program to find the 2’s complement of the 16-bit number


stored in DX.

5) Write the shortest Program that finds the 2’s complement of the
16-bit number stored at 45321h.
10/12/2023 14
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

14

7
10/12/2023

SHIFTING & ROTATION

SHL RCR
ROL
SHR RCL
ROR
SAR

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 15

15

INST. OPERANDS FUNCTION


SHL/
SAL
CY REG or MEM 0

SHR 0 REG or MEM CY

ROL REG, 1 CY REG or MEM


memory, 1
REG, CL
ROR memory, CL REG or MEM CY

RCR REG or MEM CY

RCL CY REG or MEM


10/12/2023 16
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

16

8
10/12/2023

INST. OPERANDS FUNCTION

REG, 1
memory, 1
SAR REG, CL
REG or MEM CY

memory, CL

S, Z, O, C & P FLAGS are Affected


10/12/2023 17
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

17

HOMEWORK #3
Using Instructions from the Shift and Rotate Group do the following:
6) Write a program to exchange CL with CH.
7) Write a program to exchange the contents of the byte located at
the address (32001h) by that located at the address (32002h).
8) Write a program to divide the stored number in CX by 8 and store
the result in BX.
9) Write a program to multiply the stored byte at the address (70h)
by 16 and store the result (word) at the address (80h).
10) Write a program that exchanges (swaps) the least significant
nibble of DL with the most significant nibble of it.
Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 18

18

9
10/12/2023

THE END
Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/12/2023 19

19

10

You might also like