aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/fpsp040/scosh.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m68k/fpsp040/scosh.S
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/m68k/fpsp040/scosh.S')
-rw-r--r--arch/m68k/fpsp040/scosh.S132
1 files changed, 132 insertions, 0 deletions
diff --git a/arch/m68k/fpsp040/scosh.S b/arch/m68k/fpsp040/scosh.S
new file mode 100644
index 000000000000..e81edbb87642
--- /dev/null
+++ b/arch/m68k/fpsp040/scosh.S
@@ -0,0 +1,132 @@
1|
2| scosh.sa 3.1 12/10/90
3|
4| The entry point sCosh computes the hyperbolic cosine of
5| an input argument; sCoshd does the same except for denormalized
6| input.
7|
8| Input: Double-extended number X in location pointed to
9| by address register a0.
10|
11| Output: The value cosh(X) returned in floating-point register Fp0.
12|
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.
17|
18| Speed: The program sCOSH takes approximately 250 cycles.
19|
20| Algorithm:
21|
22| COSH
23| 1. If |X| > 16380 log2, go to 3.
24|
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 ).
28| Exit.
29|
30| 3. (|X| > 16380 log2). If |X| > 16480 log2, go to 5.
31|
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:
36| Y := |X|
37| Fact := 2**(16380)
38| Y' := Y - 16381 log2
39| cosh(X) := Fact * exp(Y').
40| Exit.
41|
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.
46|
47|
48
49| Copyright (C) Motorola, Inc. 1990
50| All Rights Reserved
51|
52| THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
53| The copyright notice above does not evidence any
54| actual or intended publication of such source code.
55
56|SCOSH idnt 2,1 | Motorola 040 Floating Point Software Package
57
58 |section 8
59
60 |xref t_ovfl
61 |xref t_frcinx
62 |xref setox
63
64T1: .long 0x40C62D38,0xD3D64634 | ... 16381 LOG2 LEAD
65T2: .long 0x3D6F90AE,0xB1E75CC7 | ... 16381 LOG2 TRAIL
66
67TWO16380: .long 0x7FFB0000,0x80000000,0x00000000,0x00000000
68
69 .global scoshd
70scoshd:
71|--COSH(X) = 1 FOR DENORMALIZED X
72
73 fmoves #0x3F800000,%fp0
74
75 fmovel %d1,%FPCR
76 fadds #0x00800000,%fp0
77 bra t_frcinx
78
79 .global scosh
80scosh:
81 fmovex (%a0),%fp0 | ...LOAD INPUT
82
83 movel (%a0),%d0
84 movew 4(%a0),%d0
85 andil #0x7FFFFFFF,%d0
86 cmpil #0x400CB167,%d0
87 bgts COSHBIG
88
89|--THIS IS THE USUAL CASE, |X| < 16380 LOG2
90|--COSH(X) = (1/2) * ( EXP(X) + 1/EXP(X) )
91
92 fabsx %fp0 | ...|X|
93
94 movel %d1,-(%sp)
95 clrl %d1
96 fmovemx %fp0-%fp0,(%a0) |pass parameter to setox
97 bsr setox | ...FP0 IS EXP(|X|)
98 fmuls #0x3F000000,%fp0 | ...(1/2)EXP(|X|)
99 movel (%sp)+,%d1
100
101 fmoves #0x3E800000,%fp1 | ...(1/4)
102 fdivx %fp0,%fp1 | ...1/(2 EXP(|X|))
103
104 fmovel %d1,%FPCR
105 faddx %fp1,%fp0
106
107 bra t_frcinx
108
109COSHBIG:
110 cmpil #0x400CB2B3,%d0
111 bgts COSHHUGE
112
113 fabsx %fp0
114 fsubd T1(%pc),%fp0 | ...(|X|-16381LOG2_LEAD)
115 fsubd T2(%pc),%fp0 | ...|X| - 16381 LOG2, ACCURATE
116
117 movel %d1,-(%sp)
118 clrl %d1
119 fmovemx %fp0-%fp0,(%a0)
120 bsr setox
121 fmovel (%sp)+,%fpcr
122
123 fmulx TWO16380(%pc),%fp0
124 bra t_frcinx
125
126COSHHUGE:
127 fmovel #0,%fpsr |clr N bit if set by source
128 bclrb #7,(%a0) |always return positive value
129 fmovemx (%a0),%fp0-%fp0
130 bra t_ovfl
131
132 |end