Slide 15.8: Implementing arithmetic expressions
Slide 16.2: SAL/SHL instruction
Home

Shift and Rotate Instructions


Shifting means to move bits right and left inside an operand. Rotating shifts each bit and copies the shifted-out bit into the lowest bit if rotate left or the highest bit if rotate right.


There are two basic ways to shift bits in a number:
 Command   Description 
SHL Shift left
SHR Shift right
SAL Shift arithmetic left
SAR Shift arithmetic right
ROL Rotate left
ROR Rotate right
RCL Rotate carry left
RCR Rotate carry right
SHLD Double-precision shift left
SHRD Double-precision shift right

 Bit Position  7 6 5 4 3 2 1 0
 Bit Value  v7 v6 v5 v4 v3 v2 v1 v0
  CF  
 


Note that shift arithmetic left is identical to shift left instruction.