SAR SHIFT ARITHMETIC SAR

RIGHT

Operation:

Flags Affected:

(temp) +--COUNT

CF, OF, PF, SF, ZF.

do while (temp) "* 0

AF undefined

(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-

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.

2-145

Page 180
Image 180
Intel 210200-002 manual SAR Shift Arithmetic SAR Right, Cf, Of, Pf, Sf, Zf