1 | /* |
2 | * Public domain. |
3 | * |
4 | */ |
5 | |
6 | #include <machine/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: .tfloat 0.29 |
18 | /* Please note: we use a double value here. Since 1.0 has |
19 | an exact representation this does not effect the accuracy |
20 | but it helps to optimize the code. */ |
21 | one: .double 1.0 |
22 | |
23 | #ifdef PIC |
24 | # define MO(op) op##@GOTOFF(%edx) |
25 | #else |
26 | # define MO(op) op |
27 | #endif |
28 | |
29 | /* |
30 | * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29, |
31 | * otherwise fyl2x with the needed extra computation. |
32 | */ |
33 | .text |
34 | ENTRY(__log1pl) |
35 | fldln2 |
36 | |
37 | fldt 4(%esp) |
38 | |
39 | #ifdef PIC |
40 | LOAD_PIC_REG (dx) |
41 | #endif |
42 | |
43 | fxam |
44 | fnstsw |
45 | fld %st |
46 | sahf |
47 | jc 3f // in case x is NaN or ħInf |
48 | 4: |
49 | fabs |
50 | fldt MO(limit) |
51 | fcompp |
52 | fnstsw |
53 | sahf |
54 | jnc 2f |
55 | |
56 | movzwl 4+8(%esp), %eax |
57 | xorb $0x80, %ah |
58 | cmpl $0xc040, %eax |
59 | jae 5f |
60 | |
61 | faddl MO(one) |
62 | 5: fyl2x |
63 | ret |
64 | |
65 | 2: fyl2xp1 |
66 | ret |
67 | |
68 | 3: jp 4b // in case x is ħInf |
69 | fstp %st(1) |
70 | fstp %st(1) |
71 | fadd %st(0) |
72 | ret |
73 | |
74 | END (__log1pl) |
75 | |