[comp.sys.intel] Moving FPU values around

skibo@plx.UUCP (skibo login ) (08/26/88)

One restriction that is important to bear in mind when using MOVSW to
transfer floating - point values is to make sure that the coprocessor
has finished writing out the values to memory before they are transferred.

Sounds obvious, but under certain optimization controls, Microsoft's 
Xenix C compiler for the 286 will not do this!

Correct:
	FSTP	a
	lea	si, a		; source
	lea	di, b		; destination
	FWAIT			; insures FSTP is complete
	movsw
	movsw
	movsw
	movsw

I'm not sure if SI or DI functions as the destination pointer, but you
get the idea.  Where Microsoft fell down is when they return floating-point
values from a function:  they would issue the FSTP, and then RET (w/o FWAIT).

If the next thing to do was more floating-point, no problem, because
any subsequent floating-point operations would wait until the FSTP was
finished.  If the target of the FSTP was to be manipulated by non-processor
activites: written to disk, copied to another variable, etc, the lack of
the FWAIT instruction would cause lack of coherence.

stan chesnutt/plexus computers inc/ sun!plx!dyrk!skibo