|
|
1.1 root 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: *
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.
23: *
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: * @(#)Ksinfcosf.s 7.1 (Berkeley) 12/6/90
37: */
38:
39: #include "../tahoe/SYS.h"
40:
41: .text
42: ENTRY(Kcosf, 0)
43: tstl 4(fp) # if (arg < 0)
44: jgeq L23
45: lnd 4(fp)
46: std 4(fp) # arg = -arg;
47: L23: pushl 20(fp) # hfs
48: pushl $1
49: pushl 8(fp)
50: pushl 4(fp)
51: callf $20,_sinus
52: ret # return(sinus(arg,1));
53:
54: ENTRY(Ksinf, 0)
55: pushl 20(fp) # hfs
56: pushl $0
57: pushl 8(fp)
58: pushl 4(fp)
59: callf $20,_sinus
60: ret # return(sinus(arg, 0));
61:
62: ENTRY(sinus, 0)
63: subl3 $112,fp,sp
64: movl 8(fp),-80(fp)
65: movl 4(fp),-84(fp) # x = arg;
66: jgeq L34 # if (x < 0) {
67: lnd -84(fp)
68: std -84(fp) # x = -x;
69: addl2 $2,12(fp) # quad = quad + 2;}
70: L34: pushl 16(fp)
71: ldd _twoopi
72: pushd
73: ldd -84(fp)
74: pushd
75: callf $24,_Kmuld
76: movl r1,-88(fp)
77: movl r0,-84(fp) # std -84(fp) x = x * twoopi;
78: cmpd2 -84(fp),L36 # if (x > 32764) {
79: jleq L35
80: pushl 16(fp) # hfs
81: subl3 $60,fp,-(sp) # &e
82: pushl -80(fp)
83: pushl -84(fp) # x
84: callf $20,_Kmodf
85: clrl -92+4(fp)
86: movl r0,-92(fp) # y = modf(x, &e);
87: pushl 16(fp) # hfs
88: pushl $0
89: pushl 12(fp) # quad
90: pushl $0
91: pushl $0 # dummy acc
92: callf $24,_Kcvtld
93: pushl 16(fp) # hfs
94: pushl r1
95: pushl r0 # pushd (double)quad
96: ldd -60(fp)
97: pushd # &e
98: callf $24,_Kaddd
99: movl r1,-56(fp)
100: movl r0,-60(fp) # std -60(fp) e = e + quad;
101: pushl 16(fp) # hfs
102: subl3 $68,fp,-(sp) # &f
103:
104: pushl 16(fp) # hfs
105: ldd -60(fp)
106: pushd # &e
107: ldd L37
108: pushd # 0.25
109: callf $24,_Kmuld
110:
111: pushl r1
112: pushl r0 # pushd 0.25 * e
113: callf $20,_Kmodf # modf(0.25 * e, &f);
114:
115: pushl 16(fp) # hfs
116: movl r1,-64(fp)
117: movl r0,-68(fp) # ldd -68(fp) &f
118: pushl r1
119: pushl r0 # pushd
120: ldd L38
121: pushd
122: callf $24,_Kmuld # 4*f
123: # std r0
124: pushl 16(fp) # hfs
125: pushl r1
126: pushl r0 # pushd
127: ldd -60(fp)
128: pushd
129: callf $24,_Ksubd # e - 4 * f
130: ldd r0 # load acc with result of Ksubd
131: cvdl 12(fp) # quad = (e - 4 * f); }
132: jbr L39
133: L35: ldd -84(fp) # else {
134: cvdl -96(fp) # k = x;
135: pushl 16(fp) # hfs
136: pushl $0
137: pushl -96(fp)
138: pushl $0
139: pushl $0 # acc
140: callf $24,_Kcvtld
141: # std r0
142: pushl 16(fp) # hfs
143: pushl r1
144: pushl r0 # pushd (double)k
145: ldd -84(fp)
146: pushd # x
147: callf $24,_Ksubd
148: movl r1,-88(fp)
149: movl r0,-92(fp) # std -92(fp) y = x - k;
150: addl3 -96(fp),12(fp),r0
151: andl3 $3,r0,12(fp) # quad = (quad + k) & 03; }
152: L39: bitl $1,12(fp) # if (quad & 01)
153: jeql L40
154: pushl 16(fp) # hfs
155: ldd -92(fp)
156: pushd # y
157: ldd L41
158: pushd # 1.0
159: callf $24,_Ksubd
160: movl r1,-88(fp)
161: movl r0,-92(fp) # std -92(fp) y = 1 - y;
162: L40: cmpl 12(fp),$1 # if (quad > 1)
163: jleq L42
164: lnd -92(fp)
165: std -92(fp) # y = -y;
166: L42: pushl 16(fp) # hfs
167: ldd -92(fp)
168: pushd
169: pushd
170: callf $24,_Kmuld # y*y
171: movl r1,-72(fp)
172: movl r0,-76(fp) # std -76(fp) ysq=y*y;
173:
174: pushl 16(fp) # hfs
175: ldd -76(fp)
176: pushd
177: ldd _p4
178: pushd
179: callf $24,_Kmuld # p4*ysq
180:
181: pushl 16(fp) # hfs
182: pushl _p3+4
183: pushl _p3
184: pushl r1
185: pushl r0 # pushd
186: callf $24,_Kaddd # p4*ysq+p3
187:
188: pushl 16(fp) # hfs
189: pushl -72(fp)
190: pushl -76(fp)
191: pushl r1
192: pushl r0 # pushd
193: callf $24,_Kmuld # (p4*ysq+p3)*ysq
194:
195: pushl 16(fp) # hfs
196: pushl _p2+4
197: pushl _p2
198: pushl r1
199: pushl r0 # pushd
200: callf $24,_Kaddd # (p4*ysq+p3)*ysq+p2
201:
202: pushl 16(fp) # hfs
203: pushl -72(fp)
204: pushl -76(fp)
205: pushl r1
206: pushl r0 # pushd
207: callf $24,_Kmuld # ((p4*ysq+p3)*ysq+p2)*ysq
208:
209: pushl 16(fp) # hfs
210: pushl _p1+4
211: pushl _p1
212: pushl r1
213: pushl r0 # pushd
214: callf $24,_Kaddd # ((p4*ysq+p3)*ysq+p2)*ysq+p1
215:
216: pushl 16(fp) # hfs
217: pushl -72(fp)
218: pushl -76(fp)
219: pushl r1
220: pushl r0 # pushd
221: callf $24,_Kmuld # (((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq
222:
223: pushl 16(fp) # hfs
224: pushl _p0+4
225: pushl _p0
226: pushl r1
227: pushl r0 # pushd
228: callf $24,_Kaddd # (((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0
229:
230: pushl 16(fp) # hfs
231: pushl -88(fp)
232: pushl -92(fp)
233: pushl r1
234: pushl r0 # pushd
235: callf $24,_Kmuld # ((((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0)*y;
236:
237: movl r1,-100(fp)
238: movl r0,-104(fp) # std -104(fp) temp1
239: ldd r0
240: cvdf
241: stf r0
242: ret#1
243:
244: .data
245: .align 2
246: _twoopi:.long 0x4022F983, 0x6E4E4415 # .double .63661977236758134
247: _p0: .long 0x40C90FDA, 0x90304197 # .double 1.57079631844
248: _p1: .long 0xC0255DE0, 0xB36CEE75 # .double -.645963710599
249: _p2: .long 0x3EA33457, 0xA736E807 # .double .079689678945999999
250: _p3: .long 0xBC992665, 0x5E9A6554 # .double -.0046737666099999999
251: _p4: .long 0x3A1ED7FA, 0xCC54924E # .double .000151485129
252: L36: .long 0x47FFF800, 0x00000000 # .double 32764
253: L37: .long 0x3F800000, 0x00000000 # .double .25
254: L38: .long 0x41800000, 0x00000000 # .double 4
255: L41: .long 0x40800000, 0x00000000 # .double 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.