rol
Rotate left
Rotates the bits of the destination operand to the left.
XNZVC –●●0●
- ● set from the result
- 0 always 0
- – not changed
Forms
Operands
<ea>- An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With
opt p=68020, an allowedd(An,Xn)ord(PC,Xn)mode also permits the corresponding 68020 indexed and memory indirect forms. See 68020 addressing. More Dn- A data register,
d0tod7. More #imm- An immediate rotate count from
1to8, for example#3. More
Two forms: (1) ro<d> Dx/Im, Dn rotates Dn by the count in Dx or immediate (1–8), any size. Defaults to word. (2) ro<d>.w (An) rotates a memory word by 1; .w is the only size accepted and may be omitted.
* --- ROL: rotate left (bits wrap around) ---
move.w #$1234, d0
rol.w #8, d0 ; d0 = $3412
* --- ROR: rotate right ---
move.w #$1234, d1
ror.w #8, d1 ; d1 = $3412
* --- Single bit rotate ---
move.w #%1000000000000001, d2
rol.w #1, d2 ; d2 = %0000000000000011
* --- Memory form: rotates word at (a0) left by 1 ---
lea $2000, a0 ; free memory: the program itself is at $1000
move.w #%1000000000000001, (a0)
rol (a0) ; (a0) = %0000000000000011