Am 30.06.2014 08:21, schrieb Walter Bright:
The only way I know to access x87 is with inline asm.

I suggest using "long double" on Linux and look at the compiler output. You
don't have to believe me - use gcc or clang.

gcc.godbolt.org clang 3.4.1 -O3

int main(int argc, char** argv)
{
  return ((long double)argc/12345.6789);
}

asm:

.LCPI0_0:
        .quad   4668012723080132769     # double 12345.678900000001
main:                                   # @main
        movl    %edi, -8(%rsp)
        fildl   -8(%rsp)
        fdivl   .LCPI0_0(%rip)
        fnstcw  -10(%rsp)
        movw    -10(%rsp), %ax
        movw    $3199, -10(%rsp)        # imm = 0xC7F
        fldcw   -10(%rsp)
        movw    %ax, -10(%rsp)
        fistpl  -4(%rsp)
        fldcw   -10(%rsp)
        movl    -4(%rsp), %eax
        ret



Reply via email to