~mingw-w64/mingw-w64/experimental

« back to all changes in this revision

Viewing changes to ros-privexp/mingw-w64-crt/math/exp2l.S

  • Committer: NightStrike
  • Date: 2010-08-11 22:20:57 UTC
  • Revision ID: svn-v4:4407c894-4637-0410-b4f5-ada5f102cad1:experimental:3266
Branch for adding option for supporting ros

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This file has no copyright assigned and is placed in the Public Domain.
 
3
 * This file is part of the w64 mingw-runtime package.
 
4
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 
5
 */
 
6
#include <_mingw_mac.h>
 
7
 
 
8
        .file   "exp2l.S"
 
9
        .text
 
10
#ifdef _WIN64
 
11
        .align 8
 
12
#else
 
13
        .align 4
 
14
#endif
 
15
.globl __MINGW_USYMBOL(exp2l)
 
16
        .def    __MINGW_USYMBOL(exp2l); .scl    2;      .type   32;     .endef
 
17
__MINGW_USYMBOL(exp2l):
 
18
#ifdef _WIN64
 
19
        fldt    (%rdx)
 
20
        fxam                            /* Is NaN or +-Inf?  */
 
21
        fstsw   %ax
 
22
        movb    $0x45, %dh
 
23
        andb    %ah, %dh
 
24
        cmpb    $0x05, %dh
 
25
        je      1f                      /* Is +-Inf, jump.  */
 
26
        fld     %st
 
27
        frndint                         /* int(x) */
 
28
        fsubr   %st,%st(1)              /* fract(x) */
 
29
        fxch
 
30
        f2xm1                           /* 2^(fract(x)) - 1 */
 
31
        fld1
 
32
        faddp                           /* 2^(fract(x)) */
 
33
        fscale                          /* e^x */
 
34
        fstp    %st(1)
 
35
        movq    %rcx,%rax
 
36
        movq    $0,8(%rcx)
 
37
        fstpt   (%rcx)
 
38
        ret
 
39
 
 
40
1:      testl   $0x200, %eax            /* Test sign.  */
 
41
        jz      2f                      /* If positive, jump.  */
 
42
        fstp    %st
 
43
        fldz                            /* Set result to 0.  */
 
44
2:      movq    %rcx,%rax
 
45
        movq    $0,8(%rcx)
 
46
        fstpt   (%rcx)
 
47
        ret
 
48
#else
 
49
        fldt    4(%esp)
 
50
/* I added the following ugly construct because exp(+-Inf) resulted
 
51
   in NaN.  The ugliness results from the bright minds at Intel.
 
52
   For the i686 the code can be written better.
 
53
   -- drepper@cygnus.com.  */
 
54
        fxam                            /* Is NaN or +-Inf?  */
 
55
        fstsw   %ax
 
56
        movb    $0x45, %dh
 
57
        andb    %ah, %dh
 
58
        cmpb    $0x05, %dh
 
59
        je      1f                      /* Is +-Inf, jump.  */
 
60
        fld     %st
 
61
        frndint                         /* int(x) */
 
62
        fsubr   %st,%st(1)              /* fract(x) */
 
63
        fxch
 
64
        f2xm1                           /* 2^(fract(x)) - 1 */
 
65
        fld1
 
66
        faddp                           /* 2^(fract(x)) */
 
67
        fscale                          /* e^x */
 
68
        fstp    %st(1)
 
69
        ret
 
70
 
 
71
1:      testl   $0x200, %eax            /* Test sign.  */
 
72
        jz      2f                      /* If positive, jump.  */
 
73
        fstp    %st
 
74
        fldz                            /* Set result to 0.  */
 
75
2:      ret
 
76
#endif