ASL (short for "Arithmetic Shift Left") is the mnemonic for a machine language instruction which "shifts" the bits in either the accumulator or a specified address in RAM, one bit position towards the "left", or most significant, "end" of the byte. The bit previously held at the most significant position is "shifted out" of the byte, and into the carry flag, whereas the least significant bit, "left empty" by the shift operation, is "filled in" with a zero bit.
If the byte affected by the operation is taken as an unsigned 8-bit integer, the ASL operation effectively doubles the number, leaving a result of up to nine bits, the most significant of which is subsequently held in the carry flag. Doubling signed integers in this way requires programming efforts to keep the sign bit from mixing with the other bits, causing erratic sign-changes.
It is interesting to note that whereas ADC and SBC do not come in "flavours" which do not take an incoming carry or borrow, both ASL and its counterpart, LSR, are complemented by the instructions ROL and ROR, which "fills the vacant bit" with what was in the carry flag prior to the operation. Historically, ASL and LSR was implemented in the very first 65xx CPUs, whereas ROL and ROR was only added in CPUs manufactured after a certain date.
The following example shows how to left-shift, or double the value of, an integer spanning several bytes:
ASL Num Shift least significant byte ROL Num+1 Shift next-to-least-significant byte ROL Num+2 Shift the byte after that ... ROL Num+7 Shift most significant byte
Addressing modes[edit | edit source]
ASL supports the five addressing modes shown in the table at right. In the assembler formats listed, nn represents a single-byte (8-bit) figure, and nnnn is a two-byte (16-bit) address.
CPU flags[edit | edit source]
ASL affects 3 of the CPU's status flags: