PROGRAMMING NUMERIC APPLICATIONS
Table 2-3. Basic
Arithmetic
Instructions
and Operands
Instruction Form
Mnemonic
Operand Forms
ASM286 Example
Form
destination, source
Classical stack
Fop
{ST(1),ST}
FADD
Register
Fop
ST(i),ST or ST,ST(i)
FSUB ST,ST(3)
Register pop FopP
ST(i),ST
FMULP ST(2),ST
Real
memory
Fop
{
ST,}
short-realflong-real
FDIV
AZIMUTH
Integer
memory
Flop
{
ST,}
word-integer fshort-integer
FIDIV
N_PULSES
NOTES:
Braces
({
})
surround implicit operands; these are not coded, and are shown here for information only.
op
=
ADD
destination
+-
destination + source
SUB destination
+-
destination - source
SUBR destination
+-
source - destination
MUL destination
+-
destination· source
DIV
destination
+-
destination
-7-
source
DIVR destination
+-
source
-7-
destination
Often the operand
in
the stack top
is
needed for one operation but then
is
of
no
further use
in
the
computation. The register pop form can be used to pick up the stack top as the source operand, and
then discard it
by
popping the stack. Coding operands of ST(1),ST with a register pop mnemonic
is
equivalent to a classical stack operation: the top
is
popped and the result
is
left at the
new
top.
The two memory forms increase the flexibility of the 80287's arithmetic instructions. They permit a
real number or a binary integer
in
memory to be used directly
as
a source operand. This
is
a very useful
facility in situations where operands are not used frequently enough to justify holding them
in
registers.
Note that any memory addressing mode may be used to define these operands,
so
they may be elements
in arrays, structures, or other data organizations,
as
well
as
simple scalars.
The six basic operations are discussed further
in
the next paragraphs, and descriptions of the remaining
seven arithmetic operations
follow.
ADDITION
FADD
FADDP
FIADD
/
/source/destination,source
/
/destination/source
source
The addition instructions (add real, add real and pop, integer add) add the source and destination
operands and return the sum to the destination. The operand
at
the stack top may be doubled by
coding:
FADD
ST,ST(O)
NORMAL SUBTRACTION
FSUB /
/source/destination,source
FSUBP /
/destination/source
FISUB source
2-6