2 | scosh.sa 3.1 12/10/90
4 | The entry point sCosh computes the hyperbolic cosine of
5 | an input argument; sCoshd does the same except for denormalized
8 | Input: Double-extended number X in location pointed to
9 | by address register a0.
11 | Output: The value cosh(X) returned in floating-point register Fp0.
13 | Accuracy and Monotonicity: The returned result is within 3 ulps in
14 | 64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
15 | result is subsequently rounded to double precision. The
16 | result is provably monotonic in double precision.
18 | Speed: The program sCOSH takes approximately 250 cycles.
23 | 1. If |X| > 16380 log2, go to 3.
25 | 2. (|X| <= 16380 log2) Cosh(X) is obtained by the formulae
26 | y = |X|, z = exp(Y), and
27 | cosh(X) = (1/2)*( z + 1/z ).
30 | 3. (|X| > 16380 log2). If |X| > 16480 log2, go to 5.
32 | 4. (16380 log2 < |X| <= 16480 log2)
33 | cosh(X) = sign(X) * exp(|X|)/2.
34 | However, invoking exp(|X|) may cause premature overflow.
35 | Thus, we calculate sinh(X) as follows:
38 | Y' := Y - 16381 log2
39 | cosh(X) := Fact * exp(Y').
42 | 5. (|X| > 16480 log2) sinh(X) must overflow. Return
43 | Huge*Huge to generate overflow and an infinity with
44 | the appropriate sign. Huge is the largest finite number in
45 | extended format. Exit.
49 | Copyright (C) Motorola, Inc. 1990
52 | For details on the license for this file, please see the
53 | file, README, in this same directory.
55 |SCOSH idnt 2,1 | Motorola 040 Floating Point Software Package
63 T1: .long 0x40C62D38,0xD3D64634 | ... 16381 LOG2 LEAD
64 T2: .long 0x3D6F90AE,0xB1E75CC7 | ... 16381 LOG2 TRAIL
66 TWO16380: .long 0x7FFB0000,0x80000000,0x00000000,0x00000000
70 |--COSH(X) = 1 FOR DENORMALIZED X
72 fmoves #0x3F800000,%fp0
75 fadds #0x00800000,%fp0
80 fmovex (%a0),%fp0 | ...LOAD INPUT
88 |--THIS IS THE USUAL CASE, |X| < 16380 LOG2
89 |--COSH(X) = (1/2) * ( EXP(X) + 1/EXP(X) )
95 fmovemx %fp0-%fp0,(%a0) |pass parameter to setox
96 bsr setox | ...FP0 IS EXP(|X|)
97 fmuls #0x3F000000,%fp0 | ...(1/2)EXP(|X|)
100 fmoves #0x3E800000,%fp1 | ...(1/4)
101 fdivx %fp0,%fp1 | ...1/(2 EXP(|X|))
109 cmpil #0x400CB2B3,%d0
113 fsubd T1(%pc),%fp0 | ...(|X|-16381LOG2_LEAD)
114 fsubd T2(%pc),%fp0 | ...|X| - 16381 LOG2, ACCURATE
118 fmovemx %fp0-%fp0,(%a0)
122 fmulx TWO16380(%pc),%fp0
126 fmovel #0,%fpsr |clr N bit if set by source
127 bclrb #7,(%a0) |always return positive value
128 fmovemx (%a0),%fp0-%fp0