The 8087 and 287 FPUs were designed before the IEEE 754 standard was released. Because of this, they contain some instructions which are not compliant with it. When the 387 was released in 1987, it addressed these problems by adding some new instructions (notably, FPREM1
) and also by changing a lot of rules and quirks about rounding, infinities and denormal numbers (the main differences are listed in the 80387 Programmer's Reference Manual, Appendix C and D).
While some 387 programs may lose precision by being run on a 287, and some may even miss some important overflow/underflow/denormal exceptions, a 387 program is guaranteed to not work correctly if it tries a new instruction like FSIN
or FUCOM
.
Since the 387 was released 2 years after the 386, the first 386 systems were built with a 287 socket. Is it possible for such a system to emulate the new 387 instructions (without swapping the 287 with a 287XL)? By that, I mean to trap only the 387 opcodes, not every FPU opcode (which is trivial by setting CR0.EM
).
Current x86 CPUs seem to trap invalid FPU opcodes (in the D8
–DF
range). However, the 80386 CPU has no idea which FPU opcodes are valid and which aren't, because the FPU is external.