asl

Arithmetic shift left

Shifts the bits of the destination operand to the left.

Used in
XNZVC ●●●●●
  • ● set from the result

Forms

Operands

<ea>
An operand using one of the instruction’s supported addressing modes, such as d0, (a0)+ or 4(a1). It may name a register, memory or an immediate value. More
Dn
A data register, d0 to d7. More
#imm
An immediate shift count from 1 to 8, for example #3. More

Two forms: (1) as<d> Dx/Im, Dn shifts Dn by the count in Dx or immediate (1–8), any size. ASR fills the new high bits with copies of the sign bit, ASL fills the new low bits with zeros. Defaults to word. Note: ASL sets the overflow flag if the MSB changes during the shift, while ASR always clears it. (2) as<d>.w (An) shifts a memory word by 1; .w is the only size accepted and may be omitted.

* --- ASR: arithmetic shift right (preserves sign) ---
move.w #$FF00, d0
asr.w #4, d0 ; d0 = $FFF0 (sign bit preserved)

move.w #$0F00, d1
asr.w #4, d1 ; d1 = $00F0 (positive, fills with 0)

* --- ASL: arithmetic shift left ---
move.w #$0001, d2
asl.w #4, d2 ; d2 = $0010

; ASL sets V if the MSB changes during the shift
move.w #$7000, d3
asl.w #1, d3 ; V flag set! MSB changed from 0 to 1

* --- Memory form: shifts word at (a0) left by 1 ---
lea $1000, a0
move.w #$0001, (a0)
asl (a0) ; (a0) = $0002