The SHR instruction
Logical shift of a register or a memory location right.
The SHR instruction format
| Instruction | Description |
|---|---|
| SHR reg/mem8, 1 | Unsigned division of reg/mem8 by 2, once. |
| SHR reg/mem8, CL | Unsigned division of reg/mem8 by 2, CL times. |
| SHR reg/mem16, 1 | Unsigned division of reg/mem16 by 2, once. |
| SHR reg/mem16, CL | Unsigned division of reg/mem16 by 2, CL times. |
Shifts the bits in the first operand (the destination operand) right by the number of bits specified in the second operand. Bits shifted beyond the boundary of the destination operand are first shifted into the CF flag and then discarded. At the end of the shift operation the CF flag contains the last bit shifted out of the destination operand.
Usage example
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, 0011100b ; Copy the value 00111100 into the al register mov cl, 2 ; Copy the value 2 into the cl register shr al, cl ; Perform a logical shift of al right by 2, 00001111 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
?