Week10 Lecture Chapter5
Week10 Lecture Chapter5
COMPOSITION
Course Information
Logical Instructions
5.6 Characteristics and functions of instruction set
17
Logical Instructions
5.6 Characteristics and functions of instruction set
18
NOT OPR
(OPR) (OPR)
AND DST, SRC
(DST) (DST) (SRC)
OR DST, SRC
(DST) (DST) (SRC)
XOR DST, SRC
(DST) (DST) (SRC)
TEST OPR1, OPR2
(OPR1) (OPR2)
5.6 Characteristics and functions of instruction set
19
NOT OPR
(OPR) (OPR)
AND DST, SRC
(DST) (DST) (SRC)
OR DST, SRC
(DST) (DST) (SRC)
XOR DST, SRC
(DST) (DST) (SRC)
TEST OPR1, OPR2
(OPR1) (OPR2)
5.6 Characteristics and functions of instruction set
20
AND
Used in clearing certain bits (masking)
OR
Used in setting certain bits
XOR
Used in Inverting bits
Used to compare if two numbers are equal
5.6 Characteristics and functions of instruction set
21
AND
Used in clearing certain bits (masking)
OR
Used in setting certain bits
XOR
Used in Inverting bits
Used to compare if two numbers are equal
5.6 Characteristics and functions of instruction set
22
Examples
AND AL, 0FH
AND AX, BX
AND DX, [BX+SI] ;
OR AX, 00F0H
XOR AL, 0FH
XOR AX, AX
5.6 Characteristics and functions of instruction set
25
Examples
TEST AX, 8000H
TEST AL, 01H
NOT AL
NOT BX
NOT WORD PTR [1000H] ; 1000H 和
1001H
AND AL, 0FH
OR AL, 0FH
XOR AL, 0FH
TEST AL, 0FH
5.6 Characteristics and functions of instruction set
27
Examples
TEST AX, 8000H
TEST AL, 01H
NOT AL
NOT BX
NOT WORD PTR [1000H] ; 1000H 和
1001H
AND AL, 0FH
OR AL, 0FH
XOR AL, 0FH
TEST AL, 0FH
28
5.6 Characteristics and functions of instruction set
29
0 CF
SAR OPR, CNT
5.6 Characteristics and functions of instruction set
32
0 CF
SAR OPR, CNT
5.6 Characteristics and functions of instruction set
33
CF
CF
5.6 Characteristics and functions of instruction set
34
CF
CF
5.6 Characteristics and functions of instruction set
35
Assume (BX)=84F0H
(BX) is unsigned integer, (BX)/2 is
SHR BX, 1 ; (BX) = 4278H
(BX) is signed integer, (BX)/2 is
SAR BX, 1 ; (BX) = 0C278H
5.6 Characteristics and functions of instruction set
38
Assume (BX)=84F0H
(BX) is unsigned integer, (BX)/2 is
SHR BX, 1 ; (BX) = 4278H
(BX) is signed integer, (BX)/2 is
SAR BX, 1 ; (BX) = 0C278H
5.6 Characteristics and functions of instruction set
39
String Instruction
Source DS:SI, Destination ES:DI
You must ensure DS and ES are correct
You must ensure SI and DI are offsets into DS and ES
respectively
Direction Flag (0 = Up, 1 = Down)
CLD - Increment addresses (left to right)
STD - Decrement addresses (right to left)
43
44
5.6 Characteristics and functions of instruction set
45
String Instruction
Source DS:SI, Destination ES:DI
You must ensure DS and ES are correct
You must ensure SI and DI are offsets into DS and ES
respectively
Direction Flag (0 = Up, 1 = Down)
CLD - Increment addresses (left to right)
STD - Decrement addresses (right to left)
5.6 Characteristics and functions of instruction set
46
String Instruction
Source DS:SI, Destination ES:DI
You must ensure DS and ES are correct
You must ensure SI and DI are offsets into DS and ES
respectively
Direction Flag (0 = Up, 1 = Down)
CLD - Increment addresses (left to right)
STD - Decrement addresses (right to left)
5.6 Characteristics and functions of instruction set
47
5.6 Characteristics and functions of instruction set
48
5.6 Characteristics and functions of instruction set
49
5.6 Characteristics and functions of instruction set
50
5.6 Characteristics and functions of instruction set
51