Slide 16.1: Shift and rotate instructions Slide 16.3: SHR instruction Home |
SAL/SHL
Instruction
SAL
(shift arithmetic left) or SHL
(shift left) instruction performs a logical left shift on the destination operand, filling the lowest bit with 0. The highest bit is moved to the Carry
flag, and the bit that was in the Carry
flag is lost.
SAL/SHL — Shift Arithmetic Left / Shift Logical Left |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SAL/SHL
is for performing high-speed multiplication by powers of 2. Shifting any operand left by n
bits multiplies the operand by 2n
.
Shift Positive Left | Shift Negative Left | Shift Arithmetic Left |
.data value BYTE 4 .code shl value, 03 movsx eax, value call WriteInt |
.data value BYTE -16 .code shl value, 03 movsx eax, value call WriteInt |
.data value BYTE -17 .code sal value, 03 movsx eax, value call WriteInt |
Output | Output | Output |