Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3.

Similar presentations


Presentation on theme: "Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3."— Presentation transcript:

1 Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3

2 Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Can shift bytes or words in registers or memory left or right 1 bit. Can rotate or rotate through carry bytes or words in registers or memory left or right 1 bit. Can shift bytes or words in registers or memory left or right CL bits. Can rotate or rotate through carry bytes or words in registers or memory left or right CL bits.

3 Introduction to Computer Engineering by Richard E. Haskell Shift Left: SHL AL,1

4 Introduction to Computer Engineering by Richard E. Haskell SHL AL,1 100 D0 11000 = E0 E0

5 Introduction to Computer Engineering by Richard E. Haskell D0 E0 SHL AL,1 Tutor: /MH D0 E0 D0 E0 D0 E0 D0 E0 D0 E0 D0 E0 D0 E0 D0 E0

6 Introduction to Computer Engineering by Richard E. Haskell Shift Right: SHR 1 0 1 0 0 1 0 1 10 C Bit 7 6 5 4 3 2 1 0

7 Introduction to Computer Engineering by Richard E. Haskell Rotate through Carry Left: RCL 1 0 1 0 0 1 0 1 1 C Bit 7 6 5 4 3 2 1 0

8 Introduction to Computer Engineering by Richard E. Haskell Rotate through Carry Right: RCR 1 0 1 0 0 1 0 1 1 C Bit 7 6 5 4 3 2 1 0

9 Introduction to Computer Engineering by Richard E. Haskell Rotate Left and Rotate Right: ROL and ROR 1 0 1 0 0 1 0 1 1 C ROR 1 0 1 0 0 1 0 1 1 C ROL (a) (b)

10 Introduction to Computer Engineering by Richard E. Haskell Shift Arithmetic Right: SAR 1 0 1 0 0 1 0 1 1 C 1 1 0 1 0 0 1 0 1 1 1 1 0 1 0 0 1 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 1 0 0

11 Introduction to Computer Engineering by Richard E. Haskell Use CL to shift multiple bits 0000 B1 03 MOV CL,3 0002 D2 E0 SHL AL,CL AL = 5 = 00000101 00101000 shift left 3 bits = 28H = 40 = 5 x 2 3 = 5 x 8 Shifting left 1 bit multiplies by 2

12 Introduction to Computer Engineering by Richard E. Haskell Shifting right 1 bit divides by 2 0000 B1 03 MOV CL,3 0002 D2 E8 SHR AL,CL AL = 100 10 = 64H = 01100100 00001100 shift right 3 bits = 0CH = 12 = 100 / 2 3 = 100 / 8 8 x 12 = 96 Note: Remainder of 4 = 100 2 is shifted out and lost.


Download ppt "Introduction to Computer Engineering by Richard E. Haskell Shift and Rotate Instructions Module M16.2 Section 10.3."

Similar presentations


Ads by Google