johnl@esegue.segue.boston.ma.us (John R. Levine) (03/08/90)
I am working on porting a large C program to a 386 running 386/ix and have run into the following 387 related problem. On some machines, particularly Compaq 386-25, we are getting repeatable wrong floating point results. Upon investigation, it appears that in some cases the 387 is storing a result with FSTP and then the CPU is loading that result with the next instruction. The 386 hardware manual clearly states that you're not supposed to do that. The FSTP sets up an address pointer in the 386 and the 387 clocks out the data when it feels like it. You need to do a WAIT to make sure it's done. None of the 386 C compilers that I've looked at put in these waits, so I expect that in most cases the 387 actually shoves the data out fast enough that the wait isn't necessary. On my own machine, an Intel 302 with the Intel cached 25 MHz motherboard, I can't make it fail. My question is whether it is possible to characterize the circumstances under which you actually need to wait after a FST, FSTP, FIST, or FISTP. I can put the WAIT instructions into the compiler (we're using GCC) but all of those extra waits will make the program somewhat bigger and slower, so if there's a safe way to avoid most of them, I'd like to do so. By the way, I called Intel's 800 support number in Oregon and after waiting for the usual 45 minutes, was informed that there wasn't anybody there who knew anything at all about programming the 387, the best they could do was to tell me where to order the 387 programmer's manual. -- John R. Levine, Segue Software, POB 349, Cambridge MA 02238, +1 617 864 9650 johnl@esegue.segue.boston.ma.us, {ima|lotus|spdcc}!esegue!johnl "Now, we are all jelly doughnuts."