1 * $NetBSD: ssinh.sa,v 1.3 1994/10/26 07:50:05 cgd Exp $
3 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4 * M68000 Hi-Performance Microprocessor Division
5 * M68040 Software Package
7 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
10 * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
11 * To the maximum extent permitted by applicable law,
12 * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
13 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
14 * PARTICULAR PURPOSE and any warranty against infringement with
15 * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
16 * and any accompanying written materials.
18 * To the maximum extent permitted by applicable law,
19 * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
20 * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
21 * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
22 * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
23 * SOFTWARE. Motorola assumes no responsibility for the maintenance
24 * and support of the SOFTWARE.
26 * You are hereby granted a copyright license to use, modify, and
27 * distribute the SOFTWARE so long as this entire notice is retained
28 * without alteration in any modified and/or redistributed versions,
29 * and that such modified versions are clearly identified as such.
30 * No licenses are granted by implication, estoppel or otherwise
31 * under any patents or trademarks of Motorola, Inc.
34 * ssinh.sa 3.1 12/10/90
36 * The entry point sSinh computes the hyperbolic sine of
37 * an input argument; sSinhd does the same except for denormalized
40 * Input: Double-extended number X in location pointed to
41 * by address register a0.
43 * Output: The value sinh(X) returned in floating-point register Fp0.
45 * Accuracy and Monotonicity: The returned result is within 3 ulps in
46 * 64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
47 * result is subsequently rounded to double precision. The
48 * result is provably monotonic in double precision.
50 * Speed: The program sSINH takes approximately 280 cycles.
55 * 1. If |X| > 16380 log2, go to 3.
57 * 2. (|X| <= 16380 log2) Sinh(X) is obtained by the formulae
58 * y = |X|, sgn = sign(X), and z = expm1(Y),
59 * sinh(X) = sgn*(1/2)*( z + z/(1+z) ).
62 * 3. If |X| > 16480 log2, go to 5.
64 * 4. (16380 log2 < |X| <= 16480 log2)
65 * sinh(X) = sign(X) * exp(|X|)/2.
66 * However, invoking exp(|X|) may cause premature overflow.
67 * Thus, we calculate sinh(X) as follows:
70 * sgnFact := sgn * 2**(16380)
71 * Y' := Y - 16381 log2
72 * sinh(X) := sgnFact * exp(Y').
75 * 5. (|X| > 16480 log2) sinh(X) must overflow. Return
76 * sign(X)*Huge*Huge to generate overflow and an infinity with
77 * the appropriate sign. Huge is the largest finite number in
78 * extended format. Exit.
81 SSINH IDNT 2,1 Motorola 040 Floating Point Software Package
85 T1 DC.L $40C62D38,$D3D64634 ... 16381 LOG2 LEAD
86 T2 DC.L $3D6F90AE,$B1E75CC7 ... 16381 LOG2 TRAIL
96 *--SINH(X) = X FOR DENORMALIZED X
102 FMOVE.x (a0),FP0 ...LOAD INPUT
106 move.l d0,a1 save a copy of original (compacted) operand
111 *--THIS IS THE USUAL CASE, |X| < 16380 LOG2
112 *--Y = |X|, Z = EXPM1(Y), SINH(X) = SIGN(X)*(1/2)*( Z + Z/(1+Z) )
114 FABS.X FP0 ...Y = |X|
119 bsr setoxm1 ...FP0 IS Z = EXPM1(Y)
124 FADD.S #:3F800000,FP1 ...1+Z
126 FDIV.X FP1,FP0 ...Z/(1+Z)
134 fmul.s (sp)+,fp0 ;last fp inst - possible exceptions set
142 FSUB.D T1(pc),FP0 ...(|X|-16381LOG2_LEAD)
144 move.l #$80000000,-(sp)
148 MOVE.L D0,-(sp) ...EXTENDED FMT
149 FSUB.D T2(pc),FP0 ...|X| - 16381 LOG2, ACCURATE
157 fmul.x (sp)+,fp0 ;possible exception