You are on page 1of 9

10/28/2022

(2)
logical Group
Shift & Rotate Group
Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/28/2022 1

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

10/28/2022

1
10/28/2022

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/28/2022 3

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


10/28/2022

2
10/28/2022

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

10/28/2022 6
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

3
10/28/2022

INST. OPERANDS FUNCTION

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/28/2022 7

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/28/2022 8

4
10/28/2022

INST. OPERANDS FUNCTION

Example:
MOV AL, 55h ; AL = 55h
REG NOT AL ; AL =0AAh
NOT MOV AL, 5h ; AL = 5h

memory NOT AL ; AL = ?

NONE of the FLAGS are Affected

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/28/2022 9

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/28/2022 10
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

10

5
10/28/2022

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/28/2022 11

11

Using Instructions from the Logical Group do the following:

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


registers.

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

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

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


stored in DX.

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

12

6
10/28/2022

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/28/2022 13

13

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/28/2022 14
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

14

7
10/28/2022

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/28/2022 15
Dr. Mazin H. Aziz 2nd-Class Microprocessor I

15

Using Instructions from the Shift and Rotate Group do the following:
1) Write a program to exchange CL with CH.
2) Write a program to exchange the contents of the byte located at
the address (32001h) by that located at the address (32002h).
3) Write a program to divide the stored number in CX by 8 and store
the result in BX.
4) Write a program to multiply the stored byte at the address (70h)
by 16 and store the result (word) at the address (80h).
5) 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/28/2022 16

16

8
10/28/2022

Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/28/2022 17

17

You might also like