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 * scosh.sa 3.1 12/10/90
36 * The entry point sCosh computes the hyperbolic cosine of
37 * an input argument; sCoshd 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 cosh(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 sCOSH takes approximately 250 cycles.
55 * 1. If |X| > 16380 log2, go to 3.
57 * 2. (|X| <= 16380 log2) Cosh(X) is obtained by the formulae
58 * y = |X|, z = exp(Y), and
59 * cosh(X) = (1/2)*( z + 1/z ).
62 * 3. (|X| > 16380 log2). If |X| > 16480 log2, go to 5.
64 * 4. (16380 log2 < |X| <= 16480 log2)
65 * cosh(X) = sign(X) * exp(|X|)/2.
66 * However, invoking exp(|X|) may cause premature overflow.
67 * Thus, we calculate sinh(X) as follows:
70 * Y' := Y - 16381 log2
71 * cosh(X) := Fact * exp(Y').
74 * 5. (|X| > 16480 log2) sinh(X) must overflow. Return
75 * Huge*Huge to generate overflow and an infinity with
76 * the appropriate sign. Huge is the largest finite number in
77 * extended format. Exit.
80 SCOSH IDNT 2,1 Motorola 040 Floating Point Software Package
88 T1 DC.L $40C62D38,$D3D64634 ... 16381 LOG2 LEAD
89 T2 DC.L $3D6F90AE,$B1E75CC7 ... 16381 LOG2 TRAIL
91 TWO16380 DC.L $7FFB0000,$80000000,$00000000,$00000000
95 *--COSH(X) = 1 FOR DENORMALIZED X
97 FMOVE.S #:3F800000,FP0
100 FADD.S #:00800000,FP0
105 FMOVE.X (a0),FP0 ...LOAD INPUT
113 *--THIS IS THE USUAL CASE, |X| < 16380 LOG2
114 *--COSH(X) = (1/2) * ( EXP(X) + 1/EXP(X) )
120 fmovem.x fp0,(a0) ;pass parameter to setox
121 bsr setox ...FP0 IS EXP(|X|)
122 FMUL.S #:3F000000,FP0 ...(1/2)EXP(|X|)
125 FMOVE.S #:3E800000,FP1 ...(1/4)
126 FDIV.X FP0,FP1 ...1/(2 EXP(|X|))
138 FSUB.D T1(pc),FP0 ...(|X|-16381LOG2_LEAD)
139 FSUB.D T2(pc),FP0 ...|X| - 16381 LOG2, ACCURATE
147 FMUL.X TWO16380(pc),FP0
151 fmove.l #0,fpsr ;clr N bit if set by source
152 bclr.b #7,(a0) ;always return positive value