chapter 7 logic, shift and rotate instructions (part 1)
TRANSCRIPT
![Page 1: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/1.jpg)
Chapter 7Logic, Shift and Rotate Instructions (Part 1)PREPARED BY
AHMED AL MAROUF
LECTURER, CSE, DAFFODIL INTERNATIONAL UNIVERSITY (DIU)
1
![Page 2: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/2.jpg)
OutlinePart 1 contains only
Logic Instructions AND
OR
XOR
NOT
Applications of Logic Instructions CLEAR
SET
COMPLEMENT /CHANGE
2
![Page 3: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/3.jpg)
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
![Page 4: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/4.jpg)
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
![Page 5: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/5.jpg)
Examples
5
![Page 6: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/6.jpg)
Assembly Instructions
6
![Page 7: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/7.jpg)
Effect on Flags of Logic Instructions
7
![Page 8: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/8.jpg)
Applications of Logic Instructions
1. Clearing bits
2. Setting bits
3. Complementing bits
These operations can be performed on individual bits.
8
![Page 9: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/9.jpg)
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
![Page 10: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/10.jpg)
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
![Page 11: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/11.jpg)
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
![Page 12: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/12.jpg)
Use Logic Instructions as Mask
12
![Page 13: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/13.jpg)
Examples
13
![Page 14: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/14.jpg)
Examples
14
![Page 15: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/15.jpg)
Examples
15
![Page 16: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/16.jpg)
Other applications of Logic Instructions (1)
16
![Page 17: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/17.jpg)
Other applications of Logic Instructions (2)
17
![Page 18: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/18.jpg)
NOT Instruction
18
![Page 19: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/19.jpg)
Exercise (Self-Study)
21
![Page 20: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/20.jpg)
Exercise (Self-Study) Contd.
22
![Page 21: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)](https://reader033.vdocuments.net/reader033/viewer/2022051406/627d9241eafed87cb377bf93/html5/thumbnails/21.jpg)
Thank you.
23