Hasty Briefsbeta

Bilingual

8087 Emulation on 8086 Systems

5 hours ago
  • #history
  • #x86
  • #emulation
  • The 8086 CPU (1978) had a generic coprocessor interface used by the Intel 8087 FPU (1980), an expensive add-on not universally available.
  • Intel released the E8087 software emulation package in 1980, enabling developers to write 8087 software without requiring physical hardware.
  • Emulation required tight cooperation between assemblers/compilers, linkers, and runtime libraries, with decision to emulate made at link time.
  • Intel's original implementation replaced ESC opcodes D8h-DFh with INT 18h-1Fh, using eight interrupt vectors to preserve FPU opcode information.
  • Microsoft adopted and modified Intel's mechanism for DOS tools, using interrupts 34h-3Dh (10 vectors) and emulating WAIT instructions and segment overrides.
  • Microsoft's emulator could detect an 8087 at runtime and replace software INT instructions with real 8087 code for near-full-speed execution on FPU-equipped systems.
  • MASM versions (e.g., 1.25, 3.0) used switches like /R and /E to generate emulation-ready code, adding fix-ups (e.g., FIDRQQ, FIWRQQ) for FPU instructions and FWAIT.
  • Fix-up values were carefully calculated to transform opcode sequences (e.g., WAIT/ESC) into software INT instructions via linker adjustments.
  • Segment overrides (CS, DS, ES, SS) were handled with specific fix-ups (e.g., FIARQQ, FICRQQ), using additional values (e.g., FJCRQQ) to encode override information.
  • Debuggers like SYMDEB recognized emulated instructions, displaying them as FPU commands rather than raw INT opcodes for easier debugging.
  • No-emulation libraries defined fix-up symbols with zero values, leaving object code unchanged, allowing emulation-ready code to run unmodified without FPU.
  • Intel's original implementation was more complete, supporting no-wait instructions (e.g., FNSTSW) and using different fix-up names (e.g., M:_WST), but Microsoft's variant became dominant in DOS development.