Annotation of coherent/b/lib/libm/i8087/tanh87.m, revision 1.1.1.1

1.1       root        1: //////////
                      2: / libm 8087
                      3: / tanh(d)
                      4: //////////
                      5: 
                      6: #include "larges.h"
                      7: #include "ifno8087.h"
                      8: 
                      9:        .globl  tanh_
                     10:        .globl  exp
                     11:        .globl  tstcc
                     12: 
                     13: //////////
                     14: / double
                     15: / tanh(d)
                     16: / double d;
                     17: /
                     18: / tanh(d) = (exp(d) - exp(-d)) / (exp(d) + exp(-d))
                     19: /        = (1 - exp(-2 * d)) / (1 + exp(-2 * d))       (used for d > 0)
                     20: /        = - (1 - exp(2 * d)) / (1 + exp(2 * d))       (used for d < 0)
                     21: //////////
                     22: 
                     23: d      =       RASIZE          / arg offset
                     24: 
                     25: tanh_:
                     26:        ifno8087(_tanh_)
                     27:        mov     bx, sp
                     28:        fdld    Pss d(bx)       / Load argument d.
                     29: 
                     30:        Gcall   tstcc           / Check sign of d.
                     31:        je      1f              / d is zero, just return it.
                     32:        jb      0f              / Jump if negative.
                     33:        fchs                    / Change positive to negative.
                     34: 
                     35: 0:     pushf                   / Save the flags.
                     36:        fadd    st, st          / 2 * d
                     37:        Gcall   exp             / exp(2 * d)
                     38:        fld1                    / 1, exp(2 * d)
                     39:        fsub    st, st1         / 1 - exp(2 * d), exp(2 * d)
                     40:        fld1                    / 1, 1 - exp(2 * d), exp(2 * d)
                     41:        faddp   st2, st         / 1 - exp(2 * d), 1 + exp(2 * d)
                     42:        fdivr                   / (1 -  exp(2 * d)) / (1 + exp(2 * d))
                     43:        popf                    / Restore the flags.
                     44:        ja      1f              / d was positive, done.
                     45:        fchs                    / d was negative, flip result sign.
                     46: 
                     47: 1:     Gret

unix.superglobalmegacorp.com

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