SHL
By Vesper Vei
1 minute read
Table of Contents
SHL (shl)
Basic function
SHL (Shift Logical Left) shifts the destination operand left by n bits, filling the right side with 0s.
In mathematical terms, it is equivalent to: dest = dest * 2^n。
Instruction execution process
- Shift left the specified number of times
- Fill the right side with 0s
- Update flags such as CF, ZF, SF, and OF
- The last bit shifted out → CF
Instruction format
shl r/m32, imm8shl r/m64, imm8shl r/m32, clshl r/m64, clBehavioral characteristics
- Logical operation; does not consider the sign
- Performs fast multiplication on values
- Has a strong effect on flags, especially CF and OF
Common uses
- Quickly multiply by 2^n
- Address calculation (such as structure base address offsets)
- Bitmap construction
- In ROP/shellcode, construct large numbers