Annotation of coherent/b/lib/libm/i387/log87.s, revision 1.1.1.1

1.1       root        1: //////////
                      2: / /usr/src/libm/i387/log87.s
                      3: / i387 mathematics library
                      4: / log(x), log10(x), ylog2x
                      5: //////////
                      6: 
                      7: RASIZE =       4
                      8: 
                      9:        .globl  log10
                     10:        .globl  log
                     11:        .globl  _ylog2x
                     12: /      .globl  _cfcc
                     13:        .globl  _tstcc
                     14:        .globl  _edomain
                     15: 
                     16: //////////
                     17: / double
                     18: / log(x)
                     19: / double x;
                     20: /
                     21: / double
                     22: / log10(x)
                     23: / double x;
                     24: /
                     25: / ylog2x does the work for log functions and pow().
                     26: / Passed args x, y on the NDP stack,
                     27: / it pops both and returns y * log base 2 of x on the NDP stacktop %st.
                     28: /
                     29: / Useful identity:
                     30: /       log base n of x = log base n of 2 * log base 2 of x.
                     31: / Uses fyl2x, which requires x > 0.
                     32: //////////
                     33: 
                     34: x      =       RASIZE          / arg offset
                     35: 
                     36: log10:
                     37:        fldlg2                  / Load y = log base 10 of 2.
                     38:        jmp     .L1
                     39: 
                     40: log:
                     41:        fldln2                  / Load y = log base e of 2.
                     42: 
                     43: .L1:
                     44:        fldl    x(%esp)         / Load argument x.
                     45: 
                     46: _ylog2x:                       / x, y
                     47:        call    _tstcc          / Check sign of x.
                     48:        ja      ?2              / x > 0., ok.
                     49:        fstp    %st             / x <= 0, pop y.
                     50:        jmp     _edomain        / Issue EDOM error and return 0.
                     51: 
                     52: ?2:
                     53: //////////
                     54: / The code below uses
                     55: /      fyl2x   if d <= 1 or d >= 2-sqrt(2)/2,
                     56: /      fyl2xp1 if 1 < d < 2-sqrt(2)/2.
                     57: / Since the precision fyl2xp1 purports to save is already lost,
                     58: / this appears to make no difference in the result.
                     59: / The code is commented out for now and should be removed eventually.
                     60: /      fdcom   near1
                     61: /      call    _cfcc           / Compare d to 2+sqrt(2)/2.
                     62: /      jae     ?4              / d >= 2+sqrt(2)/2, use fyl2x.
                     63: /      fld1                    / Load 1.
                     64: /      fcom
                     65: /      call    _cfcc           / Compare 1 to d.
                     66: /      jae     ?3              / 1 >= d, use fyl2x.
                     67: /      fsub                    / d = d-1 and pop off the 1.
                     68: /      fyl2xp1                 / result = y * log base 2 of d+1.
                     69: /      ret
                     70: /
                     71: /?3:   fstp    %st             / Pop off the 1.
                     72: /
                     73: /?4:
                     74: //////////
                     75:        fyl2x                   / result = y * log base 2 of x.
                     76:        ret
                     77: 
                     78: //////////
                     79: / Commented out as above...
                     80: /near?1:       .byte   0x1A, 0x62, 0xC0, 0xCC, 0xB0, 0xAF, 0xF4, 0x3F  / 2 - sqrt(2)/2
                     81: //////////
                     82: 
                     83: / end of log87.s

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.