How do I specify immediate floating point numbers with inline assembly?

前端 未结 5 1781
天命终不由人
天命终不由人 2020-12-10 14:52

When I try to compile this code:

#include 

main(int argc, char *argv[]) {
   double y = 0;

   __asm__ (\"fldl $150;\"
            \"fsqrt;\"         


        
5条回答
  •  -上瘾入骨i
    2020-12-10 15:34

    I do not know of an assembly language which supports literal floating point constants for immediate use. The usual means is to declare initialized storage containing the floating point constant and referencing it:

    const1:     dq  1.2345
    ...
         fldl    const1
    

    For the example you give, it is possible to do this more directly:

    printf ("%f\n", sqrt (150));
    

    Otherwise, this must be an artificially complicated project, perhaps homework.

提交回复
热议问题