ROL Instruction


The ROL (rotate left) instruction shifts each bit to the left. Also, the highest bit is copied both into the Carry flag and into the lowest bit. Bit rotation differs from bit shifting in that the former does not lose any bits. A bit that is rotated off one end of a number appears again at the other end.

 ROL — Rotate Left 
Usage: rol dest, count


Flag O D I S Z A P C
Result *             *

Rotates the bits in the destination to the left “count” times with all data pushed out the left side re-entering on the right. The Carry flag will contain the value of the last bit rotated out.

Clocks
Operands 286 386 486 Size Bytes
reg, 1 2 3 3 2
mem, 1 7 7 4 2-4
reg, CL 5+n 3 3 2
mem, CL 8+n 7 4 2-4
reg, immed8 5+n 3 2 3
mem, immed8 8+n 7 4 3-5

ROL can be used to exchange the upper (bits 4–7) and lower (bits 0–3) halves of a byte.

 Rotate Left 4 Bits   Rotate Right 4 Bits   Rotate Carry Left 4 Bits 
 .data
 value  BYTE  84h
 .code
 rol    value, 04
 movzx  eax, value 
 call   WriteHex
 .data
 value  BYTE  84h
 .code
 ror    value, 04
 movzx  eax, value
 call   WriteInt
 .data
 value  BYTE  84h
 .code
 stc
 rcl    value, 04
 movzx  eax, value 
 call   WriteHex
 Output  Output  Output
  EAX =

 

  EAX =

 

  EAX =