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 by Ulrich Drepper <drepper@cygnus.com>.
  5.  *
  6.  * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
  7.  */
  8.  
  9.         .file   "logf.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 _logf
  21.         .def    _logf;  .scl    2;      .type   32;     .endef
  22. _logf:
  23.         fldln2                  /* log(2) */
  24.         flds    4(%esp)         /* x : log(2) */
  25.         fld     %st             /* x : x : log(2) */
  26.         fsubl   one             /* x-1 : x : log(2) */
  27.         fld     %st             /* x-1 : x-1 : x : log(2) */
  28.         fabs                    /* |x-1| : x-1 : x : log(2) */
  29.         fcompl  limit           /* x-1 : x : log(2) */
  30.         fnstsw                  /* x-1 : x : log(2) */
  31.         andb    $0x45, %ah
  32.         jz      2f
  33.         fstp    %st(1)          /* x-1 : log(2) */
  34.         fyl2xp1                 /* log(x) */
  35.         ret
  36.  
  37. 2:      fstp    %st(0)          /* x : log(2) */
  38.         fyl2x                   /* log(x) */
  39.         ret
  40.