C inline assembly of x96 fbstp instruction

Posted by David HUnter on Stack Overflow See other posts from Stack Overflow or by David HUnter
Published on 2010-06-14T21:00:39Z Indexed on 2010/06/14 21:02 UTC
Read the original article Hit count: 274

Filed under:
|
|
|

Was wondering how to inline a usage of fbstp on a 32 bit I86 architecture. I tried something like

int main( ) { double foo = 100.0;

long bar = 0;

asm( "pushl %1; fbstp %0"
     : "=m"(bar)
     : "r"(foo)
   );

...

But bar is unchanged. I have tried reading everything I can find on this but most example simply do things like add two integers together. I can’t find any that talk about pushing operands onto the stack and what I should be doing when an instruction like fbstp writes 80 bits of data back to memory ( i.e. what C type to use ) and how to specify it in the asm syntax.

Also on x86-64 there seems to be a pushq and no pushl but fbstp still exists whereas fbstq does not. Is there some other magic for 64 bit.

© Stack Overflow or respective owner

Related posts about gcc

Related posts about assembly