Slide 16.2: SAL/SHL instruction Slide 16.4: SAR instruction Home |
SHR
Instruction
SHR
(shift right) instruction performs a logical right shift on the destination operand, replacing the highest bit with 0. The lowest bit is copied into the Carry
flag, and the bit that was in the Carry
flag is lost.
SHR — Shift Logical Right |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
n
bits divides the operand by 2n
.
SAR
instruction because it preserves the number's sign bit.
Shift Positive Right | Shift Negative Right | Shift Arithmetic Right |
.data value SDWORD 32 .code shr value, 03 mov eax, value call WriteInt |
.data value SDWORD -32 .code shr value, 03 mov eax, value call WriteInt |
.data value SDWORD -32 .code sar value, 03 mov eax, value call WriteInt |
Output | Output | Output |