3-624
INSTRUCTION SET REFERENCE
SAL/SAR/SHL/SHRShift (Continued)
Intel Architecture Compatibility
The 8086 does not mask the shift count. However, all other Intel Architecture processors
(starting with the Intel 286 processor) do mask the shift count to five bits, resulting in a
maximum count of 31. This masking is done in all operating modes (including the virtual-8086
mode) to reduce the maximum execution time of the instructions.
Operation
tempCOUNT
<
(COUNT AND 1FH);
tempDEST
<
DEST;
WHILE (tempCOUNT
?
0)
DO
IF instruction is SAL or SHL
THEN
CF
<
MSB(DEST);
ELSE (* instruction is SAR or SHR *)
CF
<
LSB(DEST);
FI;
IF instruction is SAL or SHL
THEN
DEST
<
DEST
?
2;
ELSE
IF instruction is SAR
THEN
DEST
<
DEST
/
2 (*Signed divide, rounding toward negative infinity*);
ELSE (* instruction is SHR *)
DEST
<
DEST
/
2 ; (* Unsigned divide *);
FI;
FI;
tempCOUNT
<
tempCOUNT 1;
OD;
(* Determine overflow for the various instructions *)
IF COUNT = 1
THEN
IF instruction is SAL or SHL
THEN
OF
<
MSB(DEST) XOR
CF;
ELSE
IF instruction is SAR
THEN
OF
<
0;
ELSE (* instruction is SHR *)
OF
<
MSB(tempDEST);
FI;
FI;