使用x87指令计算切线FPTAN和FDIVR

时间:2015-03-02 07:36:01

标签: assembly floating-point x87

我想用X87 FPTAN和FDIVR计算tan(pi)

#include <stdio.h>
int main(){

  double answer,angle=3.14;
  __asm__ ("FPTAN;"
       "FDIVR;"
       : "=t" (answer) : "0" (angle));
  printf ("angle = %g\n",angle);
  printf ("answer = %g\n",answer);

}

但是我收到了编译错误

error: unknown use of instruction mnemonic without a size suffix
      __asm__ ("FPTAN;"
               ^
<inline asm>:1:8: note: instantiated into assembly here
        FPTAN;FDIVR;
              ^
1 error generated.

如何驾驭错误?看起来需要大小后缀,但我不知道如何构造指令。

有关信息,我的“gcc -v”返回

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

0 个答案:

没有答案