ASL (Arithmetic Shift Left)

[operand] = [operand] << 1

or

[operand] = [operand] * 2

ASL shifts all the bits of an operand one place to the left.

The value of the shifted-out bit is captured in the Carry flag. If the shifted-out bit is 1, the Carry flag is set to 1, otherwise it is cleared to 0. Before the shift, the Carry flag has no effect on the operation.

For example, suppose we have the value 11001010 in the accumulator (A). When we execute the ASL instruction, the bits are shifted to the left and the value becomes 10010100. The most significant bit is now 1 because the least significant bit (0) was shifted out, and the Carry flag is set to 1 to reflect this.

ASL 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

ASL supports the following addressing modes:

Mode

Syntax

Bytes

Cycles

Implied

ASL

0A

2

ZeroPage

ASL zp

06 nn

5

ZeroPage+X

ASL zp,x

16 nn

6

Absolute

ASL addr

0E ll hh

6

Absolute+X

ASL addr,x

1E 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 bit that is shifted out of the result.

Examples

Shift Accumulator Left

    LDA #$83   ; load A with binary 10000011
    ASL A      ; A now contains binary 00000110, C is set to 1

Shift Memory Left

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

See Also

  • LSR (Logical Shift Right)

  • ROL (ROtate Left)

  • ROR (ROtate Right)

Comments