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 |
|
2 |
ASL zp |
|
5 |
|
ASL zp,x |
|
6 |
|
ASL addr |
|
6 |
|
ASL addr,x |
|
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.