Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Written by J.T. Conklin <jtc@netbsd.org>.
  3.  * Public domain.
  4.  *
  5.  * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
  6.  *
  7.  * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
  8.  *
  9.  * Removed header file dependency for use in libmingwex.a by
  10.  *   Danny Smith <dannysmith@users.sourceforge.net>
  11.  */
  12.  
  13.         .file   "log10l.S"
  14.         .text
  15.         .align 4
  16. one:    .double 1.0
  17.         /* It is not important that this constant is precise.  It is only
  18.            a value which is known to be on the safe side for using the
  19.            fyl2xp1 instruction.  */
  20. limit:  .double 0.29
  21.  
  22.         .text
  23.         .align 4
  24. .globl _log10l
  25.         .def    _log10l;        .scl    2;      .type   32;     .endef
  26. _log10l:
  27.         fldlg2                  /* log10(2) */
  28.         fldt    4(%esp)         /* x : log10(2) */
  29.         fxam
  30.         fnstsw
  31.         fld     %st             /* x : x : log10(2) */
  32.         sahf
  33.         jc      3f              /* in case x is NaN or ±Inf */
  34. 4:      fsubl   one             /* x-1 : x : log10(2) */
  35.         fld     %st             /* x-1 : x-1 : x : log10(2) */
  36.         fabs                    /* |x-1| : x-1 : x : log10(2) */
  37.         fcompl  limit           /* x-1 : x : log10(2) */
  38.         fnstsw                  /* x-1 : x : log10(2) */
  39.         andb    $0x45, %ah
  40.         jz      2f
  41.         fstp    %st(1)          /* x-1 : log10(2) */
  42.         fyl2xp1                 /* log10(x) */
  43.         ret
  44.  
  45. 2:      fstp    %st(0)          /* x : log10(2) */
  46.         fyl2x                   /* log10(x) */
  47.         ret
  48.  
  49. 3:      jp      4b              /* in case x is ±Inf */
  50.         fstp    %st(1)
  51.         fstp    %st(1)
  52.         ret
  53.