Intel 210200-002 Baby Furniture User Manual


 
SAR
SHIFT
ARITHMETIC
RIGHT
SAR
Operation:
(temp) +-- COUNT
do while (temp)
"*
0
(CF) +-- low-order bit of (EA)
(EA)
+-- (EA) I
2,
where I is
equivalentto
signed division,
rounding down
(temp)
+--
(temp)-1
if COUNT = 1 then
if high-order bit
of
(EA)
"*
next-
to-high-order bit of (EA)
then
(OF)-1
else
(OF)
+-- 0
else (OF)
+-- 0
Description:
SAR
destination, count
SAR (Shift Arithmetic Right) shifts the bits in
the destination
op~rand
(byte
or
word) to the
right by the number
of
bits specified in the
count operand.
Bits equal to the original high-
order (sign) bit are shifted in on the left,
preserving the sign
of
the original value. Note
that SAR does not produce the same result as
the dividend
of
an
"equivalent"
IDIV instruc-
2-145
Flags Affected:
CF,
OF,
PF,
SF,
ZF.
AF
undefined
tion if the destination operand
is
negative and
I-bits are shifted out. For example, shifting
-5
right by one bit yields
-3,
while integer divi-
sion
-5
by 2 yields
-2.
The difference in the
instructions
is
that IDIV truncates all numbers
toward zero, while SAR truncates positive
numbers toward zero and negative numbers
toward negative infinity.