0
1.9kviews
Explain the following Logical instructions with appropriate example: 1. SHL 2.ROL 3.RCR 4.SAR
1 Answer
0
62views

1.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

2.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 the 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

3. RCR: Rotate Carry Right

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

Syntax:     RCR Register, Bits to be shifted
Example:    RCR BH, 6

4. 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).

Syntax:     SAR Register, Bits to be shifted
Example:    SAR BX, 5
Please log in to add an answer.