SAL/SAR/SHL/SHR—Shift Instructions (Continued)
IF instruction is SAL or SHL
THEN
ELSE (* instruction is SAR or SHR *)
FI;
IF instruction is SAL or SHL
THEN
ELSE
FI;
temp temp - 1;
OD;
(* Determine overflow for the various instructions *)
IF COUNT = 1
THEN
IF instruction is SAL or SHL
FI;
ELSE
OF undefined;
FI;
Flags Affected
The CF flag contains the value of the last bit shifted out of the destination operand; it is
undefined for SHL and SHR instructions count is greater than or equal to the size of the
destination operand. The OF flag is affected only for 1-bit shifts (see "Description"
above); otherwise, it is undefined. The SF, ZF, and PF flags are set according to the
result. If the count is 0, the flags are not affected.
4:350
CF MSB(DEST);
CF LSB(DEST);
DEST DEST 2;
IF instruction is SAR
THEN
DEST DEST 2 (*Signed divide, rounding toward negative infinity*);
ELSE (* instruction is SHR *)
DEST DEST 2 ; (* Unsigned divide *);
FI;
THEN
OF MSB(DEST) XORCF;
ELSE
IF instruction is SAR
THEN
OF 0;
ELSE (* instruction is SHR *)
OF MSB(tempDEST);
FI;
Volume 4: Base IA-32 Instruction Reference