ROL (ROtate Left)

[operand] = [operand] << 1 + C

ROL shifts all the bits of an operand one place to the left, and sets the least significant bit to the value of the Carry flag. The Carry flag is then set to the value of the most significant bit before it is shifted out.

ROL can operate on both memory locations and the accumulator register (A). When used on memory, the operand is the value stored at the specified memory address.

Addressing Modes

ROL supports the following addressing modes:

Mode

Syntax

Bytes

Cycles

Implied

ROL A

2A

2

Zero Page

ROL zp

26 nn

5

Zero Page + X

ROL zp,X

36 nn

6

Absolute

ROL addr

2E ll hh

6

Absolute + X

ROL addr,X

3E ll hh

7

Flags Affected

  • N (Negative) – Set if the result has the most significant bit set (i.e., is negative); otherwise, it is cleared.

  • Z (Zero) – Set if the result is zero; otherwise, it is cleared.

  • C (Carry) – Set to the value of the most significant bit before it is shifted out.

Examples

Rotate Accumulator Left

    LDA #85   ; load A with binary 01010101
    CLC       ; clear carry flag
    ROL A     ; A now contains binary 10101010, C is set to 0

Rotate Memory Left

    LDX #$10  ; load X with 16
    ROL $00,X ; Rotate the value at address $0010 left

See Also

  • ASL (Arithmetic Shift Left)

  • LSR (Logical Shift Right)

  • ROR (ROtate Right)

Comments