Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

Vol. 1 7-17
PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS
The SHLD instruction shifts the bits in the destination operand to the left and fills the
empty bit positions (in the destination operand) with bits shifted out of the source
operand. The destination and source operands must be the same length (either words
or doublewords). The shift count can range from 0 to 31 bits. The result of this shift
operation is stored in the destination operand, and the source operand is not modi-
fied. The CF flag is loaded with the last bit shifted out of the destination operand.
The SHRD instruction operates the same as the SHLD instruction except bits are
shifted to the right in the destination operand, with the empty bit positions filled with
bits shifted out of the source operand.
7.3.6.3 Rotate Instructions
The ROL (rotate left), ROR (rotate right), RCL (rotate through carry left) and RCR
(rotate through carry right) instructions rotate the bits in the destination operand out
of one end and back through the other end (see Figure 7-10). Unlike a shift, no bits
are lost during a rotation. The rotate count can range from 0 to 31.
Figure 7-9. SHLD and SHRD Instruction Operations
Destination (Memory or Register)CF
31
0
Source (Register)
31 0
Destination (Memory or Register)
CF
31
0
Source (Register)
31 0
SHRD Instruction
SHLD Instruction