C built-in x86 fbstp command build

I wonder how to enable the use of fbstp in the I86 32-bit architecture. I tried something like

int main( )
{
    double foo = 100.0;

    long bar = 0;

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

    ...

But the bar has not changed. I tried to read everything I can find on this, but in most cases just do things like adding two integers. I cannot find any talk about how to push operands onto the stack, and what should I do when an instruction, such as fbstp, writes 80 bits of data back to memory (i.e. what type is C) and how to point it to syntax asm.

Also on x86-64 there seems to be pushq and no pushl, but fbstp still exists, while fbstq does not. Is there any other magic for 64 bits.

+3
1

: http://bap.ece.cmu.edu/download/bap-0.1/VEX/test/test-i386.c

, , - :

unsigned short bcd[5];
double a;

asm("fbstp %0" : "=m" (bcd[0]) : "t" (a) : "st");
+2

Source: https://habr.com/ru/post/1750013/


All Articles