sewardj | 0c7a4f9 | 2005-03-25 20:29:00 +0000 | [diff] [blame] | 1 | |
| 2 | #include <stdio.h> |
| 3 | #include <math.h> |
| 4 | |
| 5 | double d; |
| 6 | int i; |
| 7 | |
sewardj | fef858e | 2005-03-25 22:32:39 +0000 | [diff] [blame^] | 8 | extern void do_fxam ( void ); |
sewardj | 0c7a4f9 | 2005-03-25 20:29:00 +0000 | [diff] [blame] | 9 | |
| 10 | asm( |
| 11 | "\n" |
sewardj | fef858e | 2005-03-25 22:32:39 +0000 | [diff] [blame^] | 12 | "do_fxam:\n" |
sewardj | 0c7a4f9 | 2005-03-25 20:29:00 +0000 | [diff] [blame] | 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" |
| 20 | ); |
| 21 | |
sewardj | fef858e | 2005-03-25 22:32:39 +0000 | [diff] [blame^] | 22 | |
| 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; } |
| 26 | |
| 27 | /* Try positive and negative variants of: zero, infinity, |
| 28 | nAn, and denorm */ |
| 29 | |
sewardj | 0c7a4f9 | 2005-03-25 20:29:00 +0000 | [diff] [blame] | 30 | int main ( void ) |
| 31 | { |
sewardj | fef858e | 2005-03-25 22:32:39 +0000 | [diff] [blame^] | 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 ); |
| 34 | |
| 35 | d = inf(); do_fxam(); printf("0x%4x: %f\n", i, d ); |
| 36 | d = -inf(); do_fxam(); printf("0x%4x: %f\n", i, d ); |
| 37 | |
| 38 | d = nAn(); do_fxam(); printf("0x%4x: %f\n", i, d ); |
| 39 | d = -nAn(); do_fxam(); printf("0x%4x: %f\n", i, d ); |
| 40 | |
| 41 | d = den(); do_fxam(); printf("0x%4x: %f\n", i, d ); |
| 42 | d = -den(); do_fxam(); printf("0x%4x: %f\n", i, d ); |
sewardj | 0c7a4f9 | 2005-03-25 20:29:00 +0000 | [diff] [blame] | 43 | return 0; |
| 44 | } |