1 | // |
---|
2 | // $Id$ |
---|
3 | // |
---|
4 | // satanh.sa 3.3 12/19/90 |
---|
5 | // |
---|
6 | // The entry point satanh computes the inverse |
---|
7 | // hyperbolic tangent of |
---|
8 | // an input argument; satanhd does the same except for denormalized |
---|
9 | // input. |
---|
10 | // |
---|
11 | // Input: Double-extended number X in location pointed to |
---|
12 | // by address register a0. |
---|
13 | // |
---|
14 | // Output: The value arctanh(X) returned in floating-point register Fp0. |
---|
15 | // |
---|
16 | // Accuracy and Monotonicity: The returned result is within 3 ulps in |
---|
17 | // 64 significant bit, i.e. within 0.5001 ulp to 53 bits if the |
---|
18 | // result is subsequently rounded to double precision. The |
---|
19 | // result is provably monotonic in double precision. |
---|
20 | // |
---|
21 | // Speed: The program satanh takes approximately 270 cycles. |
---|
22 | // |
---|
23 | // Algorithm: |
---|
24 | // |
---|
25 | // ATANH |
---|
26 | // 1. If |X| >= 1, go to 3. |
---|
27 | // |
---|
28 | // 2. (|X| < 1) Calculate atanh(X) by |
---|
29 | // sgn := sign(X) |
---|
30 | // y := |X| |
---|
31 | // z := 2y/(1-y) |
---|
32 | // atanh(X) := sgn * (1/2) * logp1(z) |
---|
33 | // Exit. |
---|
34 | // |
---|
35 | // 3. If |X| > 1, go to 5. |
---|
36 | // |
---|
37 | // 4. (|X| = 1) Generate infinity with an appropriate sign and |
---|
38 | // divide-by-zero by |
---|
39 | // sgn := sign(X) |
---|
40 | // atan(X) := sgn / (+0). |
---|
41 | // Exit. |
---|
42 | // |
---|
43 | // 5. (|X| > 1) Generate an invalid operation by 0 * infinity. |
---|
44 | // Exit. |
---|
45 | // |
---|
46 | |
---|
47 | // Copyright (C) Motorola, Inc. 1990 |
---|
48 | // All Rights Reserved |
---|
49 | // |
---|
50 | // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA |
---|
51 | // The copyright notice above does not evidence any |
---|
52 | // actual or intended publication of such source code. |
---|
53 | |
---|
54 | //satanh idnt 2,1 | Motorola 040 Floating Point Software Package |
---|
55 | |
---|
56 | |section 8 |
---|
57 | |
---|
58 | |xref t_dz |
---|
59 | |xref t_operr |
---|
60 | |xref t_frcinx |
---|
61 | |xref t_extdnrm |
---|
62 | |xref slognp1 |
---|
63 | |
---|
64 | .global satanhd |
---|
65 | satanhd: |
---|
66 | //--ATANH(X) = X FOR DENORMALIZED X |
---|
67 | |
---|
68 | bra t_extdnrm |
---|
69 | |
---|
70 | .global satanh |
---|
71 | satanh: |
---|
72 | movel (%a0),%d0 |
---|
73 | movew 4(%a0),%d0 |
---|
74 | andil #0x7FFFFFFF,%d0 |
---|
75 | cmpil #0x3FFF8000,%d0 |
---|
76 | bges ATANHBIG |
---|
77 | |
---|
78 | //--THIS IS THE USUAL CASE, |X| < 1 |
---|
79 | //--Y = |X|, Z = 2Y/(1-Y), ATANH(X) = SIGN(X) * (1/2) * LOG1P(Z). |
---|
80 | |
---|
81 | fabsx (%a0),%fp0 // ...Y = |X| |
---|
82 | fmovex %fp0,%fp1 |
---|
83 | fnegx %fp1 // ...-Y |
---|
84 | faddx %fp0,%fp0 // ...2Y |
---|
85 | fadds #0x3F800000,%fp1 // ...1-Y |
---|
86 | fdivx %fp1,%fp0 // ...2Y/(1-Y) |
---|
87 | movel (%a0),%d0 |
---|
88 | andil #0x80000000,%d0 |
---|
89 | oril #0x3F000000,%d0 // ...SIGN(X)*HALF |
---|
90 | movel %d0,-(%sp) |
---|
91 | |
---|
92 | fmovemx %fp0-%fp0,(%a0) // ...overwrite input |
---|
93 | movel %d1,-(%sp) |
---|
94 | clrl %d1 |
---|
95 | bsr slognp1 // ...LOG1P(Z) |
---|
96 | fmovel (%sp)+,%fpcr |
---|
97 | fmuls (%sp)+,%fp0 |
---|
98 | bra t_frcinx |
---|
99 | |
---|
100 | ATANHBIG: |
---|
101 | fabsx (%a0),%fp0 // ...|X| |
---|
102 | fcmps #0x3F800000,%fp0 |
---|
103 | fbgt t_operr |
---|
104 | bra t_dz |
---|
105 | |
---|
106 | |end |
---|