# LOGICAL INSTRUCTIONS

- Manipulates individual bits of data logically.
- 0 is to false and 1 is to true.
- SF, ZF and PF depend on the result.
- CF and OF
are equal to 0.
NOT Truth Table Values
- AF is
undefined.
Operan
Result
d
I.
NOT
1
0
 The
NOT instruction implements the bitwise
0
1
NOT operation.
 NOT operation reverses the bits in an operand.
Syntax:

NOT Operand

Given:
DL[25H]
RESULT[DAH]
DL =
FLAGS: SF = 1; ZF =
= 0;
II.

AND Truth Table Values
A
B
Result
1
1
1
0
0
1
0
1
0
0
1
1
0
1
0
1
0
0
0
0

Example:
NOT DL
DH = 2525H;
0
1
0
1
1
0
1
0
DAH;
0; PF = 1; AF = undefined; CF = 0; OF

AND
 The AND instruction implements the bitwise AND operation.
 Performs Logical Multiplication.
 Logically AND the source and the destination operands and stores the result in
the destination operand.
 If the matching bits from both the operands are 1 return 1, otherwise it returns 0.
Syntax:

AND D, S

Example:
AND BL, DL
Given: BH = 1015H; DH = 2525H;

BL[15H]
0
0
0
1
0
DL[25H]
0
0
1
0
0
RESULT[05H]
0
0
0
0
0
BL = 05H;
FLAGS: SF = 0; ZF = 0; PF = 1; AF = undefined; CF = 0; OF = 0;
III.
OR

1
1
1

0
0
0

1
1
1

BL[15H] DL[25H] RESULT[35H] BL = FLAGS: SF = 0. FLAGS: SF = 0.  Logically XOR the source and the destination operands and stores the result in the destination operand. OF = 0. AF = undefined. ZF = = 0. XOR [D]. otherwise return 0. It is also called as Inclusive-OR  The OR instruction implements the bitwise OR operation. 1 0 1  If the matching bits from either or both operands are 1 0 1 1 0 0 0 return 1. DH = 2525H. AF = undefined. Syntax: 0 0 0 XOR Truth Table Values 1 A 0 B0 Result 1 0 11 00 0 1 1 0 11 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 35H. 0. OF XOR  It is also called as Exclusive-OR  The XOR instruction implements the bitwise XOR operation. V. [Data] Example: XOR BL.  Performs Logical Addition.  If and only if the bits from the operands are different return 1. DH = 2525H. PF = 0. CF = 0. DL Given: BH = 1015H. PF = 1. DL Given: BH = 1015H. XOR Truth Table Values  A B Result Logically OR the source and the destination operands and stores the result 1 1 1 in the destination operand. TEST 1 1 0 0 0 0 1 1 0 . IV. ZF = 0. otherwise it returns 0. [Data] Example: OR BL. CF = 0. BL[15H] 0 0 0 1 0 DL[25H] 0 0 1 0 0 RESULT[30H] 0 0 1 1 0 BL = 30H. Syntax: OR [D].

0 0 0 0 1 0 0 0 0 OTHERS 1. PF = 0. Syntax: NEG DL Given: DH = AAAAH. DH = AAAAH. 0 0 0 0 0 0 0 0 0 DL[AAH] 1 0 1 0 1 0 1 0 RESULT[36H][-170] 1 0 1 0 1 0 1 1 0 sign bit  . Syntax: TEST [D]. [Data] Example: TEST BL. ZF = 1. NEG (Negate)  It converts the specified operand to its 2's compliment equivalent and the result returned to the reversing the sign of an integer. VI. DL Given: BH = 1510H. CF = 0. OF = 0. Logically AND the source and the destination operands and discarded the result but the values of status flags are updated. BL[10H] 0 0 0 1 0 DL[AAH] 1 0 1 0 1 RESULT[00H] 0 0 0 0 0 BL = 10H FLAGS: SF = 0. AF = undefined.