FPU写起来还真是囧啊,下面20个函数实现到想死……
Sin,Cos,Tan,Cot,Sec,Csc,ASin,ACos,ATan,ACot,ASec,ACsc,Sqrt,Exp,Ln,Abs,Round,Trunc,Ceil,Floor
下面是这20个函数的汇编代码,其中Exp更是登峰造极……
1 【Sin】
2 001A0000 FF F5 push ebp
3 001A0002 89 E5 mov ebp,esp
4 001A0004 81 EC 10 00 00 00 sub esp,10h
5 001A000A 60 pushad
6 001A000B DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
7 001A0011 D9 FE fsin
8 001A0013 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
9 001A0019 61 popad
10 001A001A DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
11 001A0020 89 EC mov esp,ebp
12 001A0022 8F C5 pop ebp
13 001A0024 C2 08 00 ret 8
14 【Cos】
15 001A0027 FF F5 push ebp
16 001A0029 89 E5 mov ebp,esp
17 001A002B 81 EC 10 00 00 00 sub esp,10h
18 001A0031 60 pushad
19 001A0032 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
20 001A0038 D9 FF fcos
21 001A003A DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
22 001A0040 61 popad
23 001A0041 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
24 001A0047 89 EC mov esp,ebp
25 001A0049 8F C5 pop ebp
26 001A004B C2 08 00 ret 8
27 【Tan】
28 001A004E FF F5 push ebp
29 001A0050 89 E5 mov ebp,esp
30 001A0052 81 EC 10 00 00 00 sub esp,10h
31 001A0058 60 pushad
32 001A0059 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
33 001A005F D9 FB fsincos
34 001A0061 DE F9 fdivp st(1),st
35 001A0063 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
36 001A0069 61 popad
37 001A006A DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
38 001A0070 89 EC mov esp,ebp
39 001A0072 8F C5 pop ebp
40 001A0074 C2 08 00 ret 8
41 【Cot】
42 001A0077 FF F5 push ebp
43 001A0079 89 E5 mov ebp,esp
44 001A007B 81 EC 10 00 00 00 sub esp,10h
45 001A0081 60 pushad
46 001A0082 D9 E8 fld1
47 001A0084 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
48 001A008A D9 FB fsincos
49 001A008C DE F9 fdivp st(1),st
50 001A008E DE F9 fdivp st(1),st
51 001A0090 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
52 001A0096 61 popad
53 001A0097 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
54 001A009D 89 EC mov esp,ebp
55 001A009F 8F C5 pop ebp
56 001A00A1 C2 08 00 ret 8
57 【Sec】
58 001A00A4 FF F5 push ebp
59 001A00A6 89 E5 mov ebp,esp
60 001A00A8 81 EC 10 00 00 00 sub esp,10h
61 001A00AE 60 pushad
62 001A00AF D9 E8 fld1
63 001A00B1 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
64 001A00B7 D9 FF fcos
65 001A00B9 DE F9 fdivp st(1),st
66 001A00BB DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
67 001A00C1 61 popad
68 001A00C2 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
69 001A00C8 89 EC mov esp,ebp
70 001A00CA 8F C5 pop ebp
71 001A00CC C2 08 00 ret 8
72 【Csc】
73 001A00CF FF F5 push ebp
74 001A00D1 89 E5 mov ebp,esp
75 001A00D3 81 EC 10 00 00 00 sub esp,10h
76 001A00D9 60 pushad
77 001A00DA D9 E8 fld1
78 001A00DC DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
79 001A00E2 D9 FE fsin
80 001A00E4 DE F9 fdivp st(1),st
81 001A00E6 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
82 001A00EC 61 popad
83 001A00ED DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
84 001A00F3 89 EC mov esp,ebp
85 001A00F5 8F C5 pop ebp
86 001A00F7 C2 08 00 ret 8
87 【ASin】
88 001A00FA FF F5 push ebp
89 001A00FC 89 E5 mov ebp,esp
90 001A00FE 81 EC 10 00 00 00 sub esp,10h
91 001A0104 60 pushad
92 001A0105 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
93 001A010B D9 E8 fld1
94 001A010D D9 C1 fld st(1)
95 001A010F D9 C0 fld st(0)
96 001A0111 DE C9 fmulp st(1),st
97 001A0113 DE E9 fsubp st(1),st
98 001A0115 D9 FA fsqrt
99 001A0117 D9 F3 fpatan
100 001A0119 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
101 001A011F 61 popad
102 001A0120 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
103 001A0126 89 EC mov esp,ebp
104 001A0128 8F C5 pop ebp
105 001A012A C2 08 00 ret 8
106 【ACos】
107 001A012D FF F5 push ebp
108 001A012F 89 E5 mov ebp,esp
109 001A0131 81 EC 10 00 00 00 sub esp,10h
110 001A0137 60 pushad
111 001A0138 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
112 001A013E D9 E8 fld1
113 001A0140 D9 C1 fld st(1)
114 001A0142 D9 C0 fld st(0)
115 001A0144 DE C9 fmulp st(1),st
116 001A0146 DE E9 fsubp st(1),st
117 001A0148 D9 FA fsqrt
118 001A014A D9 C9 fxch st(1)
119 001A014C D9 F3 fpatan
120 001A014E DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
121 001A0154 61 popad
122 001A0155 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
123 001A015B 89 EC mov esp,ebp
124 001A015D 8F C5 pop ebp
125 001A015F C2 08 00 ret 8
126 【ATan】
127 001A0162 FF F5 push ebp
128 001A0164 89 E5 mov ebp,esp
129 001A0166 81 EC 10 00 00 00 sub esp,10h
130 001A016C 60 pushad
131 001A016D DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
132 001A0173 D9 E8 fld1
133 001A0175 D9 F3 fpatan
134 001A0177 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
135 001A017D 61 popad
136 001A017E DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
137 001A0184 89 EC mov esp,ebp
138 001A0186 8F C5 pop ebp
139 001A0188 C2 08 00 ret 8
140 【ACot】
141 001A018B FF F5 push ebp
142 001A018D 89 E5 mov ebp,esp
143 001A018F 81 EC 10 00 00 00 sub esp,10h
144 001A0195 60 pushad
145 001A0196 D9 E8 fld1
146 001A0198 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
147 001A019E D9 F3 fpatan
148 001A01A0 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
149 001A01A6 61 popad
150 001A01A7 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
151 001A01AD 89 EC mov esp,ebp
152 001A01AF 8F C5 pop ebp
153 001A01B1 C2 08 00 ret 8
154 【ASec】
155 001A01B4 FF F5 push ebp
156 001A01B6 89 E5 mov ebp,esp
157 001A01B8 81 EC 10 00 00 00 sub esp,10h
158 001A01BE 60 pushad
159 001A01BF D9 E8 fld1
160 001A01C1 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
161 001A01C7 DE F9 fdivp st(1),st
162 001A01C9 D9 E8 fld1
163 001A01CB D9 C1 fld st(1)
164 001A01CD D9 C0 fld st(0)
165 001A01CF DE C9 fmulp st(1),st
166 001A01D1 DE E9 fsubp st(1),st
167 001A01D3 D9 FA fsqrt
168 001A01D5 D9 C9 fxch st(1)
169 001A01D7 D9 F3 fpatan
170 001A01D9 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
171 001A01DF 61 popad
172 001A01E0 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
173 001A01E6 89 EC mov esp,ebp
174 001A01E8 8F C5 pop ebp
175 001A01EA C2 08 00 ret 8
176 【ACsc】
177 001A01ED FF F5 push ebp
178 001A01EF 89 E5 mov ebp,esp
179 001A01F1 81 EC 10 00 00 00 sub esp,10h
180 001A01F7 60 pushad
181 001A01F8 D9 E8 fld1
182 001A01FA DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
183 001A0200 DE F9 fdivp st(1),st
184 001A0202 D9 E8 fld1
185 001A0204 D9 C1 fld st(1)
186 001A0206 D9 C0 fld st(0)
187 001A0208 DE C9 fmulp st(1),st
188 001A020A DE E9 fsubp st(1),st
189 001A020C D9 FA fsqrt
190 001A020E D9 F3 fpatan
191 001A0210 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
192 001A0216 61 popad
193 001A0217 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
194 001A021D 89 EC mov esp,ebp
195 001A021F 8F C5 pop ebp
196 001A0221 C2 08 00 ret 8
197 【Sqrt】
198 001A0224 FF F5 push ebp
199 001A0226 89 E5 mov ebp,esp
200 001A0228 81 EC 10 00 00 00 sub esp,10h
201 001A022E 60 pushad
202 001A022F DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
203 001A0235 D9 FA fsqrt
204 001A0237 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
205 001A023D 61 popad
206 001A023E DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
207 001A0244 89 EC mov esp,ebp
208 001A0246 8F C5 pop ebp
209 001A0248 C2 08 00 ret 8
210 【Exp】
211 001A024B FF F5 push ebp
212 001A024D 89 E5 mov ebp,esp
213 001A024F 81 EC 10 00 00 00 sub esp,10h
214 001A0255 60 pushad
215 001A0256 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
216 001A025C D9 EA fldl2e
217 001A025E DE C9 fmulp st(1),st
218 001A0260 D9 C0 fld st(0)
219 001A0262 D9 E8 fld1
220 001A0264 D9 FD fscale
221 001A0266 DD D1 fst st(1)
222 001A0268 D9 F4 fxtract
223 001A026A D9 CB fxch st(3)
224 001A026C DE E9 fsubp st(1),st
225 001A026E D9 E0 fchs
226 001A0270 D9 F0 f2xm1
227 001A0272 D9 E8 fld1
228 001A0274 DE C1 faddp st(1),st
229 001A0276 DE C9 fmulp st(1),st
230 001A0278 DD D9 fstp st(1)
231 001A027A DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
232 001A0280 61 popad
233 001A0281 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
234 001A0287 89 EC mov esp,ebp
235 001A0289 8F C5 pop ebp
236 001A028B C2 08 00 ret 8
237 【Ln】
238 001A028E FF F5 push ebp
239 001A0290 89 E5 mov ebp,esp
240 001A0292 81 EC 10 00 00 00 sub esp,10h
241 001A0298 60 pushad
242 001A0299 D9 E8 fld1
243 001A029B DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
244 001A02A1 D9 F1 fyl2x
245 001A02A3 D9 EA fldl2e
246 001A02A5 DE F9 fdivp st(1),st
247 001A02A7 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
248 001A02AD 61 popad
249 001A02AE DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
250 001A02B4 89 EC mov esp,ebp
251 001A02B6 8F C5 pop ebp
252 001A02B8 C2 08 00 ret 8
253 【Abs】
254 001A02BB FF F5 push ebp
255 001A02BD 89 E5 mov ebp,esp
256 001A02BF 81 EC 10 00 00 00 sub esp,10h
257 001A02C5 60 pushad
258 001A02C6 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
259 001A02CC D9 E1 fabs
260 001A02CE DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
261 001A02D4 61 popad
262 001A02D5 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
263 001A02DB 89 EC mov esp,ebp
264 001A02DD 8F C5 pop ebp
265 001A02DF C2 08 00 ret 8
266 【Round】
267 001A02E2 FF F5 push ebp
268 001A02E4 89 E5 mov ebp,esp
269 001A02E6 81 EC 10 00 00 00 sub esp,10h
270 001A02EC 60 pushad
271 001A02ED DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
272 001A02F3 D9 FC frndint
273 001A02F5 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
274 001A02FB 61 popad
275 001A02FC DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
276 001A0302 89 EC mov esp,ebp
277 001A0304 8F C5 pop ebp
278 001A0306 C2 08 00 ret 8
279 【Trunc】
280 001A0309 FF F5 push ebp
281 001A030B 89 E5 mov ebp,esp
282 001A030D 81 EC 10 00 00 00 sub esp,10h
283 001A0313 60 pushad
284 001A0314 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
285 001A031A D9 E8 fld1
286 001A031C D9 FD fscale
287 001A031E DD D9 fstp st(1)
288 001A0320 D9 F4 fxtract
289 001A0322 D9 F7 fincstp
290 001A0324 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
291 001A032A 61 popad
292 001A032B DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
293 001A0331 89 EC mov esp,ebp
294 001A0333 8F C5 pop ebp
295 001A0335 C2 08 00 ret 8
296 【Ceil】
297 001A0338 FF F5 push ebp
298 001A033A 89 E5 mov ebp,esp
299 001A033C 81 EC 10 00 00 00 sub esp,10h
300 001A0342 60 pushad
301 001A0343 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
302 001A0349 D9 E8 fld1
303 001A034B D9 E0 fchs
304 001A034D D9 E8 fld1
305 001A034F D9 FD fscale
306 001A0351 DD D9 fstp st(1)
307 001A0353 DE C1 faddp st(1),st
308 001A0355 D9 FC frndint
309 001A0357 DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
310 001A035D 61 popad
311 001A035E DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
312 001A0364 89 EC mov esp,ebp
313 001A0366 8F C5 pop ebp
314 001A0368 C2 08 00 ret 8
315 【Floor】
316 001A036B FF F5 push ebp
317 001A036D 89 E5 mov ebp,esp
318 001A036F 81 EC 10 00 00 00 sub esp,10h
319 001A0375 60 pushad
320 001A0376 DD 85 08 00 00 00 fld qword ptr [ebp+00000008h]
321 001A037C D9 E8 fld1
322 001A037E D9 E0 fchs
323 001A0380 D9 E8 fld1
324 001A0382 D9 FD fscale
325 001A0384 DD D9 fstp st(1)
326 001A0386 DE E9 fsubp st(1),st
327 001A0388 D9 FC frndint
328 001A038A DD 9D F8 FF FF FF fstp qword ptr [ebp+FFFFFFF8h]
329 001A0390 61 popad
330 001A0391 DD 85 F8 FF FF FF fld qword ptr [ebp+FFFFFFF8h]
331 001A0397 89 EC mov esp,ebp
332 001A0399 8F C5 pop ebp
333 001A039B C2 08 00 ret 8
posted on 2009-04-16 05:39
陈梓瀚(vczh) 阅读(4897)
评论(3) 编辑 收藏 引用 所属分类:
JIT