0% found this document useful (0 votes)
113 views4 pages

Shift and Rotate Operations

The document describes 8 shift and rotate operations in x86 assembly: SHR shifts right by inserting zeros, SAR shifts right arithmetically, SHL shifts left by inserting zeros, SAL shifts left arithmetically, ROL rotates left with the leftmost bit moving to the rightmost position, ROR rotates right with the rightmost bit moving to the leftmost position, RCL rotates left with the carry flag determining the leftmost bit, and RCR rotates right with the carry flag determining the rightmost bit. Each operation is used to shift or rotate a specified number of bits in a register.

Uploaded by

Afrina Dipti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views4 pages

Shift and Rotate Operations

The document describes 8 shift and rotate operations in x86 assembly: SHR shifts right by inserting zeros, SAR shifts right arithmetically, SHL shifts left by inserting zeros, SAL shifts left arithmetically, ROL rotates left with the leftmost bit moving to the rightmost position, ROR rotates right with the rightmost bit moving to the leftmost position, RCL rotates left with the carry flag determining the leftmost bit, and RCR rotates right with the carry flag determining the rightmost bit. Each operation is used to shift or rotate a specified number of bits in a register.

Uploaded by

Afrina Dipti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Shift and Rotate operations

1. SHR : Shift Right


2. SAR : Shift Arithmetic Right
3. SHL : Shift Left
4. SAL : Shift Arithmetic Left
5. ROL : Rotate Left
6. ROR : Rotate Right
7. RCL : Rotate Carry Left
8. RCR : Rotate Carry Right

1) SHR: Shift Right

The SHR instruction is an abbreviation for ‘Shift Right’. This instruction simply shifts the mentioned bits
in the register to the right side one by one by inserting the same number (bits that are being shifted) of
zeroes from the left end. The rightmost bit that is being shifted is stored in the Carry Flag (CF).

Syntax: SHR Register, Bits to be shifted


Example: SHR AX, 2

2) SAR: Shift Arithmetic Right

The SAR instruction stands for ‘Shift Arithmetic Right’. This instruction shifts the mentioned bits in the
register to the right side one by one, but instead of inserting the zeroes from the left end, the MSB is
restored. The rightmost bit that is being shifted is stored in the Carry Flag (CF).

1
Syntax: SAR Register, Bits to be shifted
Example: SAR BX, 5

3) SHL: Shift Left

The SHL instruction is an abbreviation for ‘Shift Left’. This instruction simply shifts the mentioned bits
in the register to the left side one by one by inserting the same number (bits that are being shifted) of
zeroes from the right end. The leftmost bit that is being shifted is stored in the Carry Flag (CF).

Syntax: SHL Register, Bits to be shifted


Example: SHL AX, 2

4) SAL: Shift Arithmetic Left

The SAL instruction is an abbreviation for ‘Shift Arithmetic Left’. This instruction is the same as SHL.

Syntax: SAL Register, Bits to be shifted


Example: SAL CL, 2

2
5) ROL: Rotate Left

The ROL instruction is an abbreviation for ‘Rotate Left’. This instruction rotates the mentioned bits in the
register to the left side one by one such that leftmost bit that is being rotated is again stored as the rightmost
bit in the register, and it is also stored in the Carry Flag (CF).

Syntax: ROL Register, Bits to be shifted


Example: ROL AH, 4

6) ROR: Rotate Right

The ROR instruction stands for ‘Rotate Right’. This instruction rotates the mentioned bits in the register
to the right side one by one such that rightmost bit that is being rotated is again stored as the MSB in the
register, and it is also stored in the Carry Flag (CF).

Syntax: ROR Register, Bits to be shifted


Example: ROR AH, 4

3
7) RCL: Rotate Carry Left

This instruction rotates the mentioned bits in the register to the left side one by one such that leftmost bit
that is being rotated it is stored in the Carry Flag (CF), and the bit in the CF moved as the LSB in the
register.

Syntax: RCL Register, Bits to be shifted


Example: RCL CH, 1

8) RCR: Rotate Carry Right

This instruction rotates the mentioned bits in the register to the right side such that rightmost bit that is
being rotated it is stored in the Carry Flag (CF), and the bit in the CF moved as the MSB in the register.

Syntax: RCR Register, Bits to be shifted


Example: RCR BH, 6

You might also like