Node:Emulation, Next:, Previous:Floating point, Up:Floating point

11.1 Floating-point code without 80387

Q: I don't have an 80387. How do I compile and run floating point programs?

Q: What shall I install on a target machine which lacks hardware floating-point support?

A: Programs which use floating point computations and could be run on machines without an 80387 should either be linked with the libemu.a emulation library (add -lemu to your link command line) or be allowed to dynamically load the emu387.dxe emulator at run-time if needed. Linking with libemu makes distribution simpler at a price of adding about 20KB to the size of the program .exe file (the emulator functions will be used only if no hardware floating point support is detected at runtime). You should always do one of the above when you distribute floating-point programs.

A few users reported that the emulation won't work for them unless they explicitly tell DJGPP there is no x87 hardware, like this:

  set 387=N
  set emu387=c:/djgpp/bin/emu387.dxe

This is probably due to some subtle bug in the emulator setup code. It is possible that it was fixed in the latest DJGPP version, so upgrade if you can. If the problem persists, please post the details to the comp.os.msdos.djgpp news group.

There is an alternative FP emulator called WMEMU (get the file v2misc/wmemu21b.zip). It mimics a real coprocessor more closely, but is larger in size and is distributed under the GNU General Public License (which generally means you need to distribute its source if you distribute wmemu387.dxe, or distribute the source or objects to your entire program, if you link it with libwmemu.a). Its advantage is that with WMEMU, you can debug FP apps on a non-FPU machine. (But you will need to get the latest binaries of WMEMU, since older distributions were compiled with a beta release of DJGPP v2.0 and will cause unresolved externals if you try linking against libwmemu.a without recompiling it.) Note, however, that even WMEMU doesn't solve all the problems of debugging FP programs on a non-FPU machine (e.g., emulating flags doesn't work).