(Redirected from X86-assembly/Instructions/sal)Jump to navigation Jump to search
|You are here:|
- The shl or sal instruction is used to shift the bits of the operand destination to the left, by the number of bits specified in the count operand.
- Bits shifted beyond the destination are first shifted into the CF flag.
- Zeros fill vacated positions during the shift operation.
- Equivalent to multiplying by 2n
This is the equivalent to this function in python:
>>> def shl(dest, count): ... return hex(dest << count) ... >>> shl(0xA, 2) '0x28'
shl destination, count
mov eax, 0xA ; set EAX to 0xA (1010 in binary) shl eax, 2 ; shifts 2 bits left in EAX, now equal to 0x28 (101000 in binary)
shl eax, 1 ;Equivalent to EAX*(2^1) or EAX*2 shl eax, 2 ;Equivalent to EAX*(2^2) or EAX*4 shl eax, 3 ;Equivalent to EAX*(2^3) or EAX*8 shl eax, 4 ;Equivalent to EAX*(2^4) or EAX*16 shl eax, 5 ;Equivlaent to EAX*(2^5) or EAX*32 shl eax, 6 ;Equivalent to EAX*(2^6) or EAX*64 shl eax, 7 ;Equivalent to EAX*(2^7) or EAX*128 shl eax, 8 ;Equivalent to EAX*(2^8) or EAX*256