Chapter 7 Logic, Shift and Rotate Instructions (Part 1) - Daffodil ...
-
Upload
khangminh22 -
Category
Documents
-
view
4 -
download
0
Transcript of Chapter 7 Logic, Shift and Rotate Instructions (Part 1) - Daffodil ...
Chapter 7Logic, Shift and Rotate Instructions (Part 1)PREPARED BY
AHMED AL MAROUF
LECTURER, CSE, DAFFODIL INTERNATIONAL UNIVERSITY (DIU)
1
OutlinePart 1 contains only
Logic Instructions AND
OR
XOR
NOT
Applications of Logic Instructions CLEAR
SET
COMPLEMENT /CHANGE
2
Logic Instructions Logic instructions has the ability to manipulate individual bits.
The binary values of 0 and 1 are treated as False and True, respectively.
Logic Operations for 8086 assembly language are: AND
OR
XOR and
NOT
When logic operation is applied to 8-bit or 16-bit operands, the result is obtained by applying the logic operation at each bit position.
3
Truth Table of Logic OperationsOperands Logic Operations
Operand 1 Operand 2 AND OR XOR NOT Op1
0 0 0 0 0 1
0 1 0 1 1 1
1 0 0 1 1 0
1 1 1 1 0 0
4
Applications of Logic Instructions
1. Clearing bits
2. Setting bits
3. Complementing bits
These operations can be performed on individual bits.
8
Clearing bits Clearing means changing the bits as follow:
0 to 0
1 to 0
Therefore,
Masks for
Changed – 0
Unchanged - 1
9
Operands Logic Operations
Original Bit Mask AND
0 0 0
0 1 0
1 0 0
1 1 1
Setting bits Setting means changing the bits as follow:
0 to 1
1 to 1
Therefore,
Masks for
Changed – 1
Unchanged - 0
10
Operands Logic Operations
Original Bit Mask OR
0 0 0
0 1 1
1 0 1
1 1 1
Complementing bits Setting means changing the bits as follow:
0 to 1
1 to 0
Therefore,
Masks for
Changed – 1
Unchanged - 0
11
Operands Logic Operations
Original Bit Mask XOR
0 0 0
0 1 1
1 0 1
1 1 0