chapter 7 logic, shift and rotate instructions (part 1)

21
Chapter 7 Logic, Shift and Rotate Instructions (Part 1) PREPARED BY AHMED AL MAROUF LECTURER, CSE, DAFFODIL INTERNATIONAL UNIVERSITY (DIU) 1

Upload: others

Post on 13-May-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Chapter 7Logic, Shift and Rotate Instructions (Part 1)PREPARED BY

AHMED AL MAROUF

LECTURER, CSE, DAFFODIL INTERNATIONAL UNIVERSITY (DIU)

1

Ahmed Al Marouf
Pencil
Page 2: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

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)

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)

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)

Examples

5

Page 6: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Assembly Instructions

6

Page 7: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Effect on Flags of Logic Instructions

7

Page 8: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

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)

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)

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)

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)

Use Logic Instructions as Mask

12

Page 13: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Examples

13

Page 14: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Examples

14

Page 15: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Examples

15

Page 16: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Other applications of Logic Instructions (1)

16

Page 17: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Other applications of Logic Instructions (2)

17

Page 18: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

NOT Instruction

18

Page 19: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Exercise (Self-Study)

21

Page 20: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Exercise (Self-Study) Contd.

22

Page 21: Chapter 7 Logic, Shift and Rotate Instructions (Part 1)

Thank you.

23