The FPU Stack
The most important registers in the FPU are a stack of eight extended
floating point numbers.
One of the registers is designated as the top of the stack (ST0) and
all other registers are relative to it: ST1, ST2. Data is pushed
on the stack with a load. Data is taken off the stack with a store.
Actually, the store copies the top of the stack but does not take it off.
The instruction must be combined with a pop (by using the "p" suffix on the
instuction).
In every FPU computation, one of
the operands is ST0. When values are put on or are taken off,
ST0 is changed so that it points to the new top of the stack.
If an attempt to put value on a non-empty entry will result in an error.
FPU Load (Push)
fld | mem32 or mem64 | ; short or long fp load |
fld | ST(n) | ; load from another stack entry |
fild | mem16 or mem32 | ; int or long int load |
fbld | mem80 | ; BCD load |
NOTE: The argument is converted to internal format of FPU and pushed on the stack.
NOTE: A simple register cannot be used as the operand.
FPU Load (Push) constants
fld1 | ; load 1 |
fldz | ; load zero |
fldpi | ; load p |
fldl2t | ; load log210 |
fldl2e | ; load log2e |
fldlg2 | ; load log102 |
fldln2 | ; load loge2 |
FPU Store (and pop) ST0
fst[p] | mem32 or mem64 | ; store [and pop] ST0 |
fst[p] | STn | ; copy [then pop] ST0 to STn |
fist[p] | mem16 or mem32 | ; store [and pop] ST0 as int |
fbst | mem80 | ; store and pop ST0 as BCD |
FPU Miscellaneous Stack Instructions
fcomp | ST | ; pop FPU stack |
fld | ST | ; load duplicate of stack top |
fxch | ST(n) | ; exchange contents of ST0 and STn |
fxch | | ; exchange contents of ST0 and ST1 |
©2004, Gary L. Burt