The SHL and SAL instructions
The logical (SHL) and arithmetic (SAL) shift left instructions.
The SHL instruction
| Instruction | Description |
|---|---|
| SHL reg/mem8, 1 | Multiply reg/mem8 by 2, once. |
| SHL reg/mem8, CL | Multiply reg/mem8 by 2, CL times. |
| SHL reg/mem16, 1 | Multiply reg/mem16 by 2, once. |
| SHL reg/mem16, CL | Multiply reg/mem16 by 2, CL times. |
The SAL instruction
| Instruction | Description |
|---|---|
| SAL reg/mem8, 1 | Multiply reg/mem8 by 2, once. |
| SAL reg/mem8, CL | Multiply reg/mem8 by 2, CL times. |
| SAL reg/mem16, 1 | Multiply reg/mem16 by 2, once. |
| SAL reg/mem16, CL | Multiply reg/mem16 by 2, CL times. |
The SAL and SHL instructions perform the same operation; they shift the bits in the destination operand left (towards the more significant bits). With each count of the shift, the most significant bit of the destination operand is shifted into the CF flag while the least significant bit is cleared.
Usage example of SHL
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the main procedure mov al, 00001111b ; Copy the value 00001111 into the al register mov cl, 2 ; Copy the value 2 into the cl register shl al, cl ; Perform a logical shift of al left by 2, 00111100 mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Usage example of SAL
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the main procedure mov al, 00001111b ; Copy the value 00001111 into the al register mov cl, 2 ; Copy the value 2 into the cl register sal al, cl ; Perform an arithmetic shift of al left by 2, 00111100 mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
CF
YesPF
YesAF
?ZF
YesSF
YesTF
NoIF
NoDF
NoOF
?