Annotation of 43BSD/usr.lib/liboldnm/tanh.s, revision 1.1.1.1

1.1       root        1: #
                      2: # Copyright (c) 1980 Regents of the University of California.
                      3: # All rights reserved.  The Berkeley software License Agreement
                      4: # specifies the terms and conditions for redistribution.
                      5: #
                      6: #      @(#)tanh.s      5.1 (Berkeley) 5/8/85
                      7: # 
                      8: #
                      9: # double tanh(arg)
                     10: # double arg
                     11: # method: tanh(arg)=sinh(arg)/cosh(arg); if |arg|<0.5 sinh(9 is computed from
                     12: # a polynomial approx otherwise from exp().
                     13: # Only 1 call to exp() is made.
                     14: # J F Jarvis, August 17, 1978
                     15: .globl _tanh
                     16: .globl _exp
                     17: .text
                     18: .align 1
                     19: _tanh:
                     20:        .word   0x07c0
                     21:        bispsw  $0xe0
                     22:        clrl    r10     # sign bit
                     23:        movd    4(ap),r6
                     24:        jgeq    t1
                     25:        movw    $0x8000,r10
                     26:        xorw2   r10,r6  # co|arg|
                     27: t1:    cmpd    r6,$0d2.0e+1
                     28:        jleq    t2
                     29:        movd    $0d1.0e+0,r0
                     30:        xorw2   r10,r0
                     31:        ret
                     32: t2:    movd    r6,-(sp)
                     33:        calls   $2,_exp
                     34:        movd    r0,r8
                     35:        divd3   r8,$0d1.0e+0,-(sp)      # exp(-|arg|)
                     36:        cmpd    r6,$0d0.5e+0
                     37:        jgeq    t3
                     38:        muld3   r6,r6,r0        # |arg|<0.5, sinh() from poly approx
                     39:        polyd   r0,$5,pcoef
                     40:        muld2   r6,r0
                     41:        muld2   $0d2.0e+0,r0    
                     42:        jbr     t4
                     43: t3:    subd3   (sp),r8,r0
                     44: t4:                            # r0,1 = 2*sinh(|arg|)
                     45:        addd3   (sp),r8,r2      # r2,3 = cosh(|arg|);
                     46:        divd2   r2,r0   # r0,1 = tanh(|arg|)
                     47:        xorw2   r10,r0  # r0,1 = tanh(arg)
                     48:        ret
                     49: .data
                     50: .align 2
                     51: pcoef:
                     52:        .double 0d0.251726188251e-7
                     53:        .double 0d0.275569807356154e-5
                     54:        .double 0d0.1984127027907999e-3
                     55:        .double 0d0.833333333307759961e-2
                     56:        .double 0d0.16666666666667212324e+0
                     57:        .double 0d0.99999999999999998116e+0

unix.superglobalmegacorp.com

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