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