Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1906 | serge | 1 | /* |
2 | * Written by J.T. Conklin |
||
3 | * Public domain. |
||
4 | * |
||
5 | * Changed to use fyl2xp1 for values near 1, |
||
6 | */ |
||
7 | |||
8 | .file "log.s" |
||
9 | .text |
||
10 | .align 4 |
||
11 | one: .double 1.0 |
||
12 | /* It is not important that this constant is precise. It is only |
||
13 | a value which is known to be on the safe side for using the |
||
14 | fyl2xp1 instruction. */ |
||
15 | limit: .double 0.29 |
||
16 | |||
17 | .text |
||
18 | .align 4 |
||
19 | .globl _log |
||
20 | .def _log; .scl 2; .type 32; .endef |
||
21 | _log: |
||
22 | fldln2 /* log(2) */ |
||
23 | fldl 4(%esp) /* x : log(2) */ |
||
24 | fld %st /* x : x : log(2) */ |
||
25 | fsubl one /* x-1 : x : log(2) */ |
||
26 | fld %st /* x-1 : x-1 : x : log(2) */ |
||
27 | fabs /* |x-1| : x-1 : x : log(2) */ |
||
28 | fcompl limit /* x-1 : x : log(2) */ |
||
29 | fnstsw /* x-1 : x : log(2) */ |
||
30 | andb $0x45, %ah |
||
31 | jz 2f |
||
32 | fstp %st(1) /* x-1 : log(2) */ |
||
33 | fyl2xp1 /* log(x) */ |
||
34 | ret |
||
35 | |||
36 | 2: fstp %st(0) /* x : log(2) */ |
||
37 | fyl2x /* log(x) */ |
||
38 | ret |