Floating-Point and Coprocessors


There are three ways to deal with floating point:

union {
char state[108];
int control;
} coproc;
Tasks using the coprocessor must save and restore its context using assembly language instructions.

/* Coprocessor Context Save *
* for in line assembly     */
asm fsave coproc.state
asm fldcw coproc.control
.
/* floating point operations */
.
.
/* Coprocessor Context Restore */

asm frstor coproc.state
Coprocessor hardware provides a reentrancy problem for multitasking. To save the context of an 80x87 coprocessor, 94 bytes are needed for the 8087 or 80287, 108 bytes for 80387 coprocessors.