From: http://romway.blog.163.com/blog/static/63898227200802945318599/
1) arithmetic shift when the multiplier or divisor is 2n, the arithmetic shift is used to quickly perform multiplication or Division operations on integers. Shift n places to the left is equivalent to multiply by 2n. The execution method is to move each bit of the original number to N places on the left, and discard n places on the left, fill 0 in all the positions of the Low-position void on the right.
2) The logic shift logic shifts n places to the left. This is to move each bit of the original number to N places on the left. Do not discard the high positions on the left, fill "0" in the left position of the low position ". The logical right shift N-bit execution method is to move each digit in the original number N-places to the right, do not discard the low position removed from the right, all fill 0 in the left high empty position.
Logical shift: Ignore Positive and Negative Numbers
Arithmetic shift: Consider plus or minus signs.
E g: 1000000000000000 (two places to the right) 0000000000000000 (two places to the left)
Logical shift: 0010000000000000 0000000000000000
Arithmetic shift: 1110000000000000 1000000000000000
Note: When the right shift is performed, if the first part is 1, fill 1. Otherwise, fill 0. When the logic is shifted to the left, add 0.
During logical shift, do not reserve the plus or minus signs (the first one) and add 0 in a unified manner.
Logical shift (whether left shift or right shift) is done by filling 0 at the vacancy
Example: mov ax, 1100_0111_0110_1000b
MoV Cl, 3
SHL ax, Cl; Result AX = 0011_1011_0100_0000
MoV ax, 1100_0111_0110_1000b
MoV Cl, 3
SHR ax, Cl; Result AX = 000100001000_1110_1101
The arithmetic shift must ensure that the symbol bit is not changed (the Left shift of the arithmetic is 0, and the right shift of the arithmetic is regarded as the symbol bit)
Example: mov ax, 1100_0111_0110_1000b
MoV Cl, 3
Sal ax, Cl; Result AX = 0011_1011_0100_0000
MoV ax, 1100_0111_0110_1000b
MoV Cl, 3
SAR ax, Cl; Result AX = 1111_1000_1110_1101
MoV ax, 0100_0111_0110_1000b
MoV Cl, 3
SAR ax, Cl; Result AX = pai_1000_1110_1101