Annotation of coherent/b/lib/libm/i387/exp87.s, revision 1.1

1.1     ! root        1: //////////
        !             2: / /usr/src/libm/i387/exp87.s
        !             3: / i387 mathematics library
        !             4: / exp(d), _two()
        !             5: //////////
        !             6: 
        !             7: RASIZE =       4
        !             8: 
        !             9:        .globl  exp
        !            10:        .globl  _exp
        !            11:        .globl  _two
        !            12:        .globl  _floor
        !            13:        .globl  _cfcc
        !            14:        .globl  _erange
        !            15: 
        !            16: //////////
        !            17: / double
        !            18: / exp(d)
        !            19: / double d;
        !            20: /
        !            21: / _exp() takes d on the NDP stacktop %st and returns exp(d).
        !            22: / Uses: exp(x) = 2 ^ (x * log base 2 of e).
        !            23: /
        !            24: / _two() takes d on the NDP stacktop %st and returns 2^d.
        !            25: //////////
        !            26: 
        !            27: d      =       RASIZE          / arg offset
        !            28: 
        !            29: exp:
        !            30:        fldl    d(%esp)         / Load argument d.
        !            31: 
        !            32: _exp:                          / d
        !            33:        fldl2e                  / Load log base 2 of e.
        !            34:        fmul                    / d * log base 2 of e
        !            35: 
        !            36: _two:
        !            37:        ficoms  maxexp
        !            38:        call    _cfcc           / Compare d to max exponent.
        !            39:        jbe     ?1              / d is not too big.
        !            40:        fstp    %st             / Too big, pop d.
        !            41:        call    _erange         / Set errno to indicate out of range
        !            42:        fldl    infin           / and return infinity.
        !            43:        ret
        !            44: 
        !            45: ?1:
        !            46:        ficoms  minexp
        !            47:        call    _cfcc           / Compare d to min exponent.
        !            48:        jae     ?2              / d is not too small.
        !            49:        fstp    %st             / Too small, pop d
        !            50:        fldz                    / and return 0.
        !            51:        ret
        !            52: 
        !            53: ?2:
        !            54:        fld     %st             / d, d
        !            55:        call    _floor          / Round d down to int(d), d
        !            56:        fst     %st(2)          / int(d), d, int(d)
        !            57:        fsubr                   / d-int(d) = fraction(d), int(d)
        !            58:        fcoml   half
        !            59:        call    _cfcc           / Compare fraction(d) to .5
        !            60:        jbe     ?3              / fraction(d) <= .5, ok.
        !            61:        fsubl   half            / Set fraction(d) -= .5.
        !            62: 
        !            63: ?3:
        !            64:        f2xm1                   / 2^fraction(d) - 1
        !            65:        fld1
        !            66:        fadd                    / 2^fraction(d)
        !            67:        jbe     ?4              / Was not >.5, ok as is.
        !            68:        fmull   sqrt2           / 2^fr(d) = 2^(fr(d)-.5) * 2^.5
        !            69: 
        !            70: ?4:
        !            71:        fscale                  / Scale in the integer part
        !            72:        fstp    %st(1)          / and pop, leaving result.
        !            73:        ret
        !            74: 
        !            75: //////////
        !            76: / Data.
        !            77: //////////
        !            78: sqrt2: .byte   0xCD, 0x3B, 0x7F, 0x66, 0x9E, 0xA0, 0xF6, 0x3F  / sqrt(2.)
        !            79: infin: .byte   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F  / infinity
        !            80: half:  .byte   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x3F  / .5
        !            81: maxexp:        .word   1023            / maximum exponent
        !            82: minexp:        .word   -1022           / minimum exponent
        !            83: 
        !            84: / end of exp87.s

unix.superglobalmegacorp.com

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