# `rol`

[M68K Documentation](https://asm-editor.specy.app/documentation/m68k.md) › [Instructions](https://asm-editor.specy.app/documentation/m68k/instruction.md)

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/rol

**Rotate left**

Category: Shifts and rotates

Rotates the bits of the destination operand to the left.

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | set from the result |
| Z | set from the result |
| V | always 0 |
| C | set from the result |

## Forms

- `rol <ea>, Dn` · Sizes .b .w .l, .w by default
  - Source: Dn, #imm
- `rol <ea>` · Size .w
  - Operand: (An), (An)+, -(An), d(An), d(An,Xn), abs (memory alterable)

## Operands

- [`<ea>`](https://asm-editor.specy.app/documentation/m68k/addressing-mode.md): 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 allowed `d(An,Xn)` or `d(PC,Xn)` mode also permits the corresponding 68020 indexed and memory indirect forms. See [68020 addressing](https://asm-editor.specy.app/documentation/m68k/addressing-mode/68020.md).
- [`Dn`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): A data register, `d0` to `d7`.
- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): An immediate rotate count from `1` to `8`, for example `#3`.

## Description

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.

## Example

```m68k
* --- 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
```
