ssinh.sa revision 1.2 1 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
2 * M68000 Hi-Performance Microprocessor Division
3 * M68040 Software Package
4 *
5 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
6 * All rights reserved.
7 *
8 * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
9 * To the maximum extent permitted by applicable law,
10 * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
11 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
12 * PARTICULAR PURPOSE and any warranty against infringement with
13 * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
14 * and any accompanying written materials.
15 *
16 * To the maximum extent permitted by applicable law,
17 * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
18 * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
19 * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
20 * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
21 * SOFTWARE. Motorola assumes no responsibility for the maintenance
22 * and support of the SOFTWARE.
23 *
24 * You are hereby granted a copyright license to use, modify, and
25 * distribute the SOFTWARE so long as this entire notice is retained
26 * without alteration in any modified and/or redistributed versions,
27 * and that such modified versions are clearly identified as such.
28 * No licenses are granted by implication, estoppel or otherwise
29 * under any patents or trademarks of Motorola, Inc.
30
31 *
32 * ssinh.sa 3.1 12/10/90
33 *
34 * The entry point sSinh computes the hyperbolic sine of
35 * an input argument; sSinhd does the same except for denormalized
36 * input.
37 *
38 * Input: Double-extended number X in location pointed to
39 * by address register a0.
40 *
41 * Output: The value sinh(X) returned in floating-point register Fp0.
42 *
43 * Accuracy and Monotonicity: The returned result is within 3 ulps in
44 * 64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
45 * result is subsequently rounded to double precision. The
46 * result is provably monotonic in double precision.
47 *
48 * Speed: The program sSINH takes approximately 280 cycles.
49 *
50 * Algorithm:
51 *
52 * SINH
53 * 1. If |X| > 16380 log2, go to 3.
54 *
55 * 2. (|X| <= 16380 log2) Sinh(X) is obtained by the formulae
56 * y = |X|, sgn = sign(X), and z = expm1(Y),
57 * sinh(X) = sgn*(1/2)*( z + z/(1+z) ).
58 * Exit.
59 *
60 * 3. If |X| > 16480 log2, go to 5.
61 *
62 * 4. (16380 log2 < |X| <= 16480 log2)
63 * sinh(X) = sign(X) * exp(|X|)/2.
64 * However, invoking exp(|X|) may cause premature overflow.
65 * Thus, we calculate sinh(X) as follows:
66 * Y := |X|
67 * sgn := sign(X)
68 * sgnFact := sgn * 2**(16380)
69 * Y' := Y - 16381 log2
70 * sinh(X) := sgnFact * exp(Y').
71 * Exit.
72 *
73 * 5. (|X| > 16480 log2) sinh(X) must overflow. Return
74 * sign(X)*Huge*Huge to generate overflow and an infinity with
75 * the appropriate sign. Huge is the largest finite number in
76 * extended format. Exit.
77 *
78
79 SSINH IDNT 2,1 Motorola 040 Floating Point Software Package
80
81 section 8
82
83 T1 DC.L $40C62D38,$D3D64634 ... 16381 LOG2 LEAD
84 T2 DC.L $3D6F90AE,$B1E75CC7 ... 16381 LOG2 TRAIL
85
86 xref t_frcinx
87 xref t_ovfl
88 xref t_extdnrm
89 xref setox
90 xref setoxm1
91
92 xdef ssinhd
93 ssinhd:
94 *--SINH(X) = X FOR DENORMALIZED X
95
96 bra t_extdnrm
97
98 xdef ssinh
99 ssinh:
100 FMOVE.x (a0),FP0 ...LOAD INPUT
101
102 move.l (a0),d0
103 move.w 4(a0),d0
104 move.l d0,a1 save a copy of original (compacted) operand
105 AND.L #$7FFFFFFF,D0
106 CMP.L #$400CB167,D0
107 BGT.B SINHBIG
108
109 *--THIS IS THE USUAL CASE, |X| < 16380 LOG2
110 *--Y = |X|, Z = EXPM1(Y), SINH(X) = SIGN(X)*(1/2)*( Z + Z/(1+Z) )
111
112 FABS.X FP0 ...Y = |X|
113
114 movem.l a1/d1,-(sp)
115 fmovem.x fp0,(a0)
116 clr.l d1
117 bsr setoxm1 ...FP0 IS Z = EXPM1(Y)
118 fmove.l #0,fpcr
119 movem.l (sp)+,a1/d1
120
121 FMOVE.X FP0,FP1
122 FADD.S #:3F800000,FP1 ...1+Z
123 FMOVE.X FP0,-(sp)
124 FDIV.X FP1,FP0 ...Z/(1+Z)
125 MOVE.L a1,d0
126 AND.L #$80000000,D0
127 OR.L #$3F000000,D0
128 FADD.X (sp)+,FP0
129 MOVE.L D0,-(sp)
130
131 fmove.l d1,fpcr
132 fmul.s (sp)+,fp0 ;last fp inst - possible exceptions set
133
134 bra t_frcinx
135
136 SINHBIG:
137 cmp.l #$400CB2B3,D0
138 bgt t_ovfl
139 FABS.X FP0
140 FSUB.D T1(pc),FP0 ...(|X|-16381LOG2_LEAD)
141 clr.l -(sp)
142 move.l #$80000000,-(sp)
143 move.l a1,d0
144 AND.L #$80000000,D0
145 OR.L #$7FFB0000,D0
146 MOVE.L D0,-(sp) ...EXTENDED FMT
147 FSUB.D T2(pc),FP0 ...|X| - 16381 LOG2, ACCURATE
148
149 move.l d1,-(sp)
150 clr.l d1
151 fmovem.x fp0,(a0)
152 bsr setox
153 fmove.l (sp)+,fpcr
154
155 fmul.x (sp)+,fp0 ;possible exception
156 bra t_frcinx
157
158 end
159