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