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