drd/tests/Makefile.am: Use -faligned-new for C++ code if supported
[valgrind.git] / VEX / test / x87fxam.c
blob680b7ffbb8cd10ff729e56bfe6f2606476c736f0
2 #include <stdio.h>
3 #include <math.h>
5 double d;
6 int i;
8 extern void do_fxam ( void );
10 asm(
11 "\n"
12 "do_fxam:\n"
13 "\txorl %eax,%eax\n"
14 "\tfld d\n"
15 "\tfxam\n"
16 "\tfnstsw %ax\n"
17 "\tffree %st(0)\n"
18 "\tmovl %eax, i\n"
19 "\tret\n"
23 double inf ( void ) { return 1.0 / 0.0; }
24 double nAn ( void ) { return 0.0 / 0.0; }
25 double den ( void ) { return 9.1e-220 / 1e100; }
27 /* Try positive and negative variants of: zero, infinity,
28 nAn, and denorm */
30 int main ( void )
32 d = 0.0; do_fxam(); printf("0x%4x: %f\n", i, d );
33 d = -0.0; do_fxam(); printf("0x%4x: %f\n", i, d );
35 d = inf(); do_fxam(); printf("0x%4x: %f\n", i, d );
36 d = -inf(); do_fxam(); printf("0x%4x: %f\n", i, d );
38 d = nAn(); do_fxam(); printf("0x%4x: %f\n", i, d );
39 d = -nAn(); do_fxam(); printf("0x%4x: %f\n", i, d );
41 d = den(); do_fxam(); printf("0x%4x: %f\n", i, d );
42 d = -den(); do_fxam(); printf("0x%4x: %f\n", i, d );
43 return 0;