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.  * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>.
  5.  *
  6.  * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
  7.  */
  8.  
  9.         .file   "log10f.S"
  10.         .text
  11.         .align 4
  12. one:    .double 1.0
  13.         /* It is not important that this constant is precise.  It is only
  14.            a value which is known to be on the safe side for using the
  15.            fyl2xp1 instruction.  */
  16. limit:  .double 0.29
  17.  
  18.         .text
  19.         .align 4
  20. .globl _log10f
  21.         .def    _log10f;        .scl    2;      .type   32;     .endef
  22. _log10f:
  23.         fldlg2                  /* log10(2) */
  24.         flds    4(%esp)         /* x : log10(2) */
  25.         fxam
  26.         fnstsw
  27.         fld     %st             /* x : x : log10(2) */
  28.         sahf
  29.         jc      3f              /* in case x is NaN or ±Inf */
  30. 4:      fsubl   one             /* x-1 : x : log10(2) */
  31.         fld     %st             /* x-1 : x-1 : x : log10(2) */
  32.         fabs                    /* |x-1| : x-1 : x : log10(2) */
  33.         fcompl  limit           /* x-1 : x : log10(2) */
  34.         fnstsw                  /* x-1 : x : log10(2) */
  35.         andb    $0x45, %ah
  36.         jz      2f
  37.         fstp    %st(1)          /* x-1 : log10(2) */
  38.         fyl2xp1                 /* log10(x) */
  39.         ret
  40.  
  41. 2:      fstp    %st(0)          /* x : log10(2) */
  42.         fyl2x                   /* log10(x) */
  43.         ret
  44.  
  45. 3:      jp      4b              /* in case x is ±Inf */
  46.         fstp    %st(1)
  47.         fstp    %st(1)
  48.         ret
  49.