1 // THIS FILE AUTOGENERATED FROM asm-nseel-x86-gcc.c by a2i.php
2
3 #if EEL_F_SIZE == 8
4 #define EEL_ASM_TYPE qword ptr
5 #else
6 #define EEL_ASM_TYPE dword ptr
7 #endif
8
9 #if defined(__APPLE__)
10 #define SAVE_STACK "pushl %ebp\nmovl %esp, %ebp\nandl $-16, %esp\n"
11 #define RESTORE_STACK "leave\n"
12 #else
13 #define SAVE_STACK
14 #define RESTORE_STACK
15 #endif
16
17 /* note: only EEL_F_SIZE=8 is now supported (no float EEL_F's) */
18
nseel_asm_1pdd(void)19 __declspec(naked) void nseel_asm_1pdd(void)
20 {
21 __asm {
22 SAVE_STACK
23 #ifdef TARGET_X64
24 movq xmm0, [eax];
25 sub rsp, 128;
26 mov edi, 0xffffffff;
27 #ifdef AMD64ABI
28 mov r15, rsi;
29 call edi;
30 mov rsi, r15;
31 movq [r15], xmm0;
32 #else
33 call edi;
34 movq [esi], xmm0;
35 #endif
36 add rsp, 128;
37 #else
38 sub esp, 8; /* keep stack aligned */
39 push dword ptr [eax+4]; /* push parameter */
40 push dword ptr [eax]; /* push the rest of the parameter */
41 mov edi, 0xffffffff;
42 call edi;
43 fstp qword ptr [esi]; /* store result */
44 add esp, 16;
45 #endif
46 mov eax, esi; /* set return value */
47 add esi, 8; /* advance worktab ptr */
48 RESTORE_STACK
49 _emit 0x89;
50 _emit 0x90;
51 _emit 0x90;
52 _emit 0x90;
53 _emit 0x90;
54 _emit 0x90;
55 _emit 0x90;
56 _emit 0x90;
57 _emit 0x90;
58 _emit 0x90;
59 _emit 0x90;
60 _emit 0x90;
61 }
62 }
nseel_asm_1pdd_end(void)63 __declspec(naked) void nseel_asm_1pdd_end(void){}
64
nseel_asm_2pdd(void)65 __declspec(naked) void nseel_asm_2pdd(void)
66 {
67 __asm {
68 SAVE_STACK
69 #ifdef TARGET_X64
70 movq xmm1, [eax];
71 movq xmm0, [edi];
72 sub rsp, 128;
73 mov edi, 0xffffffff;
74 #ifdef AMD64ABI
75 mov r15, rsi;
76 call edi;
77 mov rsi, r15;
78 movq [r15], xmm0;
79 #else
80 call edi;
81 movq [esi], xmm0;
82 #endif
83 add rsp, 128;
84 #else
85 push dword ptr [eax+4]; /* push parameter */
86 push dword ptr [eax]; /* push the rest of the parameter */
87 push dword ptr [edi+4]; /* push parameter */
88 push dword ptr [edi]; /* push the rest of the parameter */
89 mov edi, 0xffffffff;
90 call edi;
91 fstp qword ptr [esi]; /* store result */
92 add esp, 16;
93 #endif
94 mov eax, esi; /* set return value */
95 add esi, 8; /* advance worktab ptr */
96 RESTORE_STACK
97 _emit 0x89;
98 _emit 0x90;
99 _emit 0x90;
100 _emit 0x90;
101 _emit 0x90;
102 _emit 0x90;
103 _emit 0x90;
104 _emit 0x90;
105 _emit 0x90;
106 _emit 0x90;
107 _emit 0x90;
108 _emit 0x90;
109 }
110 }
nseel_asm_2pdd_end(void)111 __declspec(naked) void nseel_asm_2pdd_end(void){}
112
nseel_asm_2pdds(void)113 __declspec(naked) void nseel_asm_2pdds(void)
114 {
115 __asm {
116 SAVE_STACK
117 #ifdef TARGET_X64
118 movq xmm1, [eax];
119 movq xmm0, [edi];
120 sub rsp, 128;
121 mov eax, 0xffffffff;
122 #ifdef AMD64ABI
123 mov r15, rsi;
124 mov r14, rdi;
125 call eax;
126 mov rsi, r15;
127 movq [r14], xmm0;
128 mov rax, r14; /* set return value */
129 #else
130 call eax;
131 movq [edi], xmm0;
132 mov eax, edi; /* set return value */
133 #endif
134 sub rsp, 128;
135 #else
136 push dword ptr [eax+4]; /* push parameter */
137 push dword ptr [eax]; /* push the rest of the parameter */
138 push dword ptr [edi+4]; /* push parameter */
139 push dword ptr [edi]; /* push the rest of the parameter */
140 mov eax, 0xffffffff;
141 call eax;
142 fstp qword ptr [edi]; /* store result */
143 add esp, 16;
144 mov eax, edi; /* set return value */
145 #endif
146 RESTORE_STACK
147 _emit 0x89;
148 _emit 0x90;
149 _emit 0x90;
150 _emit 0x90;
151 _emit 0x90;
152 _emit 0x90;
153 _emit 0x90;
154 _emit 0x90;
155 _emit 0x90;
156 _emit 0x90;
157 _emit 0x90;
158 _emit 0x90;
159 }
160 }
nseel_asm_2pdds_end(void)161 __declspec(naked) void nseel_asm_2pdds_end(void){}
162
nseel_asm_2pp(void)163 __declspec(naked) void nseel_asm_2pp(void)
164 {
165 __asm {
166 SAVE_STACK
167 #ifdef TARGET_X64
168
169 #ifdef AMD64ABI
170 mov r15, rsi;
171 /* rdi is first parameter */
172 mov rsi, rax;
173 sub rsp, 128;
174 mov eax, 0xffffffff;
175 call eax;
176 mov rsi, r15;
177 movq [r15], xmm0;
178 #else
179 mov ecx, edi;
180 mov edx, eax;
181 sub rsp, 128;
182 mov edi, 0xffffffff;
183 call edi;
184 movq [esi], xmm0;
185 #endif
186 add rsp, 128;
187 #else
188 sub esp, 8; /* keep stack aligned */
189 push eax; /* push parameter */
190 push edi; /* push second parameter */
191 mov edi, 0xffffffff;
192 call edi;
193 fstp EEL_ASM_TYPE [esi]; /* store result */
194 add esp, 16;
195 #endif
196 mov eax, esi; /* set return value */
197 add esi, EEL_F_SIZE; /* advance worktab ptr */
198 RESTORE_STACK
199 _emit 0x89;
200 _emit 0x90;
201 _emit 0x90;
202 _emit 0x90;
203 _emit 0x90;
204 _emit 0x90;
205 _emit 0x90;
206 _emit 0x90;
207 _emit 0x90;
208 _emit 0x90;
209 _emit 0x90;
210 _emit 0x90;
211 }
212 }
nseel_asm_2pp_end(void)213 __declspec(naked) void nseel_asm_2pp_end(void) {}
214
215
nseel_asm_1pp(void)216 __declspec(naked) void nseel_asm_1pp(void)
217 {
218 __asm {
219 SAVE_STACK
220 #ifdef TARGET_X64
221 #ifdef AMD64ABI
222 mov r15, rsi;
223 mov edi, eax;
224 sub rsp, 128;
225 mov rax, 0xffffffff;
226 call rax;
227 mov rsi, r15;
228 movq [r15], xmm0;
229 #else
230 mov ecx, eax;
231 sub rsp, 128;
232 mov edi, 0xffffffff;
233 call edi;
234 movq [esi], xmm0;
235 #endif
236 add rsp, 128;
237 #else
238 sub esp, 12; /* keep stack aligned */
239 push eax; /* push parameter */
240 mov edi, 0xffffffff;
241 call edi;
242 fstp EEL_ASM_TYPE [esi]; /* store result */
243 add esp, 16;
244 #endif
245 mov eax, esi; /* set return value */
246 add esi, EEL_F_SIZE; /* advance worktab ptr */
247 RESTORE_STACK
248 _emit 0x89;
249 _emit 0x90;
250 _emit 0x90;
251 _emit 0x90;
252 _emit 0x90;
253 _emit 0x90;
254 _emit 0x90;
255 _emit 0x90;
256 _emit 0x90;
257 _emit 0x90;
258 _emit 0x90;
259 _emit 0x90;
260 }
261 }
nseel_asm_1pp_end(void)262 __declspec(naked) void nseel_asm_1pp_end(void){}
263
264
265
266 //---------------------------------------------------------------------------------------------------------------
267
268
269 // do nothing, eh
nseel_asm_exec2(void)270 __declspec(naked) void nseel_asm_exec2(void)
271 {
272 __asm {
273
274 _emit 0x89;
275 _emit 0x90;
276 _emit 0x90;
277 _emit 0x90;
278 _emit 0x90;
279 _emit 0x90;
280 _emit 0x90;
281 _emit 0x90;
282 _emit 0x90;
283 _emit 0x90;
284 _emit 0x90;
285 _emit 0x90;
286 }
287 }
nseel_asm_exec2_end(void)288 __declspec(naked) void nseel_asm_exec2_end(void) { }
289
290
291
nseel_asm_invsqrt(void)292 __declspec(naked) void nseel_asm_invsqrt(void)
293 {
294 __asm {
295 fld EEL_ASM_TYPE [eax];
296 mov edx, 0x5f3759df;
297 fst dword ptr [esi];
298 #ifdef TARGET_X64
299 mov rax, 0xffffffff;
300 sub ecx, ecx;
301 fmul EEL_ASM_TYPE [rax];
302 #else
303 #if EEL_F_SIZE == 8
304 _emit 0xDC; // fmul qword ptr [0xffffffff]
305 _emit 0x0D;
306 _emit 0xFF;
307 _emit 0xFF;
308 _emit 0xFF;
309 _emit 0xFF;
310 #else
311 _emit 0xD8; // fmul dword ptr [0xffffffff]
312 _emit 0x0D;
313 _emit 0xFF;
314 _emit 0xFF;
315 _emit 0xFF;
316 _emit 0xFF;
317 #endif
318 #endif
319 mov ecx, dword ptr [esi];
320 sar ecx, 1;
321 sub edx, ecx;
322 mov dword ptr [esi], edx;
323 fmul dword ptr [esi];
324 fmul dword ptr [esi];
325 #ifdef TARGET_X64
326 mov rax, 0xffffffff;
327 fadd EEL_ASM_TYPE [rax];
328 #else
329 #if EEL_F_SIZE == 8
330 _emit 0xDC; // fadd qword ptr [0xffffffff]
331 _emit 0x05;
332 _emit 0xFF;
333 _emit 0xFF;
334 _emit 0xFF;
335 _emit 0xFF;
336 #else
337 _emit 0xD8; // fadd dword ptr [0xffffffff]
338 _emit 0x05;
339 _emit 0xFF;
340 _emit 0xFF;
341 _emit 0xFF;
342 _emit 0xFF;
343 #endif
344 #endif
345 fmul dword ptr [esi];
346 mov eax, esi;
347 fstp EEL_ASM_TYPE [esi];
348 add esi, EEL_F_SIZE;
349 _emit 0x89;
350 _emit 0x90;
351 _emit 0x90;
352 _emit 0x90;
353 _emit 0x90;
354 _emit 0x90;
355 _emit 0x90;
356 _emit 0x90;
357 _emit 0x90;
358 _emit 0x90;
359 _emit 0x90;
360 _emit 0x90;
361 }
362 }
nseel_asm_invsqrt_end(void)363 __declspec(naked) void nseel_asm_invsqrt_end(void) {}
364
365
366 //---------------------------------------------------------------------------------------------------------------
nseel_asm_sin(void)367 __declspec(naked) void nseel_asm_sin(void)
368 {
369 __asm {
370 fld EEL_ASM_TYPE [eax];
371 fsin;
372 mov eax, esi;
373 fstp EEL_ASM_TYPE [esi];
374 add esi, EEL_F_SIZE;
375 _emit 0x89;
376 _emit 0x90;
377 _emit 0x90;
378 _emit 0x90;
379 _emit 0x90;
380 _emit 0x90;
381 _emit 0x90;
382 _emit 0x90;
383 _emit 0x90;
384 _emit 0x90;
385 _emit 0x90;
386 _emit 0x90;
387 }
388 }
nseel_asm_sin_end(void)389 __declspec(naked) void nseel_asm_sin_end(void) {}
390
391 //---------------------------------------------------------------------------------------------------------------
nseel_asm_cos(void)392 __declspec(naked) void nseel_asm_cos(void)
393 {
394 __asm {
395 fld EEL_ASM_TYPE [eax];
396 fcos;
397 mov eax, esi;
398 fstp EEL_ASM_TYPE [esi];
399 add esi, EEL_F_SIZE;
400 _emit 0x89;
401 _emit 0x90;
402 _emit 0x90;
403 _emit 0x90;
404 _emit 0x90;
405 _emit 0x90;
406 _emit 0x90;
407 _emit 0x90;
408 _emit 0x90;
409 _emit 0x90;
410 _emit 0x90;
411 _emit 0x90;
412 }
413 }
nseel_asm_cos_end(void)414 __declspec(naked) void nseel_asm_cos_end(void) {}
415
416 //---------------------------------------------------------------------------------------------------------------
nseel_asm_tan(void)417 __declspec(naked) void nseel_asm_tan(void)
418 {
419 __asm {
420 fld EEL_ASM_TYPE [eax];
421 fptan;
422 mov eax, esi;
423 fstp st(0);
424 fstp EEL_ASM_TYPE [esi];
425 add esi, EEL_F_SIZE;
426 _emit 0x89;
427 _emit 0x90;
428 _emit 0x90;
429 _emit 0x90;
430 _emit 0x90;
431 _emit 0x90;
432 _emit 0x90;
433 _emit 0x90;
434 _emit 0x90;
435 _emit 0x90;
436 _emit 0x90;
437 _emit 0x90;
438 }
439 }
nseel_asm_tan_end(void)440 __declspec(naked) void nseel_asm_tan_end(void) {}
441
442 //---------------------------------------------------------------------------------------------------------------
nseel_asm_sqr(void)443 __declspec(naked) void nseel_asm_sqr(void)
444 {
445 __asm {
446 fld EEL_ASM_TYPE [eax];
447 fmul st(0), st(0);
448 mov eax, esi;
449 fstp EEL_ASM_TYPE [esi];
450 add esi, EEL_F_SIZE;
451 _emit 0x89;
452 _emit 0x90;
453 _emit 0x90;
454 _emit 0x90;
455 _emit 0x90;
456 _emit 0x90;
457 _emit 0x90;
458 _emit 0x90;
459 _emit 0x90;
460 _emit 0x90;
461 _emit 0x90;
462 _emit 0x90;
463 }
464 }
nseel_asm_sqr_end(void)465 __declspec(naked) void nseel_asm_sqr_end(void) {}
466
467 //---------------------------------------------------------------------------------------------------------------
nseel_asm_sqrt(void)468 __declspec(naked) void nseel_asm_sqrt(void)
469 {
470 __asm {
471 fld EEL_ASM_TYPE [eax];
472 fabs;
473 fsqrt;
474 mov eax, esi;
475 fstp EEL_ASM_TYPE [esi];
476 add esi, EEL_F_SIZE;
477 _emit 0x89;
478 _emit 0x90;
479 _emit 0x90;
480 _emit 0x90;
481 _emit 0x90;
482 _emit 0x90;
483 _emit 0x90;
484 _emit 0x90;
485 _emit 0x90;
486 _emit 0x90;
487 _emit 0x90;
488 _emit 0x90;
489 }
490 }
nseel_asm_sqrt_end(void)491 __declspec(naked) void nseel_asm_sqrt_end(void) {}
492
493
494 //---------------------------------------------------------------------------------------------------------------
nseel_asm_log(void)495 __declspec(naked) void nseel_asm_log(void)
496 {
497 __asm {
498 fldln2;
499 fld EEL_ASM_TYPE [eax];
500 mov eax, esi;
501 fyl2x;
502 fstp EEL_ASM_TYPE [esi];
503 add esi, EEL_F_SIZE;
504
505 _emit 0x89;
506 _emit 0x90;
507 _emit 0x90;
508 _emit 0x90;
509 _emit 0x90;
510 _emit 0x90;
511 _emit 0x90;
512 _emit 0x90;
513 _emit 0x90;
514 _emit 0x90;
515 _emit 0x90;
516 _emit 0x90;
517 }
518 }
nseel_asm_log_end(void)519 __declspec(naked) void nseel_asm_log_end(void) {}
520
521 //---------------------------------------------------------------------------------------------------------------
nseel_asm_log10(void)522 __declspec(naked) void nseel_asm_log10(void)
523 {
524 __asm {
525 fldlg2;
526 fld EEL_ASM_TYPE [eax];
527 mov eax, esi;
528 fyl2x;
529 fstp EEL_ASM_TYPE [esi];
530 add esi, EEL_F_SIZE;
531
532 _emit 0x89;
533 _emit 0x90;
534 _emit 0x90;
535 _emit 0x90;
536 _emit 0x90;
537 _emit 0x90;
538 _emit 0x90;
539 _emit 0x90;
540 _emit 0x90;
541 _emit 0x90;
542 _emit 0x90;
543 _emit 0x90;
544 }
545 }
nseel_asm_log10_end(void)546 __declspec(naked) void nseel_asm_log10_end(void) {}
547
548 //---------------------------------------------------------------------------------------------------------------
nseel_asm_abs(void)549 __declspec(naked) void nseel_asm_abs(void)
550 {
551 __asm {
552 fld EEL_ASM_TYPE [eax];
553 fabs;
554 mov eax, esi;
555 fstp EEL_ASM_TYPE [esi];
556 add esi, EEL_F_SIZE;
557 _emit 0x89;
558 _emit 0x90;
559 _emit 0x90;
560 _emit 0x90;
561 _emit 0x90;
562 _emit 0x90;
563 _emit 0x90;
564 _emit 0x90;
565 _emit 0x90;
566 _emit 0x90;
567 _emit 0x90;
568 _emit 0x90;
569 }
570 }
nseel_asm_abs_end(void)571 __declspec(naked) void nseel_asm_abs_end(void) {}
572
573
574 //---------------------------------------------------------------------------------------------------------------
nseel_asm_assign(void)575 __declspec(naked) void nseel_asm_assign(void)
576 {
577 #ifdef TARGET_X64
578
579 __asm {
580 mov rdx, qword ptr [rax];
581 mov rcx, rdx;
582 shr rdx, 32;
583 and edx, 0x7FF00000;
584 jz label_0;
585 cmp edx, 0x7FF00000;
586 je label_0;
587 jmp label_1;
588 label_0:
589
590 sub rcx, rcx;
591 label_1:
592
593 mov qword ptr [edi], rcx;
594 _emit 0x89;
595 _emit 0x90;
596 _emit 0x90;
597 _emit 0x90;
598 _emit 0x90;
599 _emit 0x90;
600 _emit 0x90;
601 _emit 0x90;
602 _emit 0x90;
603 _emit 0x90;
604 _emit 0x90;
605 _emit 0x90;
606 }
607
608 #else
609
610
611 #if EEL_F_SIZE == 8
612 __asm {
613 mov edx, dword ptr [eax+4];
614 mov ecx, dword ptr [eax];
615 and edx, 0x7ff00000;
616 jz label_2; // if exponent=zero, zero
617 cmp edx, 0x7ff00000;
618 je label_2; // if exponent=all 1s, zero
619 mov edx, dword ptr [eax+4]; // reread
620 jmp label_3;
621 label_2:
622
623 sub ecx, ecx;
624 sub edx, edx;
625 label_3:
626
627 mov dword ptr [edi], ecx;
628 mov dword ptr [edi+4], edx;
629 _emit 0x89;
630 _emit 0x90;
631 _emit 0x90;
632 _emit 0x90;
633 _emit 0x90;
634 _emit 0x90;
635 _emit 0x90;
636 _emit 0x90;
637 _emit 0x90;
638 _emit 0x90;
639 _emit 0x90;
640 _emit 0x90;
641 }
642 #else
643 __asm {
644 mov ecx, dword ptr [eax];
645 mov dword ptr [edi], ecx;
646 _emit 0x89;
647 _emit 0x90;
648 _emit 0x90;
649 _emit 0x90;
650 _emit 0x90;
651 _emit 0x90;
652 _emit 0x90;
653 _emit 0x90;
654 _emit 0x90;
655 _emit 0x90;
656 _emit 0x90;
657 _emit 0x90;
658 }
659 #endif
660
661 #endif
662
663 }
nseel_asm_assign_end(void)664 __declspec(naked) void nseel_asm_assign_end(void) {}
665
666 //---------------------------------------------------------------------------------------------------------------
nseel_asm_add(void)667 __declspec(naked) void nseel_asm_add(void)
668 {
669 __asm {
670 fld EEL_ASM_TYPE [eax];
671 fadd EEL_ASM_TYPE [edi];
672 mov eax, esi;
673 fstp EEL_ASM_TYPE [esi];
674 add esi, EEL_F_SIZE;
675 _emit 0x89;
676 _emit 0x90;
677 _emit 0x90;
678 _emit 0x90;
679 _emit 0x90;
680 _emit 0x90;
681 _emit 0x90;
682 _emit 0x90;
683 _emit 0x90;
684 _emit 0x90;
685 _emit 0x90;
686 _emit 0x90;
687 }
688 }
nseel_asm_add_end(void)689 __declspec(naked) void nseel_asm_add_end(void) {}
690
nseel_asm_add_op(void)691 __declspec(naked) void nseel_asm_add_op(void)
692 {
693 __asm {
694 fld EEL_ASM_TYPE [eax];
695 fadd EEL_ASM_TYPE [edi];
696 mov eax, edi;
697 fstp EEL_ASM_TYPE [edi];
698 _emit 0x89;
699 _emit 0x90;
700 _emit 0x90;
701 _emit 0x90;
702 _emit 0x90;
703 _emit 0x90;
704 _emit 0x90;
705 _emit 0x90;
706 _emit 0x90;
707 _emit 0x90;
708 _emit 0x90;
709 _emit 0x90;
710 }
711 }
nseel_asm_add_op_end(void)712 __declspec(naked) void nseel_asm_add_op_end(void) {}
713
714
715 //---------------------------------------------------------------------------------------------------------------
nseel_asm_sub(void)716 __declspec(naked) void nseel_asm_sub(void)
717 {
718 __asm {
719 fld EEL_ASM_TYPE [edi];
720 fsub EEL_ASM_TYPE [eax];
721 mov eax, esi;
722 fstp EEL_ASM_TYPE [esi];
723 add esi, EEL_F_SIZE;
724 _emit 0x89;
725 _emit 0x90;
726 _emit 0x90;
727 _emit 0x90;
728 _emit 0x90;
729 _emit 0x90;
730 _emit 0x90;
731 _emit 0x90;
732 _emit 0x90;
733 _emit 0x90;
734 _emit 0x90;
735 _emit 0x90;
736 }
737 }
nseel_asm_sub_end(void)738 __declspec(naked) void nseel_asm_sub_end(void) {}
739
nseel_asm_sub_op(void)740 __declspec(naked) void nseel_asm_sub_op(void)
741 {
742 __asm {
743 fld EEL_ASM_TYPE [edi];
744 fsub EEL_ASM_TYPE [eax];
745 mov eax, edi;
746 fstp EEL_ASM_TYPE [edi];
747 _emit 0x89;
748 _emit 0x90;
749 _emit 0x90;
750 _emit 0x90;
751 _emit 0x90;
752 _emit 0x90;
753 _emit 0x90;
754 _emit 0x90;
755 _emit 0x90;
756 _emit 0x90;
757 _emit 0x90;
758 _emit 0x90;
759 }
760 }
nseel_asm_sub_op_end(void)761 __declspec(naked) void nseel_asm_sub_op_end(void) {}
762
763 //---------------------------------------------------------------------------------------------------------------
nseel_asm_mul(void)764 __declspec(naked) void nseel_asm_mul(void)
765 {
766 __asm {
767 fld EEL_ASM_TYPE [edi];
768 fmul EEL_ASM_TYPE [eax];
769 mov eax, esi;
770 fstp EEL_ASM_TYPE [esi];
771 add esi, EEL_F_SIZE;
772 _emit 0x89;
773 _emit 0x90;
774 _emit 0x90;
775 _emit 0x90;
776 _emit 0x90;
777 _emit 0x90;
778 _emit 0x90;
779 _emit 0x90;
780 _emit 0x90;
781 _emit 0x90;
782 _emit 0x90;
783 _emit 0x90;
784 }
785 }
nseel_asm_mul_end(void)786 __declspec(naked) void nseel_asm_mul_end(void) {}
787
nseel_asm_mul_op(void)788 __declspec(naked) void nseel_asm_mul_op(void)
789 {
790 __asm {
791 fld EEL_ASM_TYPE [eax];
792 fmul EEL_ASM_TYPE [edi];
793 mov eax, edi;
794 fstp EEL_ASM_TYPE [edi];
795 _emit 0x89;
796 _emit 0x90;
797 _emit 0x90;
798 _emit 0x90;
799 _emit 0x90;
800 _emit 0x90;
801 _emit 0x90;
802 _emit 0x90;
803 _emit 0x90;
804 _emit 0x90;
805 _emit 0x90;
806 _emit 0x90;
807 }
808 }
nseel_asm_mul_op_end(void)809 __declspec(naked) void nseel_asm_mul_op_end(void) {}
810
811 //---------------------------------------------------------------------------------------------------------------
nseel_asm_div(void)812 __declspec(naked) void nseel_asm_div(void)
813 {
814 __asm {
815 fld EEL_ASM_TYPE [edi];
816 fdiv EEL_ASM_TYPE [eax];
817 mov eax, esi;
818 fstp EEL_ASM_TYPE [esi];
819 add esi, EEL_F_SIZE;
820 _emit 0x89;
821 _emit 0x90;
822 _emit 0x90;
823 _emit 0x90;
824 _emit 0x90;
825 _emit 0x90;
826 _emit 0x90;
827 _emit 0x90;
828 _emit 0x90;
829 _emit 0x90;
830 _emit 0x90;
831 _emit 0x90;
832 }
833 }
nseel_asm_div_end(void)834 __declspec(naked) void nseel_asm_div_end(void) {}
835
nseel_asm_div_op(void)836 __declspec(naked) void nseel_asm_div_op(void)
837 {
838 __asm {
839 fld EEL_ASM_TYPE [edi];
840 fdiv EEL_ASM_TYPE [eax];
841 mov eax, edi;
842 fstp EEL_ASM_TYPE [edi];
843 _emit 0x89;
844 _emit 0x90;
845 _emit 0x90;
846 _emit 0x90;
847 _emit 0x90;
848 _emit 0x90;
849 _emit 0x90;
850 _emit 0x90;
851 _emit 0x90;
852 _emit 0x90;
853 _emit 0x90;
854 _emit 0x90;
855 }
856 }
nseel_asm_div_op_end(void)857 __declspec(naked) void nseel_asm_div_op_end(void) {}
858
859 //---------------------------------------------------------------------------------------------------------------
nseel_asm_mod(void)860 __declspec(naked) void nseel_asm_mod(void)
861 {
862 __asm {
863 fld EEL_ASM_TYPE [edi];
864 fld EEL_ASM_TYPE [eax];
865 fabs;
866 fistp dword ptr [esi];
867 fabs;
868 fistp dword ptr [esi+4];
869 xor edx, edx;
870 #ifdef TARGET_X64
871 sub eax, eax;
872 #endif
873 cmp dword ptr [esi], 0;
874 je label_4; // skip devide, set return to 0
875 mov eax, dword ptr [esi+4];
876 div dword ptr [esi];
877 label_4:
878
879 mov dword ptr [esi], edx;
880 fild dword ptr [esi];
881 mov eax, esi;
882 fstp EEL_ASM_TYPE [esi];
883 add esi, EEL_F_SIZE;
884 _emit 0x89;
885 _emit 0x90;
886 _emit 0x90;
887 _emit 0x90;
888 _emit 0x90;
889 _emit 0x90;
890 _emit 0x90;
891 _emit 0x90;
892 _emit 0x90;
893 _emit 0x90;
894 _emit 0x90;
895 _emit 0x90;
896 }
897 }
nseel_asm_mod_end(void)898 __declspec(naked) void nseel_asm_mod_end(void) {}
899
nseel_asm_mod_op(void)900 __declspec(naked) void nseel_asm_mod_op(void)
901 {
902 __asm {
903 fld EEL_ASM_TYPE [edi];
904 fld EEL_ASM_TYPE [eax];
905 fabs;
906 fistp dword ptr [edi];
907 fabs;
908 fistp dword ptr [esi];
909 #ifdef TARGET_X64
910 sub eax, eax;
911 #endif
912 xor edx, edx;
913 cmp dword ptr [edi], 0;
914 je label_5; // skip devide, set return to 0
915 mov eax, dword ptr [esi];
916 div dword ptr [edi];
917 label_5:
918
919 mov dword ptr [edi], edx;
920 fild dword ptr [edi];
921 mov eax, edi;
922 fstp EEL_ASM_TYPE [edi];
923 _emit 0x89;
924 _emit 0x90;
925 _emit 0x90;
926 _emit 0x90;
927 _emit 0x90;
928 _emit 0x90;
929 _emit 0x90;
930 _emit 0x90;
931 _emit 0x90;
932 _emit 0x90;
933 _emit 0x90;
934 _emit 0x90;
935 }
936 }
nseel_asm_mod_op_end(void)937 __declspec(naked) void nseel_asm_mod_op_end(void) {}
938
939 //---------------------------------------------------------------------------------------------------------------
nseel_asm_or(void)940 __declspec(naked) void nseel_asm_or(void)
941 {
942 __asm {
943 fld EEL_ASM_TYPE [edi];
944 fld EEL_ASM_TYPE [eax];
945 mov eax, esi;
946 fistp qword ptr [esi];
947 fistp qword ptr [esi+8];
948 #ifdef TARGET_X64
949 mov rdi, qword ptr [rsi+8];
950 or qword ptr [rsi], rdi;
951 #else
952 mov edi, dword ptr [esi+8];
953 mov ecx, dword ptr [esi+12];
954 or dword ptr [esi], edi;
955 or dword ptr [esi+4], ecx;
956 #endif
957 fild qword ptr [esi];
958 fstp EEL_ASM_TYPE [esi];
959 add esi, EEL_F_SIZE;
960 _emit 0x89;
961 _emit 0x90;
962 _emit 0x90;
963 _emit 0x90;
964 _emit 0x90;
965 _emit 0x90;
966 _emit 0x90;
967 _emit 0x90;
968 _emit 0x90;
969 _emit 0x90;
970 _emit 0x90;
971 _emit 0x90;
972 }
973 }
nseel_asm_or_end(void)974 __declspec(naked) void nseel_asm_or_end(void) {}
975
nseel_asm_or_op(void)976 __declspec(naked) void nseel_asm_or_op(void)
977 {
978 __asm {
979 fld EEL_ASM_TYPE [edi];
980 fld EEL_ASM_TYPE [eax];
981 fistp qword ptr [edi];
982 fistp qword ptr [esi];
983 #ifdef TARGET_X64
984 mov rax, qword ptr [rsi];
985 or qword ptr [rdi], rax;
986 #else
987 mov eax, dword ptr [esi];
988 mov ecx, dword ptr [esi+4];
989 or dword ptr [edi], eax;
990 or dword ptr [edi+4], ecx;
991 #endif
992 fild qword ptr [edi];
993 mov eax, edi;
994 fstp EEL_ASM_TYPE [edi];
995 _emit 0x89;
996 _emit 0x90;
997 _emit 0x90;
998 _emit 0x90;
999 _emit 0x90;
1000 _emit 0x90;
1001 _emit 0x90;
1002 _emit 0x90;
1003 _emit 0x90;
1004 _emit 0x90;
1005 _emit 0x90;
1006 _emit 0x90;
1007 }
1008 }
nseel_asm_or_op_end(void)1009 __declspec(naked) void nseel_asm_or_op_end(void) {}
1010
1011 //---------------------------------------------------------------------------------------------------------------
nseel_asm_and(void)1012 __declspec(naked) void nseel_asm_and(void)
1013 {
1014 __asm {
1015 fld EEL_ASM_TYPE [edi];
1016 fld EEL_ASM_TYPE [eax];
1017 mov eax, esi;
1018 fistp qword ptr [esi];
1019 fistp qword ptr [esi+8];
1020 #ifdef TARGET_X64
1021 mov rdi, qword ptr [rsi+8];
1022 and qword ptr [rsi], rdi;
1023 #else
1024 mov edi, dword ptr [esi+8];
1025 mov ecx, dword ptr [esi+12];
1026 and dword ptr [esi], edi;
1027 and dword ptr [esi+4], ecx;
1028 #endif
1029 fild qword ptr [esi];
1030 fstp EEL_ASM_TYPE [esi];
1031 add esi, EEL_F_SIZE;
1032 _emit 0x89;
1033 _emit 0x90;
1034 _emit 0x90;
1035 _emit 0x90;
1036 _emit 0x90;
1037 _emit 0x90;
1038 _emit 0x90;
1039 _emit 0x90;
1040 _emit 0x90;
1041 _emit 0x90;
1042 _emit 0x90;
1043 _emit 0x90;
1044 }
1045 }
nseel_asm_and_end(void)1046 __declspec(naked) void nseel_asm_and_end(void) {}
1047
nseel_asm_and_op(void)1048 __declspec(naked) void nseel_asm_and_op(void)
1049 {
1050 __asm {
1051 fld EEL_ASM_TYPE [edi];
1052 fld EEL_ASM_TYPE [eax];
1053 fistp qword ptr [edi];
1054 fistp qword ptr [esi];
1055 #ifdef TARGET_X64
1056 mov rax, qword ptr [rsi];
1057 and qword ptr [rdi], rax;
1058 #else
1059 mov eax, dword ptr [esi];
1060 mov ecx, dword ptr [esi+4];
1061 and dword ptr [edi], eax;
1062 and dword ptr [edi+4], ecx;
1063 #endif
1064 fild qword ptr [edi];
1065 mov eax, edi;
1066 fstp EEL_ASM_TYPE [edi];
1067 _emit 0x89;
1068 _emit 0x90;
1069 _emit 0x90;
1070 _emit 0x90;
1071 _emit 0x90;
1072 _emit 0x90;
1073 _emit 0x90;
1074 _emit 0x90;
1075 _emit 0x90;
1076 _emit 0x90;
1077 _emit 0x90;
1078 _emit 0x90;
1079 }
1080 }
nseel_asm_and_op_end(void)1081 __declspec(naked) void nseel_asm_and_op_end(void) {}
1082
1083
1084 //---------------------------------------------------------------------------------------------------------------
nseel_asm_uplus(void)1085 __declspec(naked) void nseel_asm_uplus(void) // this is the same as doing nothing, it seems
1086 {
1087 __asm {
1088
1089 _emit 0x89;
1090 _emit 0x90;
1091 _emit 0x90;
1092 _emit 0x90;
1093 _emit 0x90;
1094 _emit 0x90;
1095 _emit 0x90;
1096 _emit 0x90;
1097 _emit 0x90;
1098 _emit 0x90;
1099 _emit 0x90;
1100 _emit 0x90;
1101 }
1102 }
nseel_asm_uplus_end(void)1103 __declspec(naked) void nseel_asm_uplus_end(void) {}
1104
1105 //---------------------------------------------------------------------------------------------------------------
nseel_asm_uminus(void)1106 __declspec(naked) void nseel_asm_uminus(void)
1107 {
1108 __asm {
1109 #if EEL_F_SIZE == 8
1110 mov ecx, dword ptr [eax];
1111 mov edi, dword ptr [eax+4];
1112 mov dword ptr [esi], ecx;
1113 xor edi, 0x80000000;
1114 mov eax, esi;
1115 mov dword ptr [esi+4], edi;
1116 add esi, 8;
1117 #else
1118 mov ecx, dword ptr [eax];
1119 xor ecx, 0x80000000;
1120 mov eax, esi;
1121 mov dword ptr [esi], ecx;
1122 add esi, 4;
1123 #endif
1124 _emit 0x89;
1125 _emit 0x90;
1126 _emit 0x90;
1127 _emit 0x90;
1128 _emit 0x90;
1129 _emit 0x90;
1130 _emit 0x90;
1131 _emit 0x90;
1132 _emit 0x90;
1133 _emit 0x90;
1134 _emit 0x90;
1135 _emit 0x90;
1136 }
1137 }
nseel_asm_uminus_end(void)1138 __declspec(naked) void nseel_asm_uminus_end(void) {}
1139
1140
1141
1142 //---------------------------------------------------------------------------------------------------------------
nseel_asm_sign(void)1143 __declspec(naked) void nseel_asm_sign(void)
1144 {
1145 __asm {
1146
1147 #ifdef TARGET_X64
1148
1149
1150 mov rdi, 0xFFFFFFFF;
1151 mov rcx, qword ptr [rax];
1152 mov rdx, 0x7FFFFFFFFFFFFFFF;
1153 test rcx, rdx;
1154 jz label_6;
1155 shr rcx, 60;
1156 and rcx, 8;
1157 add rcx, rdi;
1158 mov rax, rsi;
1159 add rsi, 8;
1160 mov rdi, qword ptr [rcx];
1161 mov qword ptr [rax], rdi;
1162 label_6:
1163
1164
1165
1166 #else
1167
1168 mov edi, 0xFFFFFFFF;
1169 #if EEL_F_SIZE == 8
1170 mov ecx, dword ptr [eax+4];
1171 mov edx, dword ptr [eax];
1172 test edx, 0xFFFFFFFF;
1173 jnz label_7;
1174 #else
1175 mov ecx, dword ptr [eax];
1176 #endif
1177 // high dword (minus sign bit) is zero
1178 test ecx, 0x7FFFFFFF;
1179 jz label_8; // zero zero, return the value passed directly
1180 label_7:
1181
1182 #if EEL_F_SIZE == 8
1183 shr ecx, 28;
1184 #else
1185 shr ecx, 29;
1186 #endif
1187
1188 and ecx, EEL_F_SIZE;
1189 add ecx, edi;
1190
1191 mov eax, esi;
1192 add esi, EEL_F_SIZE;
1193
1194 mov edi, dword ptr [ecx];
1195 #if EEL_F_SIZE == 8
1196 mov edx, dword ptr [ecx+4];
1197 #endif
1198 mov dword ptr [eax], edi;
1199 #if EEL_F_SIZE == 8
1200 mov dword ptr [eax+4], edx;
1201 #endif
1202 label_8:
1203
1204
1205 #endif
1206 _emit 0x89;
1207 _emit 0x90;
1208 _emit 0x90;
1209 _emit 0x90;
1210 _emit 0x90;
1211 _emit 0x90;
1212 _emit 0x90;
1213 _emit 0x90;
1214 _emit 0x90;
1215 _emit 0x90;
1216 _emit 0x90;
1217 _emit 0x90;
1218 }
1219 }
nseel_asm_sign_end(void)1220 __declspec(naked) void nseel_asm_sign_end(void) {}
1221
1222
1223
1224 //---------------------------------------------------------------------------------------------------------------
nseel_asm_bnot(void)1225 __declspec(naked) void nseel_asm_bnot(void)
1226 {
1227 __asm {
1228 fld EEL_ASM_TYPE [eax];
1229 fabs;
1230 #ifdef TARGET_X64
1231 mov rax, 0xFFFFFFFF;
1232 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1233 #else
1234 #if EEL_F_SIZE == 8
1235 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1236 _emit 0x1D;
1237 _emit 0xFF;
1238 _emit 0xFF;
1239 _emit 0xFF;
1240 _emit 0xFF;
1241 #else
1242 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1243 _emit 0x1D;
1244 _emit 0xFF;
1245 _emit 0xFF;
1246 _emit 0xFF;
1247 _emit 0xFF;
1248 #endif
1249 #endif
1250 fstsw ax;
1251 test eax, 256;
1252 mov eax, esi;
1253 jz label_9;
1254 fld1;
1255 jmp label_10;
1256 label_9:
1257
1258 fldz;
1259 label_10:
1260
1261 fstp EEL_ASM_TYPE [esi];
1262 add esi, EEL_F_SIZE;
1263 _emit 0x89;
1264 _emit 0x90;
1265 _emit 0x90;
1266 _emit 0x90;
1267 _emit 0x90;
1268 _emit 0x90;
1269 _emit 0x90;
1270 _emit 0x90;
1271 _emit 0x90;
1272 _emit 0x90;
1273 _emit 0x90;
1274 _emit 0x90;
1275 }
1276 }
nseel_asm_bnot_end(void)1277 __declspec(naked) void nseel_asm_bnot_end(void) {}
1278
1279 //---------------------------------------------------------------------------------------------------------------
nseel_asm_if(void)1280 __declspec(naked) void nseel_asm_if(void)
1281 {
1282 __asm {
1283 fld EEL_ASM_TYPE [eax];
1284 fabs;
1285 #ifdef TARGET_X64
1286 mov rax, 0xFFFFFFFF;
1287 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1288 mov rax, 0xFFFFFFFF;
1289 mov qword ptr [esi], rax; // conversion script will extend these out to full len
1290 mov rax, 0xFFFFFFFF;
1291 mov qword ptr [esi+8], rax;
1292 fstsw ax;
1293 shr rax, 5;
1294 and rax, 8;
1295 mov rax, qword ptr [rax+rsi];
1296 sub rsp, 8;
1297 #else
1298 #if EEL_F_SIZE == 8
1299 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1300 _emit 0x1D;
1301 _emit 0xFF;
1302 _emit 0xFF;
1303 _emit 0xFF;
1304 _emit 0xFF;
1305 #else
1306 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1307 _emit 0x1D;
1308 _emit 0xFF;
1309 _emit 0xFF;
1310 _emit 0xFF;
1311 _emit 0xFF;
1312 #endif
1313 mov dword ptr [esi], 0xFFFFFFFF;
1314 mov dword ptr [esi+4], 0xFFFFFFFF;
1315 fstsw ax;
1316 shr eax, 6;
1317 and eax, 4;
1318 mov eax, dword ptr [eax+esi];
1319 #endif
1320 call eax;
1321 #ifdef TARGET_X64
1322 add rsp, 8;
1323 #endif
1324
1325 _emit 0x89;
1326 _emit 0x90;
1327 _emit 0x90;
1328 _emit 0x90;
1329 _emit 0x90;
1330 _emit 0x90;
1331 _emit 0x90;
1332 _emit 0x90;
1333 _emit 0x90;
1334 _emit 0x90;
1335 _emit 0x90;
1336 _emit 0x90;
1337 }
1338 }
nseel_asm_if_end(void)1339 __declspec(naked) void nseel_asm_if_end(void) {}
1340
1341 //---------------------------------------------------------------------------------------------------------------
nseel_asm_repeat(void)1342 __declspec(naked) void nseel_asm_repeat(void)
1343 {
1344 __asm {
1345 fld EEL_ASM_TYPE [eax];
1346 fistp dword ptr [esi];
1347 #ifdef TARGET_X64 // safe not sure if movl ecx will zero the high word
1348 xor ecx, ecx;
1349 #endif
1350 mov ecx, dword ptr [esi];
1351 cmp ecx, 1;
1352 jl label_11;
1353 cmp ecx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN;
1354 jl label_12;
1355 mov ecx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN;
1356 label_12:
1357
1358 mov edx, 0xFFFFFFFF;
1359 sub esp, 8; /* keep stack aligned -- note this is required on x64 too!*/
1360 push esi; // revert back to last temp workspace
1361 push ecx;
1362 call edx;
1363 pop ecx;
1364 pop esi;
1365 add esp, 8; /* keep stack aligned -- also required on x64*/
1366 dec ecx;
1367 jnz label_12;
1368 label_11:
1369
1370 _emit 0x89;
1371 _emit 0x90;
1372 _emit 0x90;
1373 _emit 0x90;
1374 _emit 0x90;
1375 _emit 0x90;
1376 _emit 0x90;
1377 _emit 0x90;
1378 _emit 0x90;
1379 _emit 0x90;
1380 _emit 0x90;
1381 _emit 0x90;
1382 }
1383 }
nseel_asm_repeat_end(void)1384 __declspec(naked) void nseel_asm_repeat_end(void) {}
1385
nseel_asm_repeatwhile(void)1386 __declspec(naked) void nseel_asm_repeatwhile(void)
1387 {
1388 __asm {
1389 mov ecx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN;
1390 label_13:
1391
1392 mov edx, 0xFFFFFFFF;
1393 sub esp, 8; /* keep stack aligned -- required on x86 and x64*/
1394 push esi; // revert back to last temp workspace
1395 push ecx;
1396 call edx;
1397 pop ecx;
1398 pop esi;
1399 add esp, 8; /* keep stack aligned -- required on x86 and x64 */
1400 fld EEL_ASM_TYPE [eax];
1401 fabs;
1402 #ifdef TARGET_X64
1403 mov rax, 0xFFFFFFFF;
1404 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1405 #else
1406 #if EEL_F_SIZE == 8
1407 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1408 _emit 0x1D;
1409 _emit 0xFF;
1410 _emit 0xFF;
1411 _emit 0xFF;
1412 _emit 0xFF;
1413 #else
1414 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1415 _emit 0x1D;
1416 _emit 0xFF;
1417 _emit 0xFF;
1418 _emit 0xFF;
1419 _emit 0xFF;
1420 #endif
1421 #endif
1422 fstsw ax;
1423 test eax, 256;
1424 jnz label_14;
1425 dec ecx;
1426 jnz label_13;
1427 label_14:
1428
1429 mov eax, esi;
1430 _emit 0x89;
1431 _emit 0x90;
1432 _emit 0x90;
1433 _emit 0x90;
1434 _emit 0x90;
1435 _emit 0x90;
1436 _emit 0x90;
1437 _emit 0x90;
1438 _emit 0x90;
1439 _emit 0x90;
1440 _emit 0x90;
1441 _emit 0x90;
1442 }
1443 }
nseel_asm_repeatwhile_end(void)1444 __declspec(naked) void nseel_asm_repeatwhile_end(void) {}
1445
1446
nseel_asm_band(void)1447 __declspec(naked) void nseel_asm_band(void)
1448 {
1449 __asm {
1450 fld EEL_ASM_TYPE [eax];
1451 fabs;
1452 #ifdef TARGET_X64
1453 mov rax, 0xFFFFFFFF;
1454 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1455 #else
1456 #if EEL_F_SIZE == 8
1457 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1458 _emit 0x1D;
1459 _emit 0xFF;
1460 _emit 0xFF;
1461 _emit 0xFF;
1462 _emit 0xFF;
1463 #else
1464 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1465 _emit 0x1D;
1466 _emit 0xFF;
1467 _emit 0xFF;
1468 _emit 0xFF;
1469 _emit 0xFF;
1470 #endif
1471 #endif
1472 fstsw ax;
1473 test eax, 256;
1474 jnz label_15; // if Z, then we are nonzero
1475
1476 mov ecx, 0xFFFFFFFF;
1477 #ifdef TARGET_X64
1478 sub rsp, 8;
1479 #endif
1480 call ecx;
1481 #ifdef TARGET_X64
1482 add rsp, 8;
1483 #endif
1484 fld EEL_ASM_TYPE [eax];
1485 fabs;
1486 #ifdef TARGET_X64
1487 mov rax, 0xFFFFFFFF;
1488 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1489 #else
1490 #if EEL_F_SIZE == 8
1491 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1492 _emit 0x1D;
1493 _emit 0xFF;
1494 _emit 0xFF;
1495 _emit 0xFF;
1496 _emit 0xFF;
1497 #else
1498 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1499 _emit 0x1D;
1500 _emit 0xFF;
1501 _emit 0xFF;
1502 _emit 0xFF;
1503 _emit 0xFF;
1504 #endif
1505 #endif
1506 fstsw ax;
1507 test eax, 256;
1508 jnz label_15;
1509 fld1;
1510 jmp label_16;
1511
1512 label_15:
1513
1514 fldz;
1515 label_16:
1516
1517
1518 mov eax, esi;
1519 fstp EEL_ASM_TYPE [esi];
1520 add esi, EEL_F_SIZE;
1521 _emit 0x89;
1522 _emit 0x90;
1523 _emit 0x90;
1524 _emit 0x90;
1525 _emit 0x90;
1526 _emit 0x90;
1527 _emit 0x90;
1528 _emit 0x90;
1529 _emit 0x90;
1530 _emit 0x90;
1531 _emit 0x90;
1532 _emit 0x90;
1533 }
1534 }
nseel_asm_band_end(void)1535 __declspec(naked) void nseel_asm_band_end(void) {}
1536
nseel_asm_bor(void)1537 __declspec(naked) void nseel_asm_bor(void)
1538 {
1539 __asm {
1540 fld EEL_ASM_TYPE [eax];
1541 fabs;
1542 #ifdef TARGET_X64
1543 mov rax, 0xFFFFFFFF;
1544 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1545 #else
1546 #if EEL_F_SIZE == 8
1547 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1548 _emit 0x1D;
1549 _emit 0xFF;
1550 _emit 0xFF;
1551 _emit 0xFF;
1552 _emit 0xFF;
1553 #else
1554 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1555 _emit 0x1D;
1556 _emit 0xFF;
1557 _emit 0xFF;
1558 _emit 0xFF;
1559 _emit 0xFF;
1560 #endif
1561 #endif
1562 fstsw ax;
1563 test eax, 256;
1564 jz label_17; // if Z, then we are nonzero
1565
1566 mov ecx, 0xFFFFFFFF;
1567 #ifdef TARGET_X64
1568 sub rsp, 8;
1569 #endif
1570 call ecx;
1571 #ifdef TARGET_X64
1572 add rsp, 8;
1573 #endif
1574 fld EEL_ASM_TYPE [eax];
1575 fabs;
1576 #ifdef TARGET_X64
1577 mov rax, 0xFFFFFFFF;
1578 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1579 #else
1580 #if EEL_F_SIZE == 8
1581 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1582 _emit 0x1D;
1583 _emit 0xFF;
1584 _emit 0xFF;
1585 _emit 0xFF;
1586 _emit 0xFF;
1587 #else
1588 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1589 _emit 0x1D;
1590 _emit 0xFF;
1591 _emit 0xFF;
1592 _emit 0xFF;
1593 _emit 0xFF;
1594 #endif
1595 #endif
1596 fstsw ax;
1597 test eax, 256;
1598 jz label_17;
1599 fldz;
1600 jmp label_18;
1601
1602 label_17:
1603
1604 fld1;
1605 label_18:
1606
1607
1608 mov eax, esi;
1609 fstp EEL_ASM_TYPE [esi];
1610 add esi, EEL_F_SIZE;
1611 _emit 0x89;
1612 _emit 0x90;
1613 _emit 0x90;
1614 _emit 0x90;
1615 _emit 0x90;
1616 _emit 0x90;
1617 _emit 0x90;
1618 _emit 0x90;
1619 _emit 0x90;
1620 _emit 0x90;
1621 _emit 0x90;
1622 _emit 0x90;
1623 }
1624 }
nseel_asm_bor_end(void)1625 __declspec(naked) void nseel_asm_bor_end(void) {}
1626
1627 //---------------------------------------------------------------------------------------------------------------
nseel_asm_equal(void)1628 __declspec(naked) void nseel_asm_equal(void)
1629 {
1630 __asm {
1631 fld EEL_ASM_TYPE [eax];
1632 fsub EEL_ASM_TYPE [edi];
1633 fabs;
1634 #ifdef TARGET_X64
1635 mov rax, 0xFFFFFFFF;
1636 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1637 #else
1638 #if EEL_F_SIZE == 8
1639 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1640 _emit 0x1D;
1641 _emit 0xFF;
1642 _emit 0xFF;
1643 _emit 0xFF;
1644 _emit 0xFF;
1645 #else
1646 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1647 _emit 0x1D;
1648 _emit 0xFF;
1649 _emit 0xFF;
1650 _emit 0xFF;
1651 _emit 0xFF;
1652 #endif
1653 #endif
1654 fstsw ax;
1655 test eax, 256;
1656 mov eax, esi;
1657 jz label_19;
1658 fld1;
1659 jmp label_20;
1660 label_19:
1661
1662 fldz;
1663 label_20:
1664
1665 fstp EEL_ASM_TYPE [esi];
1666 add esi, EEL_F_SIZE;
1667 _emit 0x89;
1668 _emit 0x90;
1669 _emit 0x90;
1670 _emit 0x90;
1671 _emit 0x90;
1672 _emit 0x90;
1673 _emit 0x90;
1674 _emit 0x90;
1675 _emit 0x90;
1676 _emit 0x90;
1677 _emit 0x90;
1678 _emit 0x90;
1679 }
1680 }
nseel_asm_equal_end(void)1681 __declspec(naked) void nseel_asm_equal_end(void) {}
1682 //
1683 //---------------------------------------------------------------------------------------------------------------
nseel_asm_notequal(void)1684 __declspec(naked) void nseel_asm_notequal(void)
1685 {
1686 __asm {
1687 fld EEL_ASM_TYPE [eax];
1688 fsub EEL_ASM_TYPE [edi];
1689 fabs;
1690 #ifdef TARGET_X64
1691 mov rax, 0xFFFFFFFF;
1692 fcomp EEL_ASM_TYPE [rax]; //[g_closefact]
1693 #else
1694 #if EEL_F_SIZE == 8
1695 _emit 0xDC; // fcomp qword ptr [0xffffffff]
1696 _emit 0x1D;
1697 _emit 0xFF;
1698 _emit 0xFF;
1699 _emit 0xFF;
1700 _emit 0xFF;
1701 #else
1702 _emit 0xD8; // fcomp dword ptr [0xffffffff]
1703 _emit 0x1D;
1704 _emit 0xFF;
1705 _emit 0xFF;
1706 _emit 0xFF;
1707 _emit 0xFF;
1708 #endif
1709 #endif
1710 fstsw ax;
1711 test eax, 256;
1712 mov eax, esi;
1713 jnz label_21;
1714 fld1;
1715 jmp label_22;
1716 label_21:
1717
1718 fldz;
1719 label_22:
1720
1721 fstp EEL_ASM_TYPE [esi];
1722 add esi, EEL_F_SIZE;
1723 _emit 0x89;
1724 _emit 0x90;
1725 _emit 0x90;
1726 _emit 0x90;
1727 _emit 0x90;
1728 _emit 0x90;
1729 _emit 0x90;
1730 _emit 0x90;
1731 _emit 0x90;
1732 _emit 0x90;
1733 _emit 0x90;
1734 _emit 0x90;
1735 }
1736 }
nseel_asm_notequal_end(void)1737 __declspec(naked) void nseel_asm_notequal_end(void) {}
1738
1739
1740 //---------------------------------------------------------------------------------------------------------------
nseel_asm_below(void)1741 __declspec(naked) void nseel_asm_below(void)
1742 {
1743 __asm {
1744 fld EEL_ASM_TYPE [edi];
1745 fcomp EEL_ASM_TYPE [eax];
1746 fstsw ax;
1747 test eax, 256;
1748 mov eax, esi;
1749 jz label_23;
1750 fld1;
1751 jmp label_24;
1752 label_23:
1753
1754 fldz;
1755 label_24:
1756
1757 fstp EEL_ASM_TYPE [esi];
1758 add esi, EEL_F_SIZE;
1759 _emit 0x89;
1760 _emit 0x90;
1761 _emit 0x90;
1762 _emit 0x90;
1763 _emit 0x90;
1764 _emit 0x90;
1765 _emit 0x90;
1766 _emit 0x90;
1767 _emit 0x90;
1768 _emit 0x90;
1769 _emit 0x90;
1770 _emit 0x90;
1771 }
1772 }
nseel_asm_below_end(void)1773 __declspec(naked) void nseel_asm_below_end(void) {}
1774
1775 //---------------------------------------------------------------------------------------------------------------
nseel_asm_beloweq(void)1776 __declspec(naked) void nseel_asm_beloweq(void)
1777 {
1778 __asm {
1779 fld EEL_ASM_TYPE [eax];
1780 fcomp EEL_ASM_TYPE [edi];
1781 fstsw ax;
1782 test eax, 256;
1783 mov eax, esi;
1784 jnz label_25;
1785 fld1;
1786 jmp label_26;
1787 label_25:
1788
1789 fldz;
1790 label_26:
1791
1792 fstp EEL_ASM_TYPE [esi];
1793 add esi, EEL_F_SIZE;
1794 _emit 0x89;
1795 _emit 0x90;
1796 _emit 0x90;
1797 _emit 0x90;
1798 _emit 0x90;
1799 _emit 0x90;
1800 _emit 0x90;
1801 _emit 0x90;
1802 _emit 0x90;
1803 _emit 0x90;
1804 _emit 0x90;
1805 _emit 0x90;
1806 }
1807 }
nseel_asm_beloweq_end(void)1808 __declspec(naked) void nseel_asm_beloweq_end(void) {}
1809
1810
1811 //---------------------------------------------------------------------------------------------------------------
nseel_asm_above(void)1812 __declspec(naked) void nseel_asm_above(void)
1813 {
1814 __asm {
1815 fld EEL_ASM_TYPE [eax];
1816 fcomp EEL_ASM_TYPE [edi];
1817 fstsw ax;
1818 test eax, 256;
1819 mov eax, esi;
1820 jz label_27;
1821 fld1;
1822 jmp label_28;
1823 label_27:
1824
1825 fldz;
1826 label_28:
1827
1828 fstp EEL_ASM_TYPE [esi];
1829 add esi, EEL_F_SIZE;
1830 _emit 0x89;
1831 _emit 0x90;
1832 _emit 0x90;
1833 _emit 0x90;
1834 _emit 0x90;
1835 _emit 0x90;
1836 _emit 0x90;
1837 _emit 0x90;
1838 _emit 0x90;
1839 _emit 0x90;
1840 _emit 0x90;
1841 _emit 0x90;
1842 }
1843 }
nseel_asm_above_end(void)1844 __declspec(naked) void nseel_asm_above_end(void) {}
1845
nseel_asm_aboveeq(void)1846 __declspec(naked) void nseel_asm_aboveeq(void)
1847 {
1848 __asm {
1849 fld EEL_ASM_TYPE [edi];
1850 fcomp EEL_ASM_TYPE [eax];
1851 fstsw ax;
1852 test eax, 256;
1853 mov eax, esi;
1854 jnz label_29;
1855 fld1;
1856 jmp label_30;
1857 label_29:
1858
1859 fldz;
1860 label_30:
1861
1862 fstp EEL_ASM_TYPE [esi];
1863 add esi, EEL_F_SIZE;
1864 _emit 0x89;
1865 _emit 0x90;
1866 _emit 0x90;
1867 _emit 0x90;
1868 _emit 0x90;
1869 _emit 0x90;
1870 _emit 0x90;
1871 _emit 0x90;
1872 _emit 0x90;
1873 _emit 0x90;
1874 _emit 0x90;
1875 _emit 0x90;
1876 }
1877 }
nseel_asm_aboveeq_end(void)1878 __declspec(naked) void nseel_asm_aboveeq_end(void) {}
1879
1880
1881
nseel_asm_min(void)1882 __declspec(naked) void nseel_asm_min(void)
1883 {
1884 __asm {
1885 fld EEL_ASM_TYPE [edi];
1886 fcomp EEL_ASM_TYPE [eax];
1887 push eax;
1888 fstsw ax;
1889 test eax, 256;
1890 pop eax;
1891 jz label_31;
1892 mov eax, edi;
1893 label_31:
1894
1895 _emit 0x89;
1896 _emit 0x90;
1897 _emit 0x90;
1898 _emit 0x90;
1899 _emit 0x90;
1900 _emit 0x90;
1901 _emit 0x90;
1902 _emit 0x90;
1903 _emit 0x90;
1904 _emit 0x90;
1905 _emit 0x90;
1906 _emit 0x90;
1907 }
1908
1909 }
nseel_asm_min_end(void)1910 __declspec(naked) void nseel_asm_min_end(void) {}
1911
nseel_asm_max(void)1912 __declspec(naked) void nseel_asm_max(void)
1913 {
1914 __asm {
1915 fld EEL_ASM_TYPE [edi];
1916 fcomp EEL_ASM_TYPE [eax];
1917 push eax;
1918 fstsw ax;
1919 test eax, 256;
1920 pop eax;
1921 jnz label_32;
1922 mov eax, edi;
1923 label_32:
1924
1925 _emit 0x89;
1926 _emit 0x90;
1927 _emit 0x90;
1928 _emit 0x90;
1929 _emit 0x90;
1930 _emit 0x90;
1931 _emit 0x90;
1932 _emit 0x90;
1933 _emit 0x90;
1934 _emit 0x90;
1935 _emit 0x90;
1936 _emit 0x90;
1937 }
1938 }
nseel_asm_max_end(void)1939 __declspec(naked) void nseel_asm_max_end(void) {}
1940
1941
1942
1943
1944
1945 // just generic functions left, yay
1946
1947
1948
1949
_asm_generic3parm(void)1950 __declspec(naked) void _asm_generic3parm(void)
1951 {
1952 __asm {
1953 #ifdef TARGET_X64
1954
1955 #ifdef AMD64ABI
1956
1957 mov r15, rsi;
1958 mov rdx, rdi; // third parameter = parm
1959 mov rdi, 0xFFFFFFFF; // first parameter= context
1960
1961 mov rsi, ecx; // second parameter = parm
1962 mov rcx, rax; // fourth parameter = parm
1963 mov rax, 0xffffffff; // call function
1964 sub rsp, 128;
1965 call rax;
1966
1967 mov rsi, r15;
1968 add rsp, 128;
1969
1970 #else
1971 mov edx, ecx; // second parameter = parm
1972 mov ecx, 0xFFFFFFFF; // first parameter= context
1973 mov r8, rdi; // third parameter = parm
1974 mov r9, rax; // fourth parameter = parm
1975 mov edi, 0xffffffff; // call function
1976 sub rsp, 128;
1977 call edi;
1978 add rsp, 128;
1979 #endif
1980
1981 #else
1982 SAVE_STACK
1983 mov edx, 0xFFFFFFFF;
1984 push eax; // push parameter
1985 push edi; // push parameter
1986 push ecx; // push parameter
1987 push edx; // push context pointer
1988 mov edi, 0xffffffff;
1989 call edi;
1990 add esp, 16;
1991 RESTORE_STACK
1992 #endif
1993 _emit 0x89;
1994 _emit 0x90;
1995 _emit 0x90;
1996 _emit 0x90;
1997 _emit 0x90;
1998 _emit 0x90;
1999 _emit 0x90;
2000 _emit 0x90;
2001 _emit 0x90;
2002 _emit 0x90;
2003 _emit 0x90;
2004 _emit 0x90;
2005 }
2006 }
_asm_generic3parm_end(void)2007 __declspec(naked) void _asm_generic3parm_end(void) {}
2008
2009
_asm_generic3parm_retd(void)2010 __declspec(naked) void _asm_generic3parm_retd(void)
2011 {
2012 __asm {
2013 #ifdef TARGET_X64
2014 #ifdef AMD64ABI
2015 mov r15, rsi;
2016 mov rdx, rdi; // third parameter = parm
2017 mov rdi, 0xFFFFFFFF; // first parameter= context
2018 mov rsi, ecx; // second parameter = parm
2019 mov rcx, rax; // fourth parameter = parm
2020 mov rax, 0xffffffff; // call function
2021 sub rsp, 128;
2022 call rax;
2023 add rsp, 128;
2024 mov rsi, r15;
2025 mov rax, r15;
2026 movq [r15], xmm0;
2027 add rsi, 8;
2028 #else
2029 mov edx, ecx; // second parameter = parm
2030 mov ecx, 0xFFFFFFFF; // first parameter= context
2031 mov r8, rdi; // third parameter = parm
2032 mov r9, rax; // fourth parameter = parm
2033 mov edi, 0xffffffff; // call function
2034 sub rsp, 128;
2035 call edi;
2036 add rsp, 128;
2037 movq [rsi], xmm0;
2038 mov rax, rsi;
2039 add rsi, 8;
2040 #endif
2041 #else
2042 SAVE_STACK
2043 mov edx, 0xFFFFFFFF;
2044 push eax; // push parameter
2045 push edi; // push parameter
2046 push ecx; // push parameter
2047 push edx; // push context pointer
2048 mov edi, 0xffffffff;
2049 call edi;
2050 mov eax, esi;
2051 fstp EEL_ASM_TYPE [esi];
2052 add esi, EEL_F_SIZE;
2053 add esp, 16;
2054 RESTORE_STACK
2055 #endif
2056 _emit 0x89;
2057 _emit 0x90;
2058 _emit 0x90;
2059 _emit 0x90;
2060 _emit 0x90;
2061 _emit 0x90;
2062 _emit 0x90;
2063 _emit 0x90;
2064 _emit 0x90;
2065 _emit 0x90;
2066 _emit 0x90;
2067 _emit 0x90;
2068 }
2069 }
_asm_generic3parm_retd_end(void)2070 __declspec(naked) void _asm_generic3parm_retd_end(void) {}
2071
2072
_asm_generic2parm(void)2073 __declspec(naked) void _asm_generic2parm(void) // this prob neds to be fixed for ppc
2074 {
2075 __asm {
2076 #ifdef TARGET_X64
2077
2078 #ifdef AMD64ABI
2079 mov r15, rsi;
2080 mov esi, edi; // second parameter = parm
2081 mov edi, 0xFFFFFFFF; // first parameter= context
2082 mov rdx, rax; // third parameter = parm
2083 mov rcx, 0xffffffff; // call function
2084 sub rsp, 128;
2085 call rcx;
2086 mov rsi, r15;
2087 add rsp, 128;
2088 #else
2089 mov ecx, 0xFFFFFFFF; // first parameter= context
2090 mov edx, edi; // second parameter = parm
2091 mov r8, rax; // third parameter = parm
2092 mov edi, 0xffffffff; // call function
2093 sub rsp, 128;
2094 call edi;
2095 add rsp, 128;
2096 #endif
2097 #else
2098 SAVE_STACK
2099 mov edx, 0xFFFFFFFF;
2100 sub esp, 4; // keep stack aligned
2101 push eax; // push parameter
2102 push edi; // push parameter
2103 push edx; // push context pointer
2104 mov edi, 0xffffffff;
2105 call edi;
2106 add esp, 16;
2107 RESTORE_STACK
2108 #endif
2109 _emit 0x89;
2110 _emit 0x90;
2111 _emit 0x90;
2112 _emit 0x90;
2113 _emit 0x90;
2114 _emit 0x90;
2115 _emit 0x90;
2116 _emit 0x90;
2117 _emit 0x90;
2118 _emit 0x90;
2119 _emit 0x90;
2120 _emit 0x90;
2121 }
2122 }
_asm_generic2parm_end(void)2123 __declspec(naked) void _asm_generic2parm_end(void) {}
2124
2125
_asm_generic2parm_retd(void)2126 __declspec(naked) void _asm_generic2parm_retd(void)
2127 {
2128 __asm {
2129 #ifdef TARGET_X64
2130 #ifdef AMD64ABI
2131 mov r15, rsi;
2132 mov rsi, rdi; // second parameter = parm
2133 mov rdi, 0xFFFFFFFF; // first parameter= context
2134 mov rdx, rax; // third parameter = parm
2135 mov rcx, 0xffffffff; // call function
2136 sub rsp, 128;
2137 call rcx;
2138 mov rsi, r15;
2139 add rsp, 128;
2140 movq [r15], xmm0;
2141 mov rax, r15;
2142 add rsi, 8;
2143 #else
2144 mov ecx, 0xFFFFFFFF; // first parameter= context
2145 mov edx, edi; // second parameter = parm
2146 mov r8, rax; // third parameter = parm
2147 mov edi, 0xffffffff; // call function
2148 sub rsp, 128;
2149 call edi;
2150 add rsp, 128;
2151 movq [rsi], xmm0;
2152 mov rax, rsi;
2153 add rsi, 8;
2154 #endif
2155 #else
2156 SAVE_STACK
2157 mov edx, 0xFFFFFFFF;
2158 push eax; // push parameter
2159 push edi; // push parameter
2160 push ecx; // push parameter
2161 push edx; // push context pointer
2162 mov edi, 0xffffffff;
2163 call edi;
2164 mov eax, esi;
2165 fstp EEL_ASM_TYPE [esi];
2166 add esi, EEL_F_SIZE;
2167 add esp, 16;
2168 RESTORE_STACK
2169 #endif
2170 _emit 0x89;
2171 _emit 0x90;
2172 _emit 0x90;
2173 _emit 0x90;
2174 _emit 0x90;
2175 _emit 0x90;
2176 _emit 0x90;
2177 _emit 0x90;
2178 _emit 0x90;
2179 _emit 0x90;
2180 _emit 0x90;
2181 _emit 0x90;
2182 }
2183 }
_asm_generic2parm_retd_end(void)2184 __declspec(naked) void _asm_generic2parm_retd_end(void) {}
2185
2186
2187
2188
2189
_asm_generic1parm(void)2190 __declspec(naked) void _asm_generic1parm(void) // this prob neds to be fixed for ppc
2191 {
2192 __asm {
2193 #ifdef TARGET_X64
2194 #ifdef AMD64ABI
2195 mov rdi, 0xFFFFFFFF; // first parameter= context
2196 mov r15, rsi;
2197 mov rsi, eax; // second parameter = parm
2198 sub rsp, 128;
2199 mov rcx, 0xffffffff; // call function
2200 call rcx;
2201 mov rsi, r15;
2202 add rsp, 128;
2203 #else
2204 mov ecx, 0xFFFFFFFF; // first parameter= context
2205 mov edx, eax; // second parameter = parm
2206 mov edi, 0xffffffff; // call function
2207 sub rsp, 128;
2208 call edi;
2209 add rsp, 128;
2210 #endif
2211 #else
2212 SAVE_STACK
2213 mov edx, 0xFFFFFFFF;
2214 sub esp, 8; // keep stack aligned
2215 push eax; // push parameter
2216 push edx; // push context pointer
2217 mov edi, 0xffffffff;
2218 call edi;
2219 add esp, 16;
2220 RESTORE_STACK
2221 #endif
2222
2223 _emit 0x89;
2224 _emit 0x90;
2225 _emit 0x90;
2226 _emit 0x90;
2227 _emit 0x90;
2228 _emit 0x90;
2229 _emit 0x90;
2230 _emit 0x90;
2231 _emit 0x90;
2232 _emit 0x90;
2233 _emit 0x90;
2234 _emit 0x90;
2235 }
2236 }
_asm_generic1parm_end(void)2237 __declspec(naked) void _asm_generic1parm_end(void) {}
2238
2239
_asm_generic1parm_retd(void)2240 __declspec(naked) void _asm_generic1parm_retd(void) // 1 parameter returning double
2241 {
2242 __asm {
2243 #ifdef TARGET_X64
2244 #ifdef AMD64ABI
2245 mov r15, rsi;
2246 mov rdi, 0xFFFFFFFF; // first parameter= context
2247 mov rsi, rax; // second parameter = parm
2248 mov rcx, 0xffffffff; // call function
2249 sub rsp, 128;
2250 call rcx;
2251 mov rsi, r15;
2252 add rsp, 128;
2253 movq [r15], xmm0;
2254 mov rax, r15;
2255 add rsi, 8;
2256 #else
2257 mov ecx, 0xFFFFFFFF; // first parameter= context
2258 mov edx, eax; // second parameter = parm
2259 mov edi, 0xffffffff; // call function
2260 sub rsp, 128;
2261 call edi;
2262 add rsp, 128;
2263 movq [rsi], xmm0;
2264 mov rax, rsi;
2265 add rsi, 8;
2266 #endif
2267 #else
2268 SAVE_STACK
2269 mov edx, 0xFFFFFFFF;
2270 sub esp, 8; // keep stack aligned
2271 push eax; // push parameter
2272 push edx; // push context pointer
2273 mov edi, 0xffffffff;
2274 call edi;
2275 mov eax, esi;
2276 fstp EEL_ASM_TYPE [esi];
2277 add esi, EEL_F_SIZE;
2278 add esp, 16;
2279 RESTORE_STACK
2280 #endif
2281 _emit 0x89;
2282 _emit 0x90;
2283 _emit 0x90;
2284 _emit 0x90;
2285 _emit 0x90;
2286 _emit 0x90;
2287 _emit 0x90;
2288 _emit 0x90;
2289 _emit 0x90;
2290 _emit 0x90;
2291 _emit 0x90;
2292 _emit 0x90;
2293 }
2294 }
_asm_generic1parm_retd_end(void)2295 __declspec(naked) void _asm_generic1parm_retd_end(void) {}
2296
2297
2298
2299
2300
2301 // this gets its own stub because it's pretty crucial for performance :/
2302
_asm_megabuf(void)2303 __declspec(naked) void _asm_megabuf(void)
2304 {
2305 __asm {
2306 SAVE_STACK
2307
2308 #ifdef TARGET_X64
2309
2310
2311 #ifdef AMD64ABI
2312
2313 mov r15, rsi;
2314 mov rdi, 0xFFFFFFFF; // first parameter = context pointer
2315 fld EEL_ASM_TYPE [eax];
2316 mov rdx, 0xFFFFFFFF;
2317 fadd EEL_ASM_TYPE [rdx];
2318 fistp dword ptr [r15];
2319 xor rsi, rsi;
2320 mov esi, dword ptr [r15]; // r15 = esi (from above)
2321 mov edx, 0xffffffff;
2322 sub rsp, 128;
2323 call edx;
2324 mov rsi, r15;
2325 add rsp, 128;
2326 and rax, rax;
2327 jnz label_33;
2328 mov rax, r15;
2329 mov qword ptr [esi], 0;
2330 add rsi, EEL_F_SIZE;
2331 label_33:
2332
2333
2334 #else
2335 mov ecx, 0xFFFFFFFF; // first parameter = context pointer
2336 fld EEL_ASM_TYPE [eax];
2337 mov edx, 0xFFFFFFFF;
2338 fadd EEL_ASM_TYPE [rdx];
2339 fistp dword ptr [esi];
2340 xor rdx, rdx;
2341 mov edx, dword ptr [esi];
2342 mov edi, 0xffffffff;
2343 sub rsp, 128;
2344 call edi;
2345 add rsp, 128;
2346 and rax, rax;
2347 jnz label_34;
2348 mov rax, rsi;
2349 mov qword ptr [esi], 0;
2350 add esi, EEL_F_SIZE;
2351 label_34:
2352
2353 #endif
2354
2355
2356 #else
2357 mov edx, 0xFFFFFFFF;
2358 fld EEL_ASM_TYPE [eax];
2359 #if EEL_F_SIZE == 8
2360 _emit 0xDC; // fadd qword ptr [0xffffffff]
2361 _emit 0x05;
2362 _emit 0xFF;
2363 _emit 0xFF;
2364 _emit 0xFF;
2365 _emit 0xFF;
2366 #else
2367 _emit 0xD8; // fadd dword ptr [0xffffffff]
2368 _emit 0x05;
2369 _emit 0xFF;
2370 _emit 0xFF;
2371 _emit 0xFF;
2372 _emit 0xFF;
2373 #endif
2374 fistp dword ptr [esi];
2375 sub esp, 8; // keep stack aligned
2376 push dword ptr [esi]; // parameter
2377 push edx; // push context pointer
2378 mov edi, 0xffffffff;
2379 call edi;
2380 add esp, 16;
2381 and eax, eax;
2382 jnz label_35;
2383 mov eax, esi;
2384 mov dword ptr [esi], 0;
2385 #if EEL_F_SIZE == 8
2386 mov dword ptr [esi+4], 0;
2387 #endif
2388 add esi, EEL_F_SIZE;
2389 label_35:
2390
2391
2392
2393 #endif
2394
2395 RESTORE_STACK
2396
2397 _emit 0x89;
2398 _emit 0x90;
2399 _emit 0x90;
2400 _emit 0x90;
2401 _emit 0x90;
2402 _emit 0x90;
2403 _emit 0x90;
2404 _emit 0x90;
2405 _emit 0x90;
2406 _emit 0x90;
2407 _emit 0x90;
2408 _emit 0x90;
2409 }
2410 }
2411
_asm_megabuf_end(void)2412 __declspec(naked) void _asm_megabuf_end(void) {}
2413
2414
2415 #ifdef TARGET_X64
win64_callcode()2416 __declspec(naked) void win64_callcode()
2417 {
2418 __asm {
2419 #ifdef AMD64ABI
2420 mov eax, edi;
2421 #else
2422 mov eax, ecx;
2423 #endif
2424
2425 push rbx;
2426 push rbp;
2427 #ifndef AMD64ABI
2428 push rdi;
2429 push rsi;
2430 push r12;
2431 push r13;
2432 #endif
2433 push r14; // on AMD64ABI, we'll use r14/r15 to save edi/esi
2434 push r15;
2435 call eax;
2436 pop r15;
2437 pop r14;
2438 #ifndef AMD64ABI
2439 pop r13;
2440 pop r12;
2441 pop rsi;
2442 pop rdi;
2443 fclex;
2444 #endif
2445 pop rbp;
2446 pop rbx;
2447 ret;
2448 _emit 0x89;
2449 _emit 0x90;
2450 _emit 0x90;
2451 _emit 0x90;
2452 _emit 0x90;
2453 _emit 0x90;
2454 _emit 0x90;
2455 _emit 0x90;
2456 _emit 0x90;
2457 _emit 0x90;
2458 _emit 0x90;
2459 _emit 0x90;
2460 }
2461 }
2462
2463 #endif
2464