SAR
Usage: SAR dest,count Modifies flags: CF OF PF SF ZF (AF undefined)
Shifts the 'dest' right by 'count' bits with the current sign bit replicated in the leftmost bit. The Carry Flag contains the last bit shifted out.
Bitwise Arithmetic Shifts
SAL r/m8,1 ; D0 /4 [8086]
SAL r/m8,CL ; D2 /4 [8086]
SAL r/m8,imm8 ; C0 /4 ib [186]
SAL r/m16,1 ; o16 D1 /4 [8086]
SAL r/m16,CL ; o16 D3 /4 [8086]
SAL r/m16,imm8 ; o16 C1 /4 ib [186]
SAL r/m32,1 ; o32 D1 /4 [386]
SAL r/m32,CL ; o32 D3 /4 [386]
SAL r/m32,imm8 ; o32 C1 /4 ib [386]
SAR r/m8,1 ; D0 /7 [8086]
SAR r/m8,CL ; D2 /7 [8086]
SAR r/m8,imm8 ; C0 /7 ib [186]
SAR r/m16,1 ; o16 D1 /7 [8086]
SAR r/m16,CL ; o16 D3 /7 [8086]
SAR r/m16,imm8 ; o16 C1 /7 ib [186]
SAR r/m32,1 ; o32 D1 /7 [386]
SAR r/m32,CL ; o32 D3 /7 [386]
SAR r/m32,imm8 ; o32 C1 /7 ib [386]
SAL and SAR perform an arithmetic shift operation on the given source/destination (first) operand. The vacated bits are filled with zero for SAL, and with copies of the original high bit of the source operand for SAR.
SAL is a synonym for SHL (see SHL). RosAsm will assemble either one to the same code.
The number of bits to shift by is given by the second operand. Only the bottom five bits of the shift count are considered by processors above the 8086.
Example:
shl eax 2 | mov ebx eax | sar ebx 2
add eax ebx ; (eax*4)+(eax*16) = eax * 20