Shift and Rotate Instruction

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

SHIFT AND ROTATE

INSTRUCTION
PRESENTED BY:
DHANUSH S S (4GM20EC030)

HARSHA .M (4GM20EC036)

KUMAR VARUN (4GM20EC050)

L. SRUJAN (4GM20EC051)
Submitted to:
Ms Akashata Chavan
Asst. prof. Dept of ECE
WHAT IS SHIFT AND ROTATE OPERATION.?
 Shift and Rotate commands are used to convert from one form to
another form where some bits are shifted or rotated.
 Basic difference between “shift” and “rotate” is shift command
makes “fall of” bits at the end of register whereas rotate command
makes “Wrap around” at the end of the register.
 There are both arithmetic (SAL and SAR) and logical (SHL and
SHR) Shift instructions.
TYPES OF SHIFT AND ROTATE OPERATIONS :
 SHL - Shift Left.
 SHR - Shift Right.
 ROL – Rotate Left.
 ROR – Rotate Right.
 SAL – Shift Arithmetic Left.
 SAR – Shift Arithmetic Right.
 RCL - Rotate Carry Left.
 RCR - Rotate Carry Right.
1) LSHR : SHIFT RIGHT
 The LSHR instruction is an abbreviation for ‘Logical 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 : LSHR#(No of bits to be shifted),data
2)  LSHL : SHIFT LEFT
 The LSHL instruction is an abbreviation for ‘Logical 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: LSHL #(No of bits to be shifted),data
3) 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 #(No of bits to be shifted),data
4) SAL : SHIFT ARITHMETIC LEFT
 The SAL instruction is an abbreviation for ‘Shift
Arithmetic Left’.
 This instruction is the same as SHL.
 Syntax: SAL #(No of bits to be shifted),data
5) ROL : ROTATE LEFT
(WITHOUT CARRY)

 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 #(No of bits to be shifted),data
6) ROR : ROTATE RIGHT
(WITHOUT CARRY)

 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 right most 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#(No of bits to be shifted),data
7) RCL : ROTATE CARRY LEFT
(WITH CARRY)

 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 #(No of bits to be shifted),data
8)ROTATE CARRY RIGHT
(WITH CARRY)
• THE INSTRUCTION RCR (ROTATE THROUGH CARRYING RIGHT) WORKS JUST
LIKE RCL, EXCEPT THAT THE BITS ARE ROTATED TO THE LIGHT.

• SYNTAX: RCR #(NO OF BITS TO BE SHIFTED),DATA


THA NK Y OU

You might also like