Home | History | Annotate | Download | only in amd64
      1 
      2 #include <stdio.h>
      3 #include <math.h>
      4 
      5 double arg, res1, res2;
      6 
      7 extern void do_fxtract ( void );
      8 asm("\n"
      9 ".global do_fxtract\n"
     10 "do_fxtract:\n"
     11 "\tfinit\n"
     12 "\tfldl arg\n"
     13 "\tfxtract\n"
     14 "\tfstpl res1\n"
     15 "\tfstpl res2\n"
     16 "\tret"
     17 );
     18 
     19 void try ( double x )
     20 {
     21   arg = x * 1.414213562373049;
     22   res1 = res2 = 0.0;
     23   do_fxtract();
     24   printf("%17.10e  -> %14.10f %14.10f\n", arg, res1, res2);
     25 }
     26 
     27 int main ( void )
     28 {
     29   int i;
     30 
     31   /* positives */
     32 
     33   for (i = 0; i < 40; i++)
     34      try( 1.27 + (double)(i*10 - 200) );
     35 
     36   try(+0.0);
     37   try(1.0 / 0.0);
     38   try(sqrt(-1.0));
     39 
     40   try(5.1e-308);
     41   try(4.1e-308);
     42   try(3.1e-308);
     43   try(2.1e-308);
     44   try(1.1e-308);
     45   try(0.9e-308);
     46   try(0.7e-308);
     47   try(0.6e-308);
     48   try(0.5e-308);
     49   try(0.4e-308);
     50   try(0.3e-308);
     51   try(0.1e-308);
     52 
     53   try(1.3e-320);
     54   try(1.3e-321);
     55   try(1.3e-322);
     56   try(1.3e-323);
     57   try(0.9e-323);
     58   try(0.7e-323);
     59   try(0.5e-323);
     60   try(0.3e-323);
     61   try(0.2e-323);
     62   try(1.3e-324);
     63 
     64   /* negatives */
     65 
     66   printf("\n");
     67   for (i = 0; i < 40; i++)
     68      try( - (1.27 + (double)(i*10 - 200)) );
     69 
     70   try(-0.0);
     71   try(-(1.0 / 0.0));
     72   try(-sqrt(-1.0));
     73 
     74   try(-5.1e-308);
     75   try(-4.1e-308);
     76   try(-3.1e-308);
     77   try(-2.1e-308);
     78   try(-1.1e-308);
     79   try(-0.9e-308);
     80   try(-0.7e-308);
     81   try(-0.6e-308);
     82   try(-0.5e-308);
     83   try(-0.4e-308);
     84   try(-0.3e-308);
     85   try(-0.1e-308);
     86 
     87   try(-1.3e-320);
     88   try(-1.3e-321);
     89   try(-1.3e-322);
     90   try(-1.3e-323);
     91   try(-0.9e-323);
     92   try(-0.7e-323);
     93   try(-0.5e-323);
     94   try(-0.3e-323);
     95   try(-0.2e-323);
     96   try(-1.3e-324);
     97 
     98   return 0;
     99 }
    100