1 | /* |
2 | * Public domain. |
3 | */ |
4 | |
5 | #include <machine/asm.h> |
6 | #include <i386-math-asm.h> |
7 | |
8 | RCSID("$NetBSD: s_log1p.S,v 1.7 1995/05/09 00:10:58 jtc Exp $" ) |
9 | |
10 | .section .rodata |
11 | |
12 | .align ALIGNARG(4) |
13 | /* The fyl2xp1 can only be used for values in |
14 | -1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2 |
15 | 0.29 is a safe value. |
16 | */ |
17 | limit: .double 0.29 |
18 | one: .double 1.0 |
19 | |
20 | DEFINE_DBL_MIN |
21 | |
22 | #ifdef PIC |
23 | # define MO(op) op##@GOTOFF(%edx) |
24 | #else |
25 | # define MO(op) op |
26 | #endif |
27 | |
28 | /* |
29 | * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29, |
30 | * otherwise fyl2x with the needed extra computation. |
31 | */ |
32 | .text |
33 | ENTRY(__log1p) |
34 | fldln2 |
35 | |
36 | fldl 4(%esp) |
37 | |
38 | #ifdef PIC |
39 | LOAD_PIC_REG (dx) |
40 | #endif |
41 | |
42 | fxam |
43 | fnstsw |
44 | fld %st |
45 | sahf |
46 | jc 3f // in case x is NaN or ħInf |
47 | 4: fabs |
48 | fcompl MO(limit) |
49 | fnstsw |
50 | sahf |
51 | jc 2f |
52 | |
53 | faddl MO(one) |
54 | fyl2x |
55 | ret |
56 | |
57 | 2: fyl2xp1 |
58 | DBL_CHECK_FORCE_UFLOW_NONNAN |
59 | ret |
60 | |
61 | 3: jp 4b // in case x is ħInf |
62 | fstp %st(1) |
63 | fstp %st(1) |
64 | ret |
65 | |
66 | END (__log1p) |
67 | |