Xref: news2.mv.net comp.os.msdos.djgpp:2543 From: korpela AT islay DOT ssl DOT berkeley DOT edu (Eric J. Korpela) Newsgroups: comp.os.msdos.djgpp Subject: Re: [q] inlined coprocessor instructions and fpu stack Date: 8 Apr 1996 17:36:05 GMT Organization: Cal Berkeley-- Space Sciences Lab Lines: 42 Message-ID: <4kbiq5$99n@agate.berkeley.edu> References: <4k63t5$1hf AT dec-alpha DOT fred DOT net> NNTP-Posting-Host: islay.ssl.berkeley.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <4k63t5$1hf AT dec-alpha DOT fred DOT net>, wrote: >Maybe you can clear this up for me, regarding keeping the FPU stack >clean/the way I `expect it be' -- > >How/Why duz: > asm("fldl %0" : : "f" (double_arg) ); >become: >1: /NO_APP >2: fldl _double_arg >3: /APP >4: fldl %st >5: /NO_APP >6: fstp %st(0) >7: > >Lines 4 and 6 don't leave st(0) with double_arg. gcc insists on putting >these extra instructions in the S file output. How do I stop this? What >is gcc doing ? gcc is resoring the registers to their previous state. It knows that %st(0) no longer contains what it did before the inline assmebly, so gcc restores it to what it was. If you really want double_arg to remain on the stack you need to write... asm("fldl _double_arg"); Beware, though that this has great potential for screwing things up. There's a good chance that the reason gcc was restoring the fp stack was that something it needed was there. Be sure that you pop as many items as you push before doing any floating point math outside of asm statements. Watch out that the fp stack doesn't overflow. Why do you need double_arg loaded onto the fp stack? Is this asm statement immediately followed by another asm statement that uses _double_arg? If so, combine them into one statement. Eric -- Eric Korpela | An object at rest can never be korpela AT ssl DOT berkeley DOT edu | stopped. Click here for more info.