PROGRAMMING NUMERIC APPLICATIONS
FIST
destination
FIST (integer store) rounds the content of the stack top
to
an integer according to the RC field of the
control word and transfers the result to the destination. The destination may define a word or short
integer variable. Negative zero
is
stored in the same encoding
as
positive zero: 0000
...
00.
FISTP destination
FISTP
(integer and pop) operates like FIST and also pops the stack following the transfer. The desti-
nation may be any of the binary integer data types.
FBLD source
FBLD (packed decimal (BCD) load) converts the content of the source operand from packed decimal
to temporary real and loads (pushes) the result onto the stack. The sign of the source
is
preserved,
including the case where the value
is
negative zero. FBLD
is
an exact operation; the source
is
loaded
with
no
rounding error.
The packed decimal digits of the source are assumed
to
be in the range 0-9H. The instruction does not
check for invalid digits
(A-FH)
and the result of attempting to load an invalid encoding
is
undefined.
FBSTP destination
FBSTP (packed decimal (BCD) store and pop) converts the content of the stack top to a packed
decimal integer, stores the result at the destination in memory, and pops the stack. FBSTP produces a
rounded integer from a nonintegral value
by
adding 0.5 to the value and then chopping. Users
who
arc
concerned about rounding may precede
FBSTP with
FRNDINT.
Arithmetic Instructions
The 80287's arithmetic instruction set (table
2-2)
provides a wealth of variations
on
the basic add,
subtract, multiply, and divide
operations, and a number of other useful functions. These range from a
simple absolute value to a square root instruction that executes faster than ordinary division;
80287
programmers
no
longer need to spend valuable time eliminating square roots from algorithms because
they run too slowly.
Other arithmetic instructions perform exact modulo division, round real numbers
to integers, and scale values by powers of
two.
The 80287's basic arithmetic instructions (addition, subtraction, multiplication, and division) are
designed to encourage the development of very efficient algorithms. In particular, they allow the
programmer to minimize memory references and to make optimum use of the
NPX
register stack.
Table
2-3
summarizes the available operation/operand forms that are provided for basic arithmetic. In
addition
io
the
fuur
11u1111&1
opcrati0li3, t;;"G
"re\'er~ed"
i!!st!'~ctiQn5
!!l~k-~
~l1htr;:tction
and
division
"symmetrical" like addition and multiplication. The variety of instruction and operand forms give the
programmer unusual flexibility:
Operands may be located in registers or memory.
Results may be deposited in a choice of registers.
• Operands may be a variety of
NPX
data types: temporary real, long real, short real, short integer
or word integer, with automatic conversion
to
temporary real performed by the 80287.
2-4