[BACK]Return to satanh.sa CVS log [TXT][DIR] Up to [local] / sys / arch / m68k / fpsp

Annotation of sys/arch/m68k/fpsp/satanh.sa, Revision 1.1.1.1

1.1       nbrk        1: *      $OpenBSD: satanh.sa,v 1.2 1996/05/29 21:05:35 niklas Exp $
                      2: *      $NetBSD: satanh.sa,v 1.2 1994/10/26 07:49:33 cgd Exp $
                      3:
                      4: *      MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
                      5: *      M68000 Hi-Performance Microprocessor Division
                      6: *      M68040 Software Package
                      7: *
                      8: *      M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
                      9: *      All rights reserved.
                     10: *
                     11: *      THE SOFTWARE is provided on an "AS IS" basis and without warranty.
                     12: *      To the maximum extent permitted by applicable law,
                     13: *      MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
                     14: *      INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
                     15: *      PARTICULAR PURPOSE and any warranty against infringement with
                     16: *      regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
                     17: *      and any accompanying written materials.
                     18: *
                     19: *      To the maximum extent permitted by applicable law,
                     20: *      IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
                     21: *      (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
                     22: *      PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
                     23: *      OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
                     24: *      SOFTWARE.  Motorola assumes no responsibility for the maintenance
                     25: *      and support of the SOFTWARE.
                     26: *
                     27: *      You are hereby granted a copyright license to use, modify, and
                     28: *      distribute the SOFTWARE so long as this entire notice is retained
                     29: *      without alteration in any modified and/or redistributed versions,
                     30: *      and that such modified versions are clearly identified as such.
                     31: *      No licenses are granted by implication, estoppel or otherwise
                     32: *      under any patents or trademarks of Motorola, Inc.
                     33:
                     34: *
                     35: *      satanh.sa 3.3 12/19/90
                     36: *
                     37: *      The entry point satanh computes the inverse
                     38: *      hyperbolic tangent of
                     39: *      an input argument; satanhd does the same except for denormalized
                     40: *      input.
                     41: *
                     42: *      Input: Double-extended number X in location pointed to
                     43: *              by address register a0.
                     44: *
                     45: *      Output: The value arctanh(X) returned in floating-point register Fp0.
                     46: *
                     47: *      Accuracy and Monotonicity: The returned result is within 3 ulps in
                     48: *              64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
                     49: *              result is subsequently rounded to double precision. The
                     50: *              result is provably monotonic in double precision.
                     51: *
                     52: *      Speed: The program satanh takes approximately 270 cycles.
                     53: *
                     54: *      Algorithm:
                     55: *
                     56: *      ATANH
                     57: *      1. If |X| >= 1, go to 3.
                     58: *
                     59: *      2. (|X| < 1) Calculate atanh(X) by
                     60: *              sgn := sign(X)
                     61: *              y := |X|
                     62: *              z := 2y/(1-y)
                     63: *              atanh(X) := sgn * (1/2) * logp1(z)
                     64: *              Exit.
                     65: *
                     66: *      3. If |X| > 1, go to 5.
                     67: *
                     68: *      4. (|X| = 1) Generate infinity with an appropriate sign and
                     69: *              divide-by-zero by
                     70: *              sgn := sign(X)
                     71: *              atan(X) := sgn / (+0).
                     72: *              Exit.
                     73: *
                     74: *      5. (|X| > 1) Generate an invalid operation by 0 * infinity.
                     75: *              Exit.
                     76: *
                     77:
                     78: satanh IDNT    2,1 Motorola 040 Floating Point Software Package
                     79:
                     80:        section 8
                     81:
                     82:        xref    t_dz
                     83:        xref    t_operr
                     84:        xref    t_frcinx
                     85:        xref    t_extdnrm
                     86:        xref    slognp1
                     87:
                     88:        xdef    satanhd
                     89: satanhd:
                     90: *--ATANH(X) = X FOR DENORMALIZED X
                     91:
                     92:        bra             t_extdnrm
                     93:
                     94:        xdef    satanh
                     95: satanh:
                     96:        move.l          (a0),d0
                     97:        move.w          4(a0),d0
                     98:        ANDI.L          #$7FFFFFFF,D0
                     99:        CMPI.L          #$3FFF8000,D0
                    100:        BGE.B           ATANHBIG
                    101:
                    102: *--THIS IS THE USUAL CASE, |X| < 1
                    103: *--Y = |X|, Z = 2Y/(1-Y), ATANH(X) = SIGN(X) * (1/2) * LOG1P(Z).
                    104:
                    105:        FABS.X          (a0),FP0        ...Y = |X|
                    106:        FMOVE.X         FP0,FP1
                    107:        FNEG.X          FP1             ...-Y
                    108:        FADD.X          FP0,FP0         ...2Y
                    109:        FADD.S          #:3F800000,FP1  ...1-Y
                    110:        FDIV.X          FP1,FP0         ...2Y/(1-Y)
                    111:        move.l          (a0),d0
                    112:        ANDI.L          #$80000000,D0
                    113:        ORI.L           #$3F000000,D0   ...SIGN(X)*HALF
                    114:        move.l          d0,-(sp)
                    115:
                    116:        fmovem.x        fp0,(a0)        ...overwrite input
                    117:        move.l          d1,-(sp)
                    118:        clr.l           d1
                    119:        bsr             slognp1         ...LOG1P(Z)
                    120:        fmove.l         (sp)+,fpcr
                    121:        FMUL.S          (sp)+,FP0
                    122:        bra             t_frcinx
                    123:
                    124: ATANHBIG:
                    125:        FABS.X          (a0),FP0        ...|X|
                    126:        FCMP.S          #:3F800000,FP0
                    127:        fbgt            t_operr
                    128:        bra             t_dz
                    129:
                    130:        end

CVSweb