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 | * Adapted for exp2 by Ulrich Drepper |
||
4 | * Public domain. |
||
5 | */ |
||
6 | |||
7 | .file "exp2.S" |
||
8 | .text |
||
9 | .align 4 |
||
10 | .globl _exp2 |
||
11 | .def _exp2; .scl 2; .type 32; .endef |
||
12 | _exp2: |
||
13 | fldl 4(%esp) |
||
14 | /* I added the following ugly construct because exp(+-Inf) resulted |
||
15 | in NaN. The ugliness results from the bright minds at Intel. |
||
16 | For the i686 the code can be written better. |
||
17 | -- drepper@cygnus.com. */ |
||
18 | fxam /* Is NaN or +-Inf? */ |
||
19 | fstsw %ax |
||
20 | movb $0x45, %dh |
||
21 | andb %ah, %dh |
||
22 | cmpb $0x05, %dh |
||
23 | je 1f /* Is +-Inf, jump. */ |
||
24 | fld %st |
||
25 | frndint /* int(x) */ |
||
26 | fsubr %st,%st(1) /* fract(x) */ |
||
27 | fxch |
||
28 | f2xm1 /* 2^(fract(x)) - 1 */ |
||
29 | fld1 |
||
30 | faddp /* 2^(fract(x)) */ |
||
31 | fscale /* e^x */ |
||
32 | fstp %st(1) |
||
33 | ret |
||
34 | |||
35 | 1: testl $0x200, %eax /* Test sign. */ |
||
36 | jz 2f /* If positive, jump. */ |
||
37 | fstp %st |
||
38 | fldz /* Set result to 0. */ |
||
39 | 2: ret |