Fix asin missing underflows (bug 16351).
[glibc.git] / sysdeps / i386 / fpu / e_asin.S
blobea8cb6f1b2d2b1532270cf47eaef4209c754836f
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  */
6 #include <machine/asm.h>
8 RCSID("$NetBSD: e_asin.S,v 1.4 1995/05/08 23:45:40 jtc Exp $")
10         .section .rodata.cst8,"aM",@progbits,8
12         .p2align 3
13         .type dbl_min,@object
14 dbl_min:        .byte 0, 0, 0, 0, 0, 0, 0x10, 0
15         ASM_SIZE_DIRECTIVE(dbl_min)
17 #ifdef PIC
18 # define MO(op) op##@GOTOFF(%ecx)
19 #else
20 # define MO(op) op
21 #endif
23         .text
25 /* asin = atan (x / sqrt((1-x) (1+x))) */
26 ENTRY(__ieee754_asin)
27 #ifdef  PIC
28         LOAD_PIC_REG (cx)
29 #endif
30         fldl    4(%esp)                 /* x */
31         fld     %st
32         fld1                            /* 1 : x : x */
33         fsubp                           /* 1 - x : x */
34         fld1                            /* 1 : 1 - x : x */
35         fadd    %st(2)                  /* 1 + x : 1 - x : x */
36         fmulp                           /* 1 - x^2 */
37         fsqrt                           /* sqrt (1 - x^2) */
38         fpatan
39         fldl    MO(dbl_min)
40         fld     %st(1)
41         fabs
42         fucompp
43         fnstsw
44         sahf
45         jnc     1f
46         subl    $8, %esp
47         cfi_adjust_cfa_offset (8)
48         fld     %st(0)
49         fmul    %st(0)
50         fstpl   (%esp)
51         addl    $8, %esp
52         cfi_adjust_cfa_offset (-8)
53 1:      ret
54 END (__ieee754_asin)
55 strong_alias (__ieee754_asin, __asin_finite)