Intel floating point coprocessor (80x87)

see also Intel assembly language, or Notes contents for MIPS Assembly

Prepared by Lin Jensen , Bishop's University, for CSc 116 Assembly Language class.

This is a brief list of som basic float instructions for the csc116 class, in case anyone wants to use floating point arithmetic.

The intel floating point coprocessor contains 8 registers, which are internally 80 bits. Load and store instructions exist to transfer either 32-bit "single" or 64-bit "double" values.
The most interesting thing about these registers is that they are organized as a STACK, which is not to be confused with the normal stack in memory.

finit		;initialize the coprocessor
Loads "push" a number on this stack, stores "pop" the top of this stack, as indicated by the suffix p.
fld     source       ; pushes the real number in source 
fstp destination ; pops the top into the destination, as a real number
Conversions from/to integer are handled during load and store:
fild	integer_source	; converts source to a real and pushes it
fistp integer_dest ; pops top, converts to integer and stores in destination

Arithmetic operations

"pop" the top two numbers and "push" the result back. No operands. (note: there exist many varients using operands, including integers.)
fadd
fsub
fsubr ; reverses the order of operands (it matters for subtract)
fmul
fdiv
fdivr
Comparisons compare the top two numbers on the stack. You can remove one or both if you like
fcom		; compare
fcomp ; compare and pop one
fcompp ; compare and pop both

A sample of some more specialized f-instructions

fldz		; 0.0 on top of stack
fld1 ; 1.0 on top of stack
fldpi ; 3.1415..... on stack

fsqrt ; top replaced with its square root
fsin
fcos ; same for trig function

fwait ; processor waits for coprocessor to finish operations

Last updated 14 December 2004. Back to Intel assembly language, or Lab 11 or course Notes contents for MIPS Assembly