为什么不发生浮点异常?

kun*_*255 2 linux assembly x86-64 fpu sigfpe

我正在学习浮点数的算法.我写了下面的代码.但是不会发生浮点异常.我的环境是Cent OS 6.4(x86_64).

请教我这个理由.

#include <stdio.h>

int
main(void)
{
  double a,b,c;
  unsigned short int fctr;

  a=3.0;
  b=0.0;
  c=1.0;

  asm volatile(
    "fstcw %w0" // get FPU control word
    :"=m"(fctr):);
  printf("FPU control word= %X\n", fctr);

  fctr = fctr ^ 0x4;
  printf("FPU control word= %X\n", fctr);

  asm volatile(
    "fldcw %w0"  // set operand to FPU control word
    : :"m"(fctr));

  asm volatile(
    "fstcw %w0" // get FPU control word
    :"=m"(fctr):);
  printf("FPU control word= %X\n", fctr);

  c = a/b;

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*ort 5

可能是因为x86_64架构默认情况下使用SSE2而不是x87进行浮点运算.(状态字属于x87)

用-S编译并检查生成的汇编程序是否真的是x87.

链接中搜索MXCSR