BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / tahoe / math / Kexpf.s
CommitLineData
7c27088c
KB
1/*-
2 * Copyright (c) 1985 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Computer Consoles Inc.
7 *
af359dea
C
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
7c27088c 23 *
af359dea
C
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)Kexpf.s 7.1 (Berkeley) 12/6/90
7c27088c 37 */
2b252132 38
9d1834ba 39#include "../tahoe/SYS.h"
2b252132 40
253ac037 41 .text
2b252132 42ENTRY(Kexpf, R4|R3)
253ac037
SL
43 subl3 $88,fp,sp
44 tstl 4(fp)
2b252132
SL
45 jneq 1f
46 movl one,r0
253ac037 47 ret
2b252132
SL
481:
49 lnd _maxf
253ac037 50 cmpd 4(fp)
2b252132 51 jleq 1f
253ac037
SL
52 clrl r0
53 ret
2b252132
SL
541:
55 cmpd2 4(fp),_maxf
56 jleq 1f
253ac037
SL
57 ldd _HUGE
58 cvdf
59 stf r0
60 ret
2b252132 611:
253ac037 62 pushl 20(fp) # hfs
2b252132
SL
63 ldd _log2e; pushd
64 ldd 4(fp); pushd
253ac037
SL
65 callf $24,_Kmuld
66 ldd r0
67 std 4(fp)
68
69 pushl 20(fp) # hfs
70 pushl 8(fp)
71 pushl 4(fp)
72 callf $16,_Kfloorf
73 movl r0,-88(fp) # (int)ent from Kfloorf
74
75 cvlf -88(fp)
76 clrl r1
77 stf r0
78 pushl 20(fp) # hfs
79 pushl r1
80 pushl r0
2b252132 81 ldd 4(fp); pushd
253ac037
SL
82 callf $24,_Ksubd # (arg - ent)
83
84 pushl 20(fp) # hfs
2b252132
SL
85 ldd half; pushd
86 ldd r0; pushd
253ac037 87 callf $24,_Ksubd
2b252132 88 ldd r0; std -60(fp) # fract
253ac037
SL
89
90 pushl 20(fp) # hfs
91 pushd
92 pushd
93 callf $24,_Kmuld
2b252132 94 ldd r0; std -84(fp) # xsq
253ac037
SL
95
96 pushl 20(fp) # hfs
97 pushd # xsq
2b252132 98 ldd _p2; pushd
253ac037
SL
99 callf $24,_Kmuld
100
101 pushl 20(fp) # hfs
2b252132
SL
102 ldd _p1; pushd
103 ldd r0; pushd
253ac037
SL
104 callf $24,_Kaddd
105
106 pushl 20(fp) # hfs
2b252132
SL
107 ldd -84(fp); pushd
108 ldd r0; pushd
253ac037
SL
109 callf $24,_Kmuld
110
111 pushl 20(fp) # hfs
2b252132
SL
112 ldd _p0; pushd
113 ldd r0; pushd
253ac037
SL
114 callf $24,_Kaddd
115
116 pushl 20(fp) # hfs
2b252132
SL
117 ldd -60(fp); pushd # fract
118 ldd r0; pushd
253ac037 119 callf $24,_Kmuld
2b252132 120 ldd r0; std -68(fp) # temp1
253ac037
SL
121
122 pushl 20(fp) # hfs
2b252132
SL
123 ldd -84(fp); pushd # xsq
124 ldd _q2; pushd
253ac037
SL
125 callf $24,_Kmuld
126
127 pushl 20(fp) # hfs
2b252132
SL
128 ldd _q1; pushd
129 ldd r0; pushd
253ac037
SL
130 callf $24,_Kaddd
131
132 pushl 20(fp) # hfs
2b252132
SL
133 ldd -84(fp); pushd
134 ldd r0; pushd
253ac037
SL
135 callf $24,_Kmuld
136
137 pushl 20(fp) # hfs
2b252132
SL
138 ldd _q0; pushd
139 ldd r0; pushd
253ac037 140 callf $24,_Kaddd
2b252132 141 ldd r0; std -76(fp) # temp2
253ac037
SL
142
143 pushl 20(fp) # hfs for Kldexpf
144 pushl -88(fp) # ent
145
146 pushl 20(fp) # hfs tor temp2+temp1
2b252132
SL
147 ldd -68(fp); pushd # temp1
148 ldd -76(fp); pushd # temp2
253ac037
SL
149 callf $24,_Kaddd
150
151 pushl 20(fp) # hfs
2b252132
SL
152 ldd _sqrt2; pushd
153 ldd r0; pushd # temp2+temp1
253ac037 154 callf $24,_Kmuld
2b252132 155 ldd r0; std r2 # sqrt2*(temp2+temp1)
253ac037
SL
156
157 pushl 20(fp) # hfs
158 ldd -68(fp)
159 pushd
160 ldd -76(fp)
161 pushd
162 callf $24,_Ksubd # temp2-temp1
163
164 pushl 20(fp) # hfs
165 ldd r0
166 pushd # temp2-temp1
167 ldd r2
168 pushd
169 callf $24,_Kdivd
170
171 ldd r0
172 pushd
173 callf $20,_Kldexpf
174
175 #pushl 20(fp) # hfs
176 #pushl $0
177 #pushl r0 # cvlf r0
178 #pushl $0
179 #pushl $0
180 #callf $24,_Kcvtld
181
182 #ldd r0
183 #cvdf
184 #stf r0
185 ret
186
187/* file : Kfloorf.x
188*/
189 .text
190 .globl _Kfloorf
191 .data
192 .align 2
193L19: .long 0x40800000, 0x00000000 # .double 1
194 .text
195 .set L13,0x0
196 .data
197 .text
198_Kfloorf:
199 .word L13
200 subl3 $60,fp,sp
201 tstl 4(fp) # if (d<0.0) {
202 jgeq L17
203 lnd 4(fp)
204 std 4(fp) # d = -d;
205 pushl 12(fp) # hfs
206 addl3 $4,fp,-(sp) # &d
207 pushl 8(fp)
208 pushl 4(fp)
209 callf $20,_Kmodf
210 clrl -60+4(fp)
211 movl r0,-60(fp) # fract = modf(d,&d);
212 tstl r0 # if (fract != 0.0)
213 jeql L18
214 pushl 12(fp) # hfs
215 ldd L19
216 pushd
217 ldd 4(fp)
218 pushd
219 callf $24,_Kaddd
220 ldd r0
221 std 4(fp) # d +=1;
222L18: lnd 4(fp)
223 std 4(fp) # d = -d;
224 jbr L20
225L17:
226 pushl 12(fp) # hfs
227 addl3 $4,fp,-(sp)
228 pushl 8(fp)
229 pushl 4(fp)
230 callf $20,_Kmodf
231L20: ldd 4(fp)
232 cvdl r0 # for Kexpf call only!
233 ret
234
2b252132
SL
235 .data
236_p0: .long 0x45BD3D04, 0x7F734DBD # .double 1513.9067990543389
237_p1: .long 0x42A19DD4, 0x989F60DA # .double 20.202065651286927
238_p2: .long 0x3DBD2E42, 0xAB70BDA9 # .double .023093347753750233
239_q0: .long 0x468881B1, 0x7C3A6529 # .double 4368.2116627275583
240_q1: .long 0x44692F28, 0x7AE89541 # .double 233.18421142748162
241_q2: .long 0x40800000, 0x00000000 # .double 1
242_log2e: .long 0x40B8AA3B, 0x295C17F0 # .double 1.4426950408889634
243_sqrt2: .long 0x40B504F3, 0x33F9DE64 # .double 1.414213562373095
244_maxf: .long 0x471C4000, 0x00000000 # .double 10000
245_HUGE: .long 0x7FFFFFFE, 0xFFFFFFFC # .double 1.701411733192644e+38
246one: .long 0x40800000 # .float 1
247half: .long 0x40000000, 0x00000000 # .double .5