Annotation of coherent/b/lib/libm/i8087/exp87.m, revision 1.1

1.1     ! root        1: //////////
        !             2: / libm 8087
        !             3: / exp(d), two()
        !             4: //////////
        !             5: 
        !             6: #include "larges.h"
        !             7: #include "ifno8087.h"
        !             8: 
        !             9:        .globl  exp_
        !            10:        .globl  exp
        !            11:        .globl  two
        !            12:        .globl  floor
        !            13:        .globl  cfcc87
        !            14:        .globl  erange
        !            15: 
        !            16: //////////
        !            17: / double
        !            18: / exp(d)
        !            19: / double d;
        !            20: /
        !            21: / exp() is passed d on the 8087 stack and returns exp(d).
        !            22: / Uses: exp(x) = 2 ^ (x * log base 2 of e).
        !            23: /
        !            24: / two() is passed d on the 8087 stack and returns 2^d.
        !            25: //////////
        !            26: 
        !            27: d      =       RASIZE          / arg offset
        !            28: 
        !            29: exp_:
        !            30:        ifno8087(_exp_)
        !            31:        mov     bx, sp
        !            32:        fdld    Pss d(bx)       / Load argument d.
        !            33: 
        !            34: exp:                           / d
        !            35:        fldl2e                  / Load log base 2 of e.
        !            36:        fmul                    / d * log base 2 of e
        !            37: 
        !            38: two:
        !            39:        ficom   cs:maxexp
        !            40:        Gcall   cfcc87          / Compare d to max exponent.
        !            41:        jbe     1f              / d is not too big.
        !            42:        fstp    st              / Too big, pop d.
        !            43:        Gcall   erange          / Set errno to indicate out of range
        !            44:        fdld    cs:infin        / and return infinity.
        !            45:        Gret
        !            46: 
        !            47: 1:     ficom   cs:minexp
        !            48:        Gcall   cfcc87          / Compare d to min exponent.
        !            49:        jae     2f              / d is not too small.
        !            50:        fstp    st              / Too small, pop d
        !            51:        fldz                    / and return 0.
        !            52:        Gret
        !            53: 
        !            54: 2:     fld     st              / d, d
        !            55:        Gcall   floor           / Round d down to int(d), d
        !            56:        fst     st2             / int(d), d, int(d)
        !            57:        fsub                    / d-int(d) = fraction(d), int(d)
        !            58:        fdcom   cs:half
        !            59:        Gcall   cfcc87          / Compare fraction(d) to .5
        !            60:        jbe     3f              / fraction(d) <= .5, ok.
        !            61:        fdsub   cs:half         / Set fraction(d) -= .5.
        !            62: 
        !            63: 3:     f2xm1                   / 2^fraction(d) - 1
        !            64:        fld1
        !            65:        fadd                    / 2^fraction(d)
        !            66:        jbe     4f              / Was not >.5, ok as is.
        !            67:        fdmul   cs:sqrt2        / 2^fr(d) = 2^(fr(d)-.5) * 2^.5
        !            68: 
        !            69: 4:     fscale                  / Scale in the integer part
        !            70:        fstp    st1             / and pop, leaving result.
        !            71:        Gret
        !            72: 
        !            73: //////////
        !            74: / data
        !            75: //////////
        !            76: sqrt2: .byte   0xCD, 0x3B, 0x7F, 0x66, 0x9E, 0xA0, 0xF6, 0x3F  / sqrt(2.)
        !            77: infin: .byte   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F  / infinity
        !            78: half:  .byte   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x3F  / .5
        !            79: maxexp:        .word   1023    / maximum exponent
        !            80: minexp:        .word   -1022   / minimum exponent

unix.superglobalmegacorp.com

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