delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq085.html   search  

| Previous | Next | Up | Top |

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 file 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. This code is hard to debug, because the people who developed it have machines with hardware FP processors. Volunteers with FPU-less machines are needed to help debug the above problem. If you have access to a system without an FPU and are willing to fix this problem, write to Charles Sandmann and ask him for guidance.

There is an alternative FP emulator called WMEMU (get the file v2misc/wmemu2b.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 sources and recompile it, since it was compiled with a beta release of DJGPP 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).


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright ⌐ 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)