Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* ix87 specific implementation of exp(x)-1.
  2.    Copyright (C) 1996, 1997, 2005 Free Software Foundation, Inc.
  3.    This file is part of the GNU C Library.
  4.    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
  5.    Based on code by John C. Bowman <bowman@ipp-garching.mpg.de>.
  6.    Corrections by H.J. Lu (hjl@gnu.ai.mit.edu), 1997.
  7.  
  8.    The GNU C Library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU Lesser General Public
  10.    License as published by the Free Software Foundation; either
  11.    version 2.1 of the License, or (at your option) any later version.
  12.  
  13.    The GNU C Library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Lesser General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU Lesser General Public
  19.    License along with the GNU C Library; if not, write to the Free
  20.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  21.    02111-1307 USA.  */
  22.  
  23.         /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */
  24.  
  25.         .file   "s_expm1.s"
  26.         .text
  27.         .align 4
  28.  
  29. minus1: .double -1.0
  30. one:    .double 1.0
  31. l2e:    .tfloat 1.442695040888963407359924681002
  32.  
  33.         .align 4
  34. .globl ___expm1
  35.         .def    __expm1;        .scl    2;      .type   32;     .endef
  36.  
  37. ___expm1:
  38.         fldl    4(%esp)         # x
  39.         fxam                    # Is NaN or +-Inf?
  40.         fstsw   %ax
  41.         movb    $0x45, %ch
  42.         andb    %ah, %ch
  43.         cmpb    $0x40, %ch
  44.         je      3f              # If +-0, jump.
  45.  
  46.         cmpb    $0x05, %ch
  47.         je      2f              # If +-Inf, jump.
  48.  
  49.         fldt    l2e             # log2(e) : x
  50.         fmulp                   # log2(e)*x
  51.         fld     %st             # log2(e)*x : log2(e)*x
  52.         frndint                 # int(log2(e)*x) : log2(e)*x
  53.         fsubr   %st, %st(1)     # int(log2(e)*x) : fract(log2(e)*x)
  54.         fxch                    # fract(log2(e)*x) : int(log2(e)*x)
  55.         f2xm1                   # 2^fract(log2(e)*x)-1 : int(log2(e)*x)
  56.         fscale                  # 2^(log2(e)*x)-2^int(log2(e)*x) : int(log2(e)*x)
  57.         fxch                    # int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
  58.         fldl    one             # 1 : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
  59.         fscale                  # 2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
  60.         fsubrl  one             # 1-2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
  61.         fstp    %st(1)          # 1-2^int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x)
  62.         fsubrp  %st, %st(1)     # 2^(log2(e)*x)
  63.         ret
  64.  
  65. 2:      testl   $0x200, %eax    # Test sign.
  66.         jz      3f              # If positive, jump.
  67.         fstp    %st
  68.         fldl    minus1          # Set result to -1.0.
  69. 3:      ret
  70.  
  71.