Commit | Line | Data |
---|---|---|
2b252132 SL |
1 | /* Ksinfcosf.s 1.2 86/01/03 */ |
2 | ||
3 | #include "SYS.h" | |
4 | ||
9da0ba76 | 5 | .text |
2b252132 | 6 | ENTRY(Kcosf, 0) |
9da0ba76 SL |
7 | tstl 4(fp) # if (arg < 0) |
8 | jgeq L23 | |
9 | lnd 4(fp) | |
10 | std 4(fp) # arg = -arg; | |
11 | L23: pushl 20(fp) # hfs | |
12 | pushl $1 | |
13 | pushl 8(fp) | |
14 | pushl 4(fp) | |
15 | callf $20,_sinus | |
16 | ret # return(sinus(arg,1)); | |
17 | ||
2b252132 | 18 | ENTRY(Ksinf, 0) |
9da0ba76 SL |
19 | pushl 20(fp) # hfs |
20 | pushl $0 | |
21 | pushl 8(fp) | |
22 | pushl 4(fp) | |
23 | callf $20,_sinus | |
24 | ret # return(sinus(arg, 0)); | |
25 | ||
2b252132 | 26 | ENTRY(sinus, 0) |
9da0ba76 SL |
27 | subl3 $112,fp,sp |
28 | movl 8(fp),-80(fp) | |
29 | movl 4(fp),-84(fp) # x = arg; | |
30 | jgeq L34 # if (x < 0) { | |
31 | lnd -84(fp) | |
32 | std -84(fp) # x = -x; | |
33 | addl2 $2,12(fp) # quad = quad + 2;} | |
34 | L34: pushl 16(fp) | |
35 | ldd _twoopi | |
36 | pushd | |
37 | ldd -84(fp) | |
38 | pushd | |
39 | callf $24,_Kmuld | |
40 | movl r1,-88(fp) | |
41 | movl r0,-84(fp) # std -84(fp) x = x * twoopi; | |
42 | cmpd2 -84(fp),L36 # if (x > 32764) { | |
43 | jleq L35 | |
44 | pushl 16(fp) # hfs | |
45 | subl3 $60,fp,-(sp) # &e | |
46 | pushl -80(fp) | |
47 | pushl -84(fp) # x | |
48 | callf $20,_Kmodf | |
49 | clrl -92+4(fp) | |
50 | movl r0,-92(fp) # y = modf(x, &e); | |
51 | pushl 16(fp) # hfs | |
52 | pushl $0 | |
53 | pushl 12(fp) # quad | |
54 | pushl $0 | |
55 | pushl $0 # dummy acc | |
56 | callf $24,_Kcvtld | |
57 | pushl 16(fp) # hfs | |
58 | pushl r1 | |
59 | pushl r0 # pushd (double)quad | |
60 | ldd -60(fp) | |
61 | pushd # &e | |
62 | callf $24,_Kaddd | |
63 | movl r1,-56(fp) | |
64 | movl r0,-60(fp) # std -60(fp) e = e + quad; | |
65 | pushl 16(fp) # hfs | |
66 | subl3 $68,fp,-(sp) # &f | |
67 | ||
68 | pushl 16(fp) # hfs | |
69 | ldd -60(fp) | |
70 | pushd # &e | |
71 | ldd L37 | |
72 | pushd # 0.25 | |
73 | callf $24,_Kmuld | |
74 | ||
75 | pushl r1 | |
76 | pushl r0 # pushd 0.25 * e | |
77 | callf $20,_Kmodf # modf(0.25 * e, &f); | |
78 | ||
79 | pushl 16(fp) # hfs | |
80 | movl r1,-64(fp) | |
81 | movl r0,-68(fp) # ldd -68(fp) &f | |
82 | pushl r1 | |
83 | pushl r0 # pushd | |
84 | ldd L38 | |
85 | pushd | |
86 | callf $24,_Kmuld # 4*f | |
87 | # std r0 | |
88 | pushl 16(fp) # hfs | |
89 | pushl r1 | |
90 | pushl r0 # pushd | |
91 | ldd -60(fp) | |
92 | pushd | |
93 | callf $24,_Ksubd # e - 4 * f | |
94 | ldd r0 # load acc with result of Ksubd | |
95 | cvdl 12(fp) # quad = (e - 4 * f); } | |
96 | jbr L39 | |
97 | L35: ldd -84(fp) # else { | |
98 | cvdl -96(fp) # k = x; | |
99 | pushl 16(fp) # hfs | |
100 | pushl $0 | |
101 | pushl -96(fp) | |
102 | pushl $0 | |
103 | pushl $0 # acc | |
104 | callf $24,_Kcvtld | |
105 | # std r0 | |
106 | pushl 16(fp) # hfs | |
107 | pushl r1 | |
108 | pushl r0 # pushd (double)k | |
109 | ldd -84(fp) | |
110 | pushd # x | |
111 | callf $24,_Ksubd | |
112 | movl r1,-88(fp) | |
113 | movl r0,-92(fp) # std -92(fp) y = x - k; | |
114 | addl3 -96(fp),12(fp),r0 | |
115 | andl3 $3,r0,12(fp) # quad = (quad + k) & 03; } | |
116 | L39: bitl $1,12(fp) # if (quad & 01) | |
117 | jeql L40 | |
118 | pushl 16(fp) # hfs | |
119 | ldd -92(fp) | |
120 | pushd # y | |
121 | ldd L41 | |
122 | pushd # 1.0 | |
123 | callf $24,_Ksubd | |
124 | movl r1,-88(fp) | |
125 | movl r0,-92(fp) # std -92(fp) y = 1 - y; | |
126 | L40: cmpl 12(fp),$1 # if (quad > 1) | |
127 | jleq L42 | |
128 | lnd -92(fp) | |
129 | std -92(fp) # y = -y; | |
130 | L42: pushl 16(fp) # hfs | |
131 | ldd -92(fp) | |
132 | pushd | |
133 | pushd | |
134 | callf $24,_Kmuld # y*y | |
135 | movl r1,-72(fp) | |
136 | movl r0,-76(fp) # std -76(fp) ysq=y*y; | |
137 | ||
138 | pushl 16(fp) # hfs | |
139 | ldd -76(fp) | |
140 | pushd | |
141 | ldd _p4 | |
142 | pushd | |
143 | callf $24,_Kmuld # p4*ysq | |
144 | ||
145 | pushl 16(fp) # hfs | |
146 | pushl _p3+4 | |
147 | pushl _p3 | |
148 | pushl r1 | |
149 | pushl r0 # pushd | |
150 | callf $24,_Kaddd # p4*ysq+p3 | |
151 | ||
152 | pushl 16(fp) # hfs | |
153 | pushl -72(fp) | |
154 | pushl -76(fp) | |
155 | pushl r1 | |
156 | pushl r0 # pushd | |
157 | callf $24,_Kmuld # (p4*ysq+p3)*ysq | |
158 | ||
159 | pushl 16(fp) # hfs | |
160 | pushl _p2+4 | |
161 | pushl _p2 | |
162 | pushl r1 | |
163 | pushl r0 # pushd | |
164 | callf $24,_Kaddd # (p4*ysq+p3)*ysq+p2 | |
165 | ||
166 | pushl 16(fp) # hfs | |
167 | pushl -72(fp) | |
168 | pushl -76(fp) | |
169 | pushl r1 | |
170 | pushl r0 # pushd | |
171 | callf $24,_Kmuld # ((p4*ysq+p3)*ysq+p2)*ysq | |
172 | ||
173 | pushl 16(fp) # hfs | |
174 | pushl _p1+4 | |
175 | pushl _p1 | |
176 | pushl r1 | |
177 | pushl r0 # pushd | |
178 | callf $24,_Kaddd # ((p4*ysq+p3)*ysq+p2)*ysq+p1 | |
179 | ||
180 | pushl 16(fp) # hfs | |
181 | pushl -72(fp) | |
182 | pushl -76(fp) | |
183 | pushl r1 | |
184 | pushl r0 # pushd | |
185 | callf $24,_Kmuld # (((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq | |
186 | ||
187 | pushl 16(fp) # hfs | |
188 | pushl _p0+4 | |
189 | pushl _p0 | |
190 | pushl r1 | |
191 | pushl r0 # pushd | |
192 | callf $24,_Kaddd # (((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0 | |
193 | ||
194 | pushl 16(fp) # hfs | |
195 | pushl -88(fp) | |
196 | pushl -92(fp) | |
197 | pushl r1 | |
198 | pushl r0 # pushd | |
199 | callf $24,_Kmuld # ((((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0)*y; | |
200 | ||
201 | movl r1,-100(fp) | |
202 | movl r0,-104(fp) # std -104(fp) temp1 | |
203 | ldd r0 | |
204 | cvdf | |
205 | stf r0 | |
206 | ret#1 | |
2b252132 SL |
207 | |
208 | .data | |
209 | .align 2 | |
210 | _twoopi:.long 0x4022F983, 0x6E4E4415 # .double .63661977236758134 | |
211 | _p0: .long 0x40C90FDA, 0x90304197 # .double 1.57079631844 | |
212 | _p1: .long 0xC0255DE0, 0xB36CEE75 # .double -.645963710599 | |
213 | _p2: .long 0x3EA33457, 0xA736E807 # .double .079689678945999999 | |
214 | _p3: .long 0xBC992665, 0x5E9A6554 # .double -.0046737666099999999 | |
215 | _p4: .long 0x3A1ED7FA, 0xCC54924E # .double .000151485129 | |
216 | L36: .long 0x47FFF800, 0x00000000 # .double 32764 | |
217 | L37: .long 0x3F800000, 0x00000000 # .double .25 | |
218 | L38: .long 0x41800000, 0x00000000 # .double 4 | |
219 | L41: .long 0x40800000, 0x00000000 # .double 1 |