IA-32 Assembly Language Reference Manual

Rotate Instructions

Rotate With Carry Left (rcl)

rcl{bwl}		imm8, r/m[8|16|32]
rcl{bwl}		%cl, r/m[8|16|32]
Operation

r/m high-order bit -> CF

CF -> r/m low-order bit

r/m -> ShiftLeft

Description

The left rotate instruction shifts all bits in the register or memory operand specified. The carry flag (CF) is included in the rotation. The most significant bit is rotated to the carry flag, the carry flag is rotated to the least significant bit position, all other bits are shifted to the left. The result includes the original value of the carry flag.

The first operand value indicates how many times the rotate takes place. The value is either the contents of the CL register or an immediate number. For a single rotate, where the first operand is one, the overflow flag (OF) is defined. For all other cases, OF is undefined. After the shift, the carry flag bit is XORed with the most significant result bit.

Example
rclb $1, 1(%esi)
 rclb $253, 1(%esi)
 rclb %cl, 1(%esi)
 rcll $1, 4(%edi)
 rcll $253, 4(%edi)
 rcll %cl, 4(%edi)

Rotate With Carry Right (rcr)

rcr{bwl}		imm8, r/m[8|16|32]
rcr{bwl}		%cl, r/m[8|16|32]
Operation

r/m high-order bit -> CF

CF -> r/m low-order bit

r/m -> ShiftRight

Description

The right rotate instruction shifts all bits in the register or memory operand specified. The carry flag (CF) is included in the rotation. The least significant bit is rotated to the carry flag, the carry flag is rotated to the most significant bit position, all other bits are shifted to the right. The result includes the original value of the carry flag.

The first operand value indicates how many times the rotate takes place. The value is either the contents of the CL register or an immediate number. For a single rotate, where the first operand is one, the overflow flag (OF) is defined. For all other cases, OF is undefined. After the shift, the carry flag bit is XORed with the two most significant result bits.

Example
rcrb $1, 1(%esi)
 rcrb $253, 1(%esi)
 rcrb %cl, 1(%esi)
 rcrl $1, 4(%edi)
 rcrl $253, 4(%edi)
 rcrl %cl, 4(%edi)

Rotate Left (rol)

rol{bwl}		imm8, r/m[8|16|32]
rol{bwl}		%cl, r/m[8|16|32]
Operation

r/m high-order bit -> CF

CF -> r/m low-order bit

r/m -> ShiftLeft

Description

The left rotate instruction shifts all bits in the register or memory operand specified. The most significant bit is rotated to the carry flag, the carry flag is rotated to the least significant bit position, all other bits are shifted to the left. The result does not include the original value of the carry flag.

The first operand value indicates how many times the rotate takes place. The value is either the contents of the CL register or an immediate number. For a single rotate, where the first operand is one, the overflow flag (OF) is defined. For all other cases, OF is undefined. After the shift, the carry flag bit is XORed with the most significant result bit.

Example
rclb $1, 1(%esi)
 rclb $253, 1(%esi)
 rclb %cl, 1(%esi)
 rcll $1, 4(%edi)
 rcll $253, 4(%edi)
 rcll %cl, 4(%edi)

Rotate Right (ror)

ror{bwl}		imm8, r/m[8|16|32]
ror{bwl}		%cl, r/m[8|16|32]
Operation

r/m high-order bit -> CF

CF -> r/m low-order bit

r/m -> ShiftRight

Description

The right rotate instruction shifts all bits in the register or memory operand specified. The least significant bit is rotated to the carry flag, the carry flag is rotated to the most significant bit position, all other bits are shifted to the right. The result does not include the original value of the carry flag. The first operand value indicates how many times the rotate takes place. The value is either the contents of the CL register or an immediate number. For a single rotate, where the first operand is one, the overflow flag (OF) is defined. For all other cases, OF is undefined. After the shift, the carry flag bit is XORed with the two most significant result bits.

Example
rcrb $1, 1(%esi)
 rcrb $253, 1(%esi)
 rcrb %cl, 1(%esi)
 rcrl $1, 4(%edi)
 rcrl $253, 4(%edi)
 rcrl %cl, 4(%edi)