PROGRAMMING NUMERIC APPLICATIONS

FABS

FABS (absolute value) changes the top stack element to its absolute value by making its sign positive.

FCHS

FCHS (change sign) complements (reverses) the sign of the top stack element.

Comparison Instructions

Each of these instructions (table 2-5) analyzes the top stack element, often in relationship to another operand, and reports the result in the status word condition code. The basic operations are compare, test (compare with zero), and examine (report tag, sign, and normalization). Special forms of the compare operation are provided to optimize algorithms by allowing direct comparisons with binary integers and real numbers in memory, as well as popping the stack after a comparison.

The FSTSW (store status word) instruction may be used following a comparison to transfer the condi- tion code to memory for inspection.

Note that instructions other than those in the comparison group may update the condition code. To ensure that the status word is not altered inadvertently, store it immediately following a comparison operation.

FCOM / /source

FCOM (compare real) compares the stack top to the source operand. The source operand may be a register on the stack, or a short or long real memory operand. If an operand is not coded, ST is compared to ST(1). Positive and negative forms of zero compare identically as if they were unsigned. Following the instruction, the condition codes reflect the order of the operands as shown in table 2-6.

 

 

Table 2-5. Comparison Instructions

 

FCOM

 

 

Compare real

 

FCOMP

 

 

Compare real and pop

 

FCOMPP

 

 

Compare real and pop twice

 

FICOM

 

 

Integer compare

 

FICOMP

 

 

Integer compare and pop

 

FTST

 

 

Test

 

FXAM

 

 

Examine

 

Table 2-6. Condition Code Interpretation after FCOM

 

Condition Code

 

 

 

 

 

 

Interpretation after FCOM

C3

C2

C1

CO

 

0

0

X

0

ST> source

0

0

X

1

ST < source

1

0

X

0

ST = source

1

1

X

1

ST is not comparable

2-10

Page 402
Image 402
Intel 80287, 80286 manual Programming Numeric Applications Fabs, Fcom / /source, Comparison Instructions