source: dev/BasicCompiler32/NumOpe_Arithmetic.cpp@ 7

Last change on this file since 7 was 3, checked in by dai_9181, 18 years ago
File size: 29.4 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2#include "Opcode.h"
3
4void GetStackData_ToRegister(int *type,int sp){
5 /*NumOpeポーランドのスタック蓄積による演算内容(2つのデータ)を
6 レジスタedx:eax、ecx:ebxに取得する*/
7
8 if(type[sp-1]==DEF_DOUBLE){
9 //fld qword ptr[esp]
10 op_fld_ptr_esp(DEF_DOUBLE);
11
12 //fistp qword ptr[esp]
13 fpu_cast();
14 OpBuffer[obp++]=(char)0xDF;
15 OpBuffer[obp++]=(char)0x3C;
16 OpBuffer[obp++]=(char)0x24;
17 fpu_cast_end();
18
19 //pop ebx
20 op_pop(REG_EBX);
21
22 //pop ecx
23 op_pop(REG_ECX);
24 }
25 else if(type[sp-1]==DEF_SINGLE){
26 //fld dword ptr[esp]
27 op_fld_ptr_esp(DEF_SINGLE);
28
29 //sub esp,4
30 op_sub_esp(4);
31
32 //fistp qword ptr[esp]
33 fpu_cast();
34 OpBuffer[obp++]=(char)0xDF;
35 OpBuffer[obp++]=(char)0x3C;
36 OpBuffer[obp++]=(char)0x24;
37 fpu_cast_end();
38
39 //pop ebx
40 op_pop(REG_EBX);
41
42 //pop ecx
43 op_pop(REG_ECX);
44 }
45 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
46 //pop ebx
47 op_pop(REG_EBX);
48
49 //pop ecx
50 op_pop(REG_ECX);
51 }
52 else{
53 //pop eax
54 op_pop(REG_EAX);
55
56 if(IsSignedType(type[sp-1])){
57 //符号拡張
58 //edx:eax ← eax
59
60 //cdq
61 op_cdq();
62 }
63 else{
64 //ビット拡張
65 //edx:eax ← eax
66
67 //xor edx,edx
68 op_zero_reg(REG_EDX);
69 }
70
71 //mov ebx,eax
72 OpBuffer[obp++]=(char)0x8B;
73 OpBuffer[obp++]=(char)0xD8;
74
75 //mov ecx,edx
76 OpBuffer[obp++]=(char)0x8B;
77 OpBuffer[obp++]=(char)0xCA;
78 }
79
80 //第1項を64ビットに対応させる
81 if(type[sp-2]==DEF_DOUBLE){
82 //fld qword ptr[esp]
83 op_fld_ptr_esp(DEF_DOUBLE);
84
85 //fistp qword ptr[esp]
86 fpu_cast();
87 OpBuffer[obp++]=(char)0xDF;
88 OpBuffer[obp++]=(char)0x3C;
89 OpBuffer[obp++]=(char)0x24;
90 fpu_cast_end();
91
92 //pop eax
93 op_pop(REG_EAX);
94
95 //pop edx
96 op_pop(REG_EDX);
97 }
98 else if(type[sp-2]==DEF_SINGLE){
99 //fld dword ptr[esp]
100 op_fld_ptr_esp(DEF_SINGLE);
101
102 //sub esp,4
103 op_sub_esp(4);
104
105 //fistp qword ptr[esp]
106 fpu_cast();
107 OpBuffer[obp++]=(char)0xDF;
108 OpBuffer[obp++]=(char)0x3C;
109 OpBuffer[obp++]=(char)0x24;
110 fpu_cast_end();
111
112 //pop eax
113 op_pop(REG_EAX);
114
115 //pop edx
116 op_pop(REG_EDX);
117 }
118 else if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
119 //pop eax
120 op_pop(REG_EAX);
121
122 //pop edx
123 op_pop(REG_EDX);
124 }
125 else{
126 //pop eax
127 op_pop(REG_EAX);
128
129 if(IsSignedType(type[sp-2])){
130 //符号拡張
131 //edx:eax ← eax
132
133 //cdq
134 op_cdq();
135 }
136 else{
137 //ビット拡張
138 //edx:eax ← eax
139
140 //xor edx,edx
141 op_zero_reg(REG_EDX);
142 }
143 }
144}
145
146void FormatStackData_To64bit(int *type,int sp){
147 //NumOpeポーランドのスタック蓄積による演算内容(2つのデータ)を64ビット整数型にする
148
149 GetStackData_ToRegister(type,sp);
150
151 //push ecx
152 op_push(REG_ECX);
153
154 //push ebx
155 op_push(REG_EBX);
156
157 //push edx
158 op_push(REG_EDX);
159
160 //push eax
161 op_push(REG_EAX);
162}
163
164BOOL CalcTwoTerm_Arithmetic(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer){
165 /* value[sp-2] = value[sp-2] + value[sp-1]
166 value[sp-2] = value[sp-2] - value[sp-1]
167 value[sp-2] = value[sp-2] * value[sp-1] */
168
169 int sp;
170 sp=*pStackPointer;
171
172 int AnswerType;
173 AnswerType=NeutralizationType(type[sp-2],index_stack[sp-2],type[sp-1],index_stack[sp-1]);
174
175 if(type[sp-2]==DEF_DOUBLE||type[sp-2]==DEF_SINGLE||
176 type[sp-1]==DEF_DOUBLE||type[sp-1]==DEF_SINGLE){
177 /////////////
178 // 実数演算
179 /////////////
180
181 if(type[sp-1]==DEF_DOUBLE){
182 //fld qword ptr[esp]
183 op_fld_ptr_esp(DEF_DOUBLE);
184
185 //add esp,8
186 op_add_esp(8);
187 }
188 else if(type[sp-1]==DEF_SINGLE){
189 //fld dword ptr[esp]
190 op_fld_ptr_esp(DEF_SINGLE);
191
192 //add esp,4
193 op_add_esp(4);
194 }
195 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
196 //64ビット整数値
197
198 //fild qword ptr[esp]
199 op_fld_ptr_esp(DEF_INT64);
200
201 //add esp,8
202 op_add_esp(8);
203 }
204 else{
205 //その他整数型
206
207 //fild dword ptr[esp]
208 op_fld_ptr_esp(DEF_LONG);
209
210 //add esp,4
211 op_add_esp(4);
212 }
213
214 if(type[sp-2]==DEF_DOUBLE){
215 //fld qword ptr[esp]
216 op_fld_ptr_esp(DEF_DOUBLE);
217 }
218 else if(type[sp-2]==DEF_SINGLE){
219 //fld dword ptr[esp]
220 op_fld_ptr_esp(DEF_SINGLE);
221 }
222 else if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
223 //64ビット整数値
224 op_fld_ptr_esp(DEF_INT64);
225 }
226 else{
227 //その他整数型
228
229 //fild dword ptr[esp]
230 op_fld_ptr_esp(DEF_LONG);
231 }
232
233 if(GetTypeSize(type[sp-2],-1)==sizeof(_int64)){
234 if(AnswerType==DEF_SINGLE){
235 //add esp,4
236 op_add_esp(4);
237 }
238 }
239 else{
240 if(AnswerType==DEF_DOUBLE){
241 //sub esp,4
242 op_sub_esp(4);
243 }
244 }
245
246 if(idCalc==CALC_ADDITION){
247 //faddp st(1),st
248 OpBuffer[obp++]=(char)0xDE;
249 OpBuffer[obp++]=(char)0xC1;
250 }
251 else if(idCalc==CALC_SUBTRACTION){
252 //fsubrp st(1),st
253 OpBuffer[obp++]=(char)0xDE;
254 OpBuffer[obp++]=(char)0xE1;
255 }
256 else if(idCalc==CALC_PRODUCT){
257 //fmulp st(1),st
258 OpBuffer[obp++]=(char)0xDE;
259 OpBuffer[obp++]=(char)0xC9;
260 }
261
262 if(AnswerType==DEF_DOUBLE){
263 //fstp qword ptr[esp]
264 OpBuffer[obp++]=(char)0xDD;
265 OpBuffer[obp++]=(char)0x1C;
266 OpBuffer[obp++]=(char)0x24;
267 }
268 else{
269 //fstp dword ptr[esp]
270 OpBuffer[obp++]=(char)0xD9;
271 OpBuffer[obp++]=(char)0x1C;
272 OpBuffer[obp++]=(char)0x24;
273 }
274 }
275 else if(Is64Type(type[sp-2])||Is64Type(type[sp-1])){
276 //////////////////////
277 // 64ビット整数演算
278 //////////////////////
279
280 if(idCalc==CALC_PRODUCT){
281 if(!((type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD)&&
282 (type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD))){
283 //2つの項のどちらかが64ビット整数でないとき
284 FormatStackData_To64bit(type,sp);
285 }
286
287 //call _allmul
288 extern SUBINFO *pSub_allmul;
289 op_call(pSub_allmul);
290
291 //push edx
292 op_push(REG_EDX);
293
294 //push eax
295 op_push(REG_EAX);
296 }
297 else{
298 if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
299 //第2項が64ビット整数値のとき
300
301 //pop ebx
302 op_pop(REG_EBX);
303
304 //pop ecx
305 op_pop(REG_ECX);
306 }
307 else{
308 //第2項がその他整数値のとき
309
310 //pop eax
311 op_pop(REG_EAX);
312
313 if(IsSignedType(type[sp-1])){
314 //符号拡張
315 //edx:eax ← eax
316
317 //cdq
318 op_cdq();
319 }
320 else{
321 //ビット拡張
322 //edx:eax ← eax
323
324 //xor edx,edx
325 op_zero_reg(REG_EDX);
326 }
327
328 //mov ebx,eax
329 OpBuffer[obp++]=(char)0x8B;
330 OpBuffer[obp++]=(char)0xD8;
331
332 //mov ecx,edx
333 OpBuffer[obp++]=(char)0x8B;
334 OpBuffer[obp++]=(char)0xCA;
335 }
336
337 if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
338 //第1項が64ビット整数値のとき
339
340 if(idCalc==CALC_ADDITION){
341 //add dword ptr[esp],ebx
342 OpBuffer[obp++]=(char)0x01;
343 OpBuffer[obp++]=(char)0x1C;
344 OpBuffer[obp++]=(char)0x24;
345
346 //adc dword ptr[esp+sizeof(long)],ecx
347 OpBuffer[obp++]=(char)0x11;
348 OpBuffer[obp++]=(char)0x4C;
349 OpBuffer[obp++]=(char)0x24;
350 OpBuffer[obp++]=(char)0x04;
351 }
352 else if(idCalc==CALC_SUBTRACTION){
353 //sub dword ptr[esp],ebx
354 OpBuffer[obp++]=(char)0x29;
355 OpBuffer[obp++]=(char)0x1C;
356 OpBuffer[obp++]=(char)0x24;
357
358 //sbb dword ptr[esp+sizeof(long)],ecx
359 OpBuffer[obp++]=(char)0x19;
360 OpBuffer[obp++]=(char)0x4C;
361 OpBuffer[obp++]=(char)0x24;
362 OpBuffer[obp++]=(char)0x04;
363 }
364 }
365 else{
366 //第1項がその他整数値のとき
367
368 //pop eax
369 op_pop(REG_EAX);
370
371 if(IsSignedType(type[sp-2])){
372 //符号拡張
373 //edx:eax ← eax
374
375 //cdq
376 op_cdq();
377 }
378 else{
379 //ビット拡張
380 //edx:eax ← eax
381
382 //xor edx,edx
383 op_zero_reg(REG_EDX);
384 }
385
386 if(idCalc==CALC_ADDITION){
387 //add ebx,eax
388 OpBuffer[obp++]=(char)0x03;
389 OpBuffer[obp++]=(char)0xD8;
390
391 //adc ecx,edx
392 OpBuffer[obp++]=(char)0x13;
393 OpBuffer[obp++]=(char)0xCA;
394 }
395 else if(idCalc==CALC_SUBTRACTION){
396 //sub ebx,eax
397 OpBuffer[obp++]=(char)0x2B;
398 OpBuffer[obp++]=(char)0xC3;
399
400 //sbb ecx,edx
401 OpBuffer[obp++]=(char)0x1B;
402 OpBuffer[obp++]=(char)0xD1;
403 }
404
405 //push ecx
406 op_push(REG_ECX);
407
408 //push ebx
409 op_push(REG_EBX);
410 }
411 }
412 }
413 else{
414 //////////////////////////
415 //32ビット以下の整数演算
416 //////////////////////////
417
418 //pop ebx
419 op_pop(REG_EBX);
420
421 //pop eax
422 op_pop(REG_EAX);
423
424 //sub esp,4
425 op_sub_esp(4);
426
427 if(idCalc==CALC_ADDITION){
428 //add eax,ebx
429 OpBuffer[obp++]=(char)0x03;
430 OpBuffer[obp++]=(char)0xC3;
431 }
432 else if(idCalc==CALC_SUBTRACTION){
433 //sub eax,ebx
434 OpBuffer[obp++]=(char)0x2B;
435 OpBuffer[obp++]=(char)0xC3;
436 }
437 else if(idCalc==CALC_PRODUCT){
438 //imul eax,ebx(64ビット演算ではないので、符号を考慮しない)
439 OpBuffer[obp++]=(char)0x0F;
440 OpBuffer[obp++]=(char)0xAF;
441 OpBuffer[obp++]=(char)0xC3;
442 }
443
444 //mov dword ptr[esp],eax
445 OpBuffer[obp++]=(char)0x89;
446 OpBuffer[obp++]=(char)0x04;
447 OpBuffer[obp++]=(char)0x24;
448 }
449
450 sp--;
451 type[sp-1]=AnswerType;
452
453 *pStackPointer=sp;
454
455 return 1;
456}
457
458BOOL Calc_Mod(int *type,int *pStackPointer){
459 //value[sp-2]%=value[sp-1]
460 //剰余演算
461
462 int sp;
463 sp=*pStackPointer;
464
465 if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD||
466 type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
467 ////////////////
468 // 64ビット演算
469 ////////////////
470
471 //第2項を64ビットに対応させる
472 FormatStackData_To64bit(type,sp);
473
474 if(IsSignedType(type[sp-2])==0&&IsSignedType(type[sp-1])==0){
475 //符号なし演算
476
477 //call _aullrem
478 extern SUBINFO *pSub_aullrem;
479 op_call(pSub_aullrem);
480 }
481 else{
482 //符号あり演算
483
484 //call _allrem
485 extern SUBINFO *pSub_allrem;
486 op_call(pSub_allrem);
487 }
488
489 //push edx
490 op_push(REG_EDX);
491
492 //push eax
493 op_push(REG_EAX);
494
495 sp--;
496 if(type[sp-1]==DEF_QWORD&&type[sp]==DEF_QWORD) type[sp-1]=DEF_QWORD;
497 else type[sp-1]=DEF_INT64;
498 }
499 else{
500 ////////////////
501 // 32ビット演算
502 ////////////////
503
504 if(type[sp-1]==DEF_DOUBLE){
505 //fld qword ptr[esp]
506 op_fld_ptr_esp(DEF_DOUBLE);
507
508 //add esp,4
509 op_add_esp(4);
510
511 //fistp dword ptr[esp]
512 fpu_cast();
513 OpBuffer[obp++]=(char)0xDB;
514 OpBuffer[obp++]=(char)0x1C;
515 OpBuffer[obp++]=(char)0x24;
516 fpu_cast_end();
517 }
518 else if(type[sp-1]==DEF_SINGLE){
519 //fld dword ptr[esp]
520 op_fld_ptr_esp(DEF_SINGLE);
521
522 //fistp dword ptr[esp]
523 fpu_cast();
524 OpBuffer[obp++]=(char)0xDB;
525 OpBuffer[obp++]=(char)0x1C;
526 OpBuffer[obp++]=(char)0x24;
527 fpu_cast_end();
528 }
529
530 //pop ebx
531 op_pop(REG_EBX);
532
533 if(type[sp-2]==DEF_DOUBLE){
534 //fld qword ptr[esp]
535 op_fld_ptr_esp(DEF_DOUBLE);
536
537 //add esp,4
538 op_add_esp(4);
539
540 //fistp dword ptr[esp]
541 fpu_cast();
542 OpBuffer[obp++]=(char)0xDB;
543 OpBuffer[obp++]=(char)0x1C;
544 OpBuffer[obp++]=(char)0x24;
545 fpu_cast_end();
546 }
547 else if(type[sp-2]==DEF_SINGLE){
548 //fld dword ptr[esp]
549 op_fld_ptr_esp(DEF_SINGLE);
550
551 //fistp dword ptr[esp]
552 fpu_cast();
553 OpBuffer[obp++]=(char)0xDB;
554 OpBuffer[obp++]=(char)0x1C;
555 OpBuffer[obp++]=(char)0x24;
556 fpu_cast_end();
557 }
558
559 //pop eax
560 op_pop(REG_EAX);
561
562 //sub esp,4
563 op_sub_esp(4);
564
565 if(type[sp-2]==DEF_DWORD&&type[sp-1]==DEF_DWORD){
566 //xor edx,edx
567 op_zero_reg(REG_EDX);
568
569 //div ebx (eax=eax/ebx...edx)
570 OpBuffer[obp++]=(char)0xF7;
571 OpBuffer[obp++]=(char)0xF3;
572 }
573 else{
574 //cdq
575 op_cdq();
576
577 //idiv ebx (eax=eax/ebx...edx)
578 OpBuffer[obp++]=(char)0xF7;
579 OpBuffer[obp++]=(char)0xFB;
580 }
581
582 //mov dword ptr[esp],edx
583 OpBuffer[obp++]=(char)0x89;
584 OpBuffer[obp++]=(char)0x14;
585 OpBuffer[obp++]=(char)0x24;
586
587 sp--;
588 type[sp-1]=DEF_LONG;
589 }
590
591 *pStackPointer=sp;
592
593 return 1;
594}
595
596BOOL Calc_Divide(int *type,int *pStackPointer,int BaseType){
597 //value[sp-2]/=value[sp-1];
598 //除算
599
600 int sp;
601 sp=*pStackPointer;
602
603 ///////////////////////
604 // 浮動小数点演算のみ
605 ///////////////////////
606
607 int AnswerType;
608 if(type[sp-2]==DEF_DOUBLE||type[sp-1]==DEF_DOUBLE||BaseType==DEF_DOUBLE) AnswerType=DEF_DOUBLE;
609 else AnswerType=DEF_SINGLE;
610
611 if(type[sp-1]==DEF_DOUBLE){
612 //fld qword ptr[esp]
613 op_fld_ptr_esp(DEF_DOUBLE);
614
615 //add esp,8
616 op_add_esp(8);
617 }
618 else if(type[sp-1]==DEF_SINGLE){
619 //fld dword ptr[esp]
620 op_fld_ptr_esp(DEF_SINGLE);
621
622 //add esp,4
623 op_add_esp(4);
624 }
625 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
626 //64ビット整数値
627
628 //fild qword ptr[esp]
629 op_fld_ptr_esp(DEF_INT64);
630
631 //add esp,8
632 op_add_esp(8);
633 }
634 else if(type[sp-1]==DEF_DWORD){
635 //pop eax
636 op_pop(REG_EAX);
637
638 //push 0
639 op_push_value(0);
640
641 //push eax
642 op_push(REG_EAX);
643
644 //fild qword ptr[esp]
645 OpBuffer[obp++]=(char)0xDF;
646 OpBuffer[obp++]=(char)0x2C;
647 OpBuffer[obp++]=(char)0x24;
648
649 //add esp,8
650 op_add_esp(8);
651 }
652 else{
653 //fild dword ptr[esp]
654 op_fld_ptr_esp(DEF_LONG);
655
656 //add esp,4
657 op_add_esp(4);
658 }
659
660 if(type[sp-2]==DEF_DOUBLE){
661 //fld qword ptr[esp]
662 op_fld_ptr_esp(DEF_DOUBLE);
663 }
664 else if(type[sp-2]==DEF_SINGLE){
665 //fld dword ptr[esp]
666 op_fld_ptr_esp(DEF_SINGLE);
667 }
668 else if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
669 //64ビット整数値
670
671 //fild qword ptr[esp]
672 op_fld_ptr_esp(DEF_INT64);
673 }
674 else if(type[sp-2]==DEF_DWORD){
675 //pop eax
676 op_pop(REG_EAX);
677
678 //push 0
679 op_push_value(0);
680
681 //push eax
682 op_push(REG_EAX);
683
684 //fild qword ptr[esp]
685 OpBuffer[obp++]=(char)0xDF;
686 OpBuffer[obp++]=(char)0x2C;
687 OpBuffer[obp++]=(char)0x24;
688 }
689 else{ //Long
690 //fild dword ptr[esp]
691 op_fld_ptr_esp(DEF_LONG);
692 }
693 //↓ここだけ例外DWord
694 if(GetTypeSize(type[sp-2],-1)==sizeof(_int64)||type[sp-2]==DEF_DWORD){
695 if(AnswerType==DEF_SINGLE){
696 //add esp,4
697 op_add_esp(4);
698 }
699 }
700 else{
701 if(AnswerType==DEF_DOUBLE){
702 //sub esp,4
703 op_sub_esp(4);
704 }
705 }
706
707 //fdivrp st(1),st
708 OpBuffer[obp++]=(char)0xDE;
709 OpBuffer[obp++]=(char)0xF1;
710
711 sp--;
712 if(AnswerType==DEF_DOUBLE){
713 //fstp qword ptr[esp]
714 OpBuffer[obp++]=(char)0xDD;
715 OpBuffer[obp++]=(char)0x1C;
716 OpBuffer[obp++]=(char)0x24;
717
718 type[sp-1]=DEF_DOUBLE;
719 }
720 else{
721 //fstp dword ptr[esp]
722 OpBuffer[obp++]=(char)0xD9;
723 OpBuffer[obp++]=(char)0x1C;
724 OpBuffer[obp++]=(char)0x24;
725
726 type[sp-1]=DEF_SINGLE;
727 }
728
729 *pStackPointer=sp;
730
731 return 1;
732}
733
734BOOL Calc_IntDivide(int *type,LONG_PTR *index_stack,int *pStackPointer){
735 //value[sp-2]/=value[sp-1]
736 //除算(整数)
737
738 int sp;
739 sp=*pStackPointer;
740
741 if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD||
742 type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
743 ////////////////
744 // 64ビット演算
745 ////////////////
746
747 //2つの項を64ビットに対応させる
748 FormatStackData_To64bit(type,sp);
749
750 if(IsSignedType(type[sp-2])==0&&IsSignedType(type[sp-1])==0){
751 //符号なし演算
752
753 //call _aulldiv
754 extern SUBINFO *pSub_aulldiv;
755 op_call(pSub_aulldiv);
756 }
757 else{
758 //符号あり演算
759
760 //call _alldiv
761 extern SUBINFO *pSub_alldiv;
762 op_call(pSub_alldiv);
763 }
764
765 //push edx
766 op_push(REG_EDX);
767
768 //push eax
769 op_push(REG_EAX);
770
771 sp--;
772 if(type[sp-1]==DEF_QWORD&&type[sp]==DEF_QWORD) type[sp-1]=DEF_QWORD;
773 else type[sp-1]=DEF_INT64;
774 }
775 else{
776 ////////////////
777 // 32ビット演算
778 ////////////////
779
780 if(type[sp-1]==DEF_DOUBLE){
781 //fld qword ptr[esp]
782 op_fld_ptr_esp(DEF_DOUBLE);
783
784 //add esp,4
785 op_add_esp(4);
786
787 //fistp dword ptr[esp]
788 fpu_cast();
789 OpBuffer[obp++]=(char)0xDB;
790 OpBuffer[obp++]=(char)0x1C;
791 OpBuffer[obp++]=(char)0x24;
792 fpu_cast_end();
793 }
794 else if(type[sp-1]==DEF_SINGLE){
795 //fld dword ptr[esp]
796 op_fld_ptr_esp(DEF_SINGLE);
797
798 //fistp dword ptr[esp]
799 fpu_cast();
800 OpBuffer[obp++]=(char)0xDB;
801 OpBuffer[obp++]=(char)0x1C;
802 OpBuffer[obp++]=(char)0x24;
803 fpu_cast_end();
804 }
805
806 //pop ebx
807 op_pop(REG_EBX);
808
809 if(type[sp-2]==DEF_DOUBLE){
810 //fld qword ptr[esp]
811 op_fld_ptr_esp(DEF_DOUBLE);
812
813 //add esp,4
814 op_add_esp(4);
815
816 //fistp dword ptr[esp]
817 fpu_cast();
818 OpBuffer[obp++]=(char)0xDB;
819 OpBuffer[obp++]=(char)0x1C;
820 OpBuffer[obp++]=(char)0x24;
821 fpu_cast_end();
822 }
823 else if(type[sp-2]==DEF_SINGLE){
824 //fld dword ptr[esp]
825 op_fld_ptr_esp(DEF_SINGLE);
826
827 //fistp dword ptr[esp]
828 fpu_cast();
829 OpBuffer[obp++]=(char)0xDB;
830 OpBuffer[obp++]=(char)0x1C;
831 OpBuffer[obp++]=(char)0x24;
832 fpu_cast_end();
833 }
834
835 //pop eax
836 op_pop(REG_EAX);
837
838 //sub esp,4
839 op_sub_esp(4);
840
841 if((type[sp-2]==DEF_DWORD&&type[sp-1]==DEF_DWORD)||
842 (IS_POSITIVE_LITERAL(index_stack[sp-2])&&type[sp-1]==DEF_DWORD)||
843 (type[sp-2]==DEF_DWORD&&IS_POSITIVE_LITERAL(index_stack[sp-1]))){
844 //xor edx,edx
845 op_zero_reg(REG_EDX);
846
847 //div ebx (eax=eax/ebx...edx)
848 OpBuffer[obp++]=(char)0xF7;
849 OpBuffer[obp++]=(char)0xF3;
850 }
851 else{
852 //cdq
853 op_cdq();
854
855 //idiv ebx (eax=eax/ebx...edx)
856 OpBuffer[obp++]=(char)0xF7;
857 OpBuffer[obp++]=(char)0xFB;
858 }
859
860 //mov dword ptr[esp],eax
861 OpBuffer[obp++]=(char)0x89;
862 OpBuffer[obp++]=(char)0x04;
863 OpBuffer[obp++]=(char)0x24;
864
865 sp--;
866
867 //整数以外の型だったときはLong型にする
868 if(!IsWholeNumberType(type[sp-1])) type[sp-1]=DEF_LONG;
869 }
870
871 *pStackPointer=sp;
872 return 1;
873}
874
875BOOL Calc_MinusMark(int *type,int sp){
876 //value[sp-1]=-value[sp-1]
877 //符号反転
878
879 if(type[sp-1]==DEF_DOUBLE){
880 //fld qword ptr[esp]
881 op_fld_ptr_esp(DEF_DOUBLE);
882
883 //push -1
884 op_push_value(-1);
885
886 //fild dword ptr[esp]
887 op_fld_ptr_esp(DEF_LONG);
888
889 //add esp,4
890 op_add_esp(4);
891
892 //fmulp st(1),st
893 OpBuffer[obp++]=(char)0xDE;
894 OpBuffer[obp++]=(char)0xC9;
895
896 //fstp qword ptr[esp]
897 OpBuffer[obp++]=(char)0xDD;
898 OpBuffer[obp++]=(char)0x1C;
899 OpBuffer[obp++]=(char)0x24;
900 }
901 else if(type[sp-1]==DEF_SINGLE){
902 //fld dword ptr[esp]
903 op_fld_ptr_esp(DEF_SINGLE);
904
905 //push -1
906 op_push_value(-1);
907
908 //fild dword ptr[esp]
909 op_fld_ptr_esp(DEF_LONG);
910
911 //add esp,4
912 op_add_esp(4);
913
914 //fmulp st(1),st
915 OpBuffer[obp++]=(char)0xDE;
916 OpBuffer[obp++]=(char)0xC9;
917
918 //fstp dword ptr[esp]
919 OpBuffer[obp++]=(char)0xD9;
920 OpBuffer[obp++]=(char)0x1C;
921 OpBuffer[obp++]=(char)0x24;
922 }
923 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
924 //pop eax
925 op_pop(REG_EAX);
926
927 //neg eax
928 OpBuffer[obp++]=(char)0xF7;
929 OpBuffer[obp++]=(char)0xD8;
930
931 //pop edx
932 op_pop(REG_EDX);
933
934 //adc edx,0
935 OpBuffer[obp++]=(char)0x83;
936 OpBuffer[obp++]=(char)0xD2;
937 OpBuffer[obp++]=(char)0x00;
938
939 //neg edx
940 OpBuffer[obp++]=(char)0xF7;
941 OpBuffer[obp++]=(char)0xDA;
942
943 //push edx
944 op_push(REG_EDX);
945
946 //push eax
947 op_push(REG_EAX);
948
949 type[sp-1]=DEF_INT64; //QWordはInt64へ
950 }
951 else if(IsWholeNumberType(type[sp-1])){
952 //pop eax
953 op_pop(REG_EAX);
954
955 //imul eax,-1
956 OpBuffer[obp++]=(char)0x6B;
957 OpBuffer[obp++]=(char)0xC0;
958 OpBuffer[obp++]=(char)0xFF;
959
960 //push eax
961 op_push(REG_EAX);
962
963 type[sp-1]=GetSignedType(type[sp-1]);
964 }
965
966 return 1;
967}
968
969BOOL Calc_Power(int *type,int *pStackPointer){
970 //べき乗(実数演算のみ)
971
972 int sp;
973 sp=*pStackPointer;
974
975 if(type[sp-1]==DEF_DOUBLE){
976 //fld qword ptr[esp]
977 op_fld_ptr_esp(DEF_DOUBLE);
978
979 //add esp,8
980 op_add_esp(8);
981 }
982 else if(type[sp-1]==DEF_SINGLE){
983 //fld dword ptr[esp]
984 op_fld_ptr_esp(DEF_SINGLE);
985
986 //add esp,4
987 op_add_esp(4);
988 }
989 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
990 //64ビット整数値
991
992 //fild qword ptr[esp]
993 op_fld_ptr_esp(DEF_INT64);
994
995 //add esp,8
996 op_add_esp(8);
997 }
998 else{
999 //32ビット整数値
1000
1001 //fild dword ptr[esp]
1002 op_fld_ptr_esp(DEF_LONG);
1003
1004 //add esp,4
1005 op_add_esp(4);
1006 }
1007
1008 if(type[sp-2]==DEF_DOUBLE){
1009 //fld qword ptr[esp]
1010 op_fld_ptr_esp(DEF_DOUBLE);
1011 }
1012 else if(type[sp-2]==DEF_SINGLE){
1013 //fld dword ptr[esp]
1014 op_fld_ptr_esp(DEF_SINGLE);
1015
1016 //sub esp,4
1017 op_sub_esp(4);
1018 }
1019 else if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
1020 //64ビット整数値
1021
1022 //fild qword ptr[esp]
1023 op_fld_ptr_esp(DEF_INT64);
1024 }
1025 else{
1026 //32ビット整数値
1027
1028 //fild dword ptr[esp]
1029 op_fld_ptr_esp(DEF_LONG);
1030
1031 //sub esp,4
1032 op_sub_esp(4);
1033 }
1034
1035 //sub esp,8
1036 op_sub_esp(8);
1037
1038 //fstp qword ptr[esp]
1039 OpBuffer[obp++]=(char)0xDD;
1040 OpBuffer[obp++]=(char)0x1C;
1041 OpBuffer[obp++]=(char)0x24;
1042
1043 //fstp qword ptr[esp+8]
1044 OpBuffer[obp++]=(char)0xDD;
1045 OpBuffer[obp++]=(char)0x5C;
1046 OpBuffer[obp++]=(char)0x24;
1047 OpBuffer[obp++]=(char)0x08;
1048
1049 //call pow
1050 extern SUBINFO *pSub_pow;
1051 op_call(pSub_pow);
1052
1053 //sub esp,8
1054 op_sub_esp(8);
1055
1056 //fstp qword ptr[esp]
1057 OpBuffer[obp++]=(char)0xDD;
1058 OpBuffer[obp++]=(char)0x1C;
1059 OpBuffer[obp++]=(char)0x24;
1060
1061 sp--;
1062 type[sp-1]=DEF_DOUBLE;
1063
1064 *pStackPointer=sp;
1065 return 1;
1066}
1067
1068BOOL Calc_Cast(int *type,LONG_PTR *index_stack,int *pStackPointer){
1069 //キャスト
1070
1071 int sp;
1072 sp=*pStackPointer;
1073
1074 int CastType;
1075 CastType=type[sp-1];
1076 if((CastType&FLAG_CAST)==0){
1077 SetError(47,NULL,cp);
1078 return 0;
1079 }
1080 CastType=CastType&(~FLAG_CAST);
1081
1082 if(IsPtrType(CastType)){
1083 ChangeTypeToLong(type[sp-2]);
1084 }
1085 else if(IsRealNumberType(CastType)){
1086 if(CastType==DEF_DOUBLE) ChangeTypeToDouble(type[sp-2]);
1087 else if(CastType==DEF_SINGLE) ChangeTypeToSingle(type[sp-2]);
1088 }
1089 else ChangeTypeToWhole(type[sp-2],CastType);
1090
1091 type[sp-2]=CastType;
1092 index_stack[sp-2]=index_stack[sp-1];
1093
1094 sp--;
1095
1096 *pStackPointer=sp;
1097 return 1;
1098}
1099
1100BOOL Calc_SHL(int *type,int *pStackPointer){
1101 //左ビットシフト
1102 //value[sp-2]=value[sp-2]<<value[sp-1]
1103
1104 int sp;
1105 sp=*pStackPointer;
1106
1107 if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
1108 ////////////////
1109 // 64ビット演算
1110 ////////////////
1111
1112 //2項目は32ビット整数として利用
1113 if(type[sp-1]==DEF_DOUBLE){
1114 //fld qword ptr[esp]
1115 op_fld_ptr_esp(DEF_DOUBLE);
1116
1117 //add esp,4
1118 op_add_esp(4);
1119
1120 //fistp dword ptr[esp]
1121 fpu_cast();
1122 OpBuffer[obp++]=(char)0xDB;
1123 OpBuffer[obp++]=(char)0x1C;
1124 OpBuffer[obp++]=(char)0x24;
1125 fpu_cast_end();
1126
1127 //pop ecx
1128 op_pop(REG_ECX);
1129 }
1130 else if(type[sp-1]==DEF_SINGLE){
1131 //fld dword ptr[esp]
1132 op_fld_ptr_esp(DEF_SINGLE);
1133
1134 //fistp dword ptr[esp]
1135 fpu_cast();
1136 OpBuffer[obp++]=(char)0xDB;
1137 OpBuffer[obp++]=(char)0x1C;
1138 OpBuffer[obp++]=(char)0x24;
1139 fpu_cast_end();
1140
1141 //pop ecx
1142 op_pop(REG_ECX);
1143 }
1144 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
1145 //pop ecx
1146 op_pop(REG_ECX);
1147
1148 //add esp,4
1149 op_add_esp(4);
1150 }
1151 else{
1152 //pop ecx
1153 op_pop(REG_ECX);
1154 }
1155
1156 //第1項を64ビットに対応させる
1157 if(type[sp-2]==DEF_DOUBLE){
1158 //fld qword ptr[esp]
1159 op_fld_ptr_esp(DEF_DOUBLE);
1160
1161 //fistp qword ptr[esp]
1162 fpu_cast();
1163 OpBuffer[obp++]=(char)0xDF;
1164 OpBuffer[obp++]=(char)0x3C;
1165 OpBuffer[obp++]=(char)0x24;
1166 fpu_cast_end();
1167
1168 //pop eax
1169 op_pop(REG_EAX);
1170
1171 //pop edx
1172 op_pop(REG_EDX);
1173 }
1174 else if(type[sp-2]==DEF_SINGLE){
1175 //fld dword ptr[esp]
1176 op_fld_ptr_esp(DEF_SINGLE);
1177
1178 //sub esp,4
1179 op_sub_esp(4);
1180
1181 //fistp qword ptr[esp]
1182 fpu_cast();
1183 OpBuffer[obp++]=(char)0xDF;
1184 OpBuffer[obp++]=(char)0x3C;
1185 OpBuffer[obp++]=(char)0x24;
1186 fpu_cast_end();
1187
1188 //pop eax
1189 op_pop(REG_EAX);
1190
1191 //pop edx
1192 op_pop(REG_EDX);
1193 }
1194 else if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
1195 //pop eax
1196 op_pop(REG_EAX);
1197
1198 //pop edx
1199 op_pop(REG_EDX);
1200 }
1201 else{
1202 //pop eax
1203 op_pop(REG_EAX);
1204
1205 if(IsSignedType(type[sp-2])){
1206 //符号拡張
1207 //edx:eax ← eax
1208
1209 //cdq
1210 op_cdq();
1211 }
1212 else{
1213 //ビット拡張
1214 //edx:eax ← eax
1215
1216 //xor edx,edx
1217 op_zero_reg(REG_EDX);
1218 }
1219 }
1220
1221 //call _allshl
1222 extern SUBINFO *pSub_allshl;
1223 op_call(pSub_allshl);
1224
1225 //push edx
1226 op_push(REG_EDX);
1227
1228 //push eax
1229 op_push(REG_EAX);
1230
1231 sp--;
1232 }
1233 else{
1234 ////////////////
1235 // 32ビット演算
1236 ////////////////
1237
1238 //2項目は32ビット整数として利用
1239 if(type[sp-1]==DEF_DOUBLE){
1240 //fld qword ptr[esp]
1241 op_fld_ptr_esp(DEF_DOUBLE);
1242
1243 //add esp,4
1244 op_add_esp(4);
1245
1246 //fistp dword ptr[esp]
1247 fpu_cast();
1248 OpBuffer[obp++]=(char)0xDB;
1249 OpBuffer[obp++]=(char)0x1C;
1250 OpBuffer[obp++]=(char)0x24;
1251 fpu_cast_end();
1252
1253 //pop ecx
1254 op_pop(REG_ECX);
1255 }
1256 else if(type[sp-1]==DEF_SINGLE){
1257 //fld dword ptr[esp]
1258 op_fld_ptr_esp(DEF_SINGLE);
1259
1260 //fistp dword ptr[esp]
1261 fpu_cast();
1262 OpBuffer[obp++]=(char)0xDB;
1263 OpBuffer[obp++]=(char)0x1C;
1264 OpBuffer[obp++]=(char)0x24;
1265 fpu_cast_end();
1266
1267 //pop ecx
1268 op_pop(REG_ECX);
1269 }
1270 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
1271 //pop ecx
1272 op_pop(REG_ECX);
1273
1274 //add esp,4
1275 op_add_esp(4);
1276 }
1277 else{
1278 //pop ecx
1279 op_pop(REG_ECX);
1280 }
1281
1282 if(type[sp-2]==DEF_DOUBLE){
1283 //fld qword ptr[esp]
1284 op_fld_ptr_esp(DEF_DOUBLE);
1285
1286 //add esp,4
1287 op_add_esp(4);
1288
1289 //fistp dword ptr[esp]
1290 fpu_cast();
1291 OpBuffer[obp++]=(char)0xDB;
1292 OpBuffer[obp++]=(char)0x1C;
1293 OpBuffer[obp++]=(char)0x24;
1294 fpu_cast_end();
1295 }
1296 else if(type[sp-2]==DEF_SINGLE){
1297 //fld dword ptr[esp]
1298 op_fld_ptr_esp(DEF_SINGLE);
1299
1300 //fistp dword ptr[esp]
1301 fpu_cast();
1302 OpBuffer[obp++]=(char)0xDB;
1303 OpBuffer[obp++]=(char)0x1C;
1304 OpBuffer[obp++]=(char)0x24;
1305 fpu_cast_end();
1306 }
1307
1308 //pop eax
1309 op_pop(REG_EAX);
1310
1311 //sub esp,4
1312 op_sub_esp(4);
1313
1314 //shl eax,cl
1315 OpBuffer[obp++]=(char)0xD3;
1316 OpBuffer[obp++]=(char)0xE0;
1317
1318 //mov dword ptr[esp],eax
1319 OpBuffer[obp++]=(char)0x89;
1320 OpBuffer[obp++]=(char)0x04;
1321 OpBuffer[obp++]=(char)0x24;
1322
1323 sp--;
1324
1325 //32ビット型にする
1326 if(IsSignedType(type[sp-1])) type[sp-1]=DEF_LONG;
1327 else type[sp-1]=DEF_DWORD;
1328 }
1329
1330 *pStackPointer=sp;
1331 return 1;
1332}
1333
1334BOOL Calc_SHR(int *type,int *pStackPointer){
1335 //右ビットシフト
1336 //value[sp-2]=value[sp-2]>>value[sp-1]
1337
1338 int sp;
1339 sp=*pStackPointer;
1340
1341 if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
1342 ////////////////
1343 // 64ビット演算
1344 ////////////////
1345
1346 //2項目は32ビット整数として利用
1347 if(type[sp-1]==DEF_DOUBLE){
1348 //fld qword ptr[esp]
1349 op_fld_ptr_esp(DEF_DOUBLE);
1350
1351 //add esp,4
1352 op_add_esp(4);
1353
1354 //fistp dword ptr[esp]
1355 fpu_cast();
1356 OpBuffer[obp++]=(char)0xDB;
1357 OpBuffer[obp++]=(char)0x1C;
1358 OpBuffer[obp++]=(char)0x24;
1359 fpu_cast_end();
1360
1361 //pop ecx
1362 op_pop(REG_ECX);
1363 }
1364 else if(type[sp-1]==DEF_SINGLE){
1365 //fld dword ptr[esp]
1366 op_fld_ptr_esp(DEF_SINGLE);
1367
1368 //fistp dword ptr[esp]
1369 fpu_cast();
1370 OpBuffer[obp++]=(char)0xDB;
1371 OpBuffer[obp++]=(char)0x1C;
1372 OpBuffer[obp++]=(char)0x24;
1373 fpu_cast_end();
1374
1375 //pop ecx
1376 op_pop(REG_ECX);
1377 }
1378 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
1379 //pop ecx
1380 op_pop(REG_ECX);
1381
1382 //add esp,4
1383 op_add_esp(4);
1384 }
1385 else{
1386 //pop ecx
1387 op_pop(REG_ECX);
1388 }
1389
1390 //第1項を64ビットに対応させる
1391 if(type[sp-2]==DEF_DOUBLE){
1392 //fld qword ptr[esp]
1393 op_fld_ptr_esp(DEF_DOUBLE);
1394
1395 //fistp qword ptr[esp]
1396 fpu_cast();
1397 OpBuffer[obp++]=(char)0xDF;
1398 OpBuffer[obp++]=(char)0x3C;
1399 OpBuffer[obp++]=(char)0x24;
1400 fpu_cast_end();
1401
1402 //pop eax
1403 op_pop(REG_EAX);
1404
1405 //pop edx
1406 op_pop(REG_EDX);
1407 }
1408 else if(type[sp-2]==DEF_SINGLE){
1409 //fld dword ptr[esp]
1410 op_fld_ptr_esp(DEF_SINGLE);
1411
1412 //sub esp,4
1413 op_sub_esp(4);
1414
1415 //fistp qword ptr[esp]
1416 fpu_cast();
1417 OpBuffer[obp++]=(char)0xDF;
1418 OpBuffer[obp++]=(char)0x3C;
1419 OpBuffer[obp++]=(char)0x24;
1420 fpu_cast_end();
1421
1422 //pop eax
1423 op_pop(REG_EAX);
1424
1425 //pop edx
1426 op_pop(REG_EDX);
1427 }
1428 else if(type[sp-2]==DEF_INT64||type[sp-2]==DEF_QWORD){
1429 //pop eax
1430 op_pop(REG_EAX);
1431
1432 //pop edx
1433 op_pop(REG_EDX);
1434 }
1435 else{
1436 //pop eax
1437 op_pop(REG_EAX);
1438
1439 if(IsSignedType(type[sp-2])){
1440 //符号拡張
1441 //edx:eax ← eax
1442
1443 //cdq
1444 op_cdq();
1445 }
1446 else{
1447 //ビット拡張
1448 //edx:eax ← eax
1449
1450 //xor edx,edx
1451 op_zero_reg(REG_EDX);
1452 }
1453 }
1454
1455 if(type[sp-2]==DEF_QWORD){
1456 //符号なし演算
1457
1458 //call _aullshr
1459 extern SUBINFO *pSub_aullshr;
1460 op_call(pSub_aullshr);
1461 }
1462 else{
1463 //符号あり演算
1464
1465 //call _allshr
1466 extern SUBINFO *pSub_allshr;
1467 op_call(pSub_allshr);
1468 }
1469
1470 //push edx
1471 op_push(REG_EDX);
1472
1473 //push eax
1474 op_push(REG_EAX);
1475
1476 sp--;
1477 }
1478 else{
1479 ////////////////
1480 // 32ビット演算
1481 ////////////////
1482
1483 //2項目は32ビット整数として利用
1484 if(type[sp-1]==DEF_DOUBLE){
1485 //fld qword ptr[esp]
1486 op_fld_ptr_esp(DEF_DOUBLE);
1487
1488 //add esp,4
1489 op_add_esp(4);
1490
1491 //fistp dword ptr[esp]
1492 fpu_cast();
1493 OpBuffer[obp++]=(char)0xDB;
1494 OpBuffer[obp++]=(char)0x1C;
1495 OpBuffer[obp++]=(char)0x24;
1496 fpu_cast_end();
1497
1498 //pop ecx
1499 op_pop(REG_ECX);
1500 }
1501 else if(type[sp-1]==DEF_SINGLE){
1502 //fld dword ptr[esp]
1503 op_fld_ptr_esp(DEF_SINGLE);
1504
1505 //fistp dword ptr[esp]
1506 fpu_cast();
1507 OpBuffer[obp++]=(char)0xDB;
1508 OpBuffer[obp++]=(char)0x1C;
1509 OpBuffer[obp++]=(char)0x24;
1510 fpu_cast_end();
1511
1512 //pop ecx
1513 op_pop(REG_ECX);
1514 }
1515 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
1516 //pop ecx
1517 op_pop(REG_ECX);
1518
1519 //add esp,4
1520 op_add_esp(4);
1521 }
1522 else{
1523 //pop ecx
1524 op_pop(REG_ECX);
1525 }
1526
1527 if(type[sp-2]==DEF_DOUBLE){
1528 //fld qword ptr[esp]
1529 op_fld_ptr_esp(DEF_DOUBLE);
1530
1531 //add esp,4
1532 op_add_esp(4);
1533
1534 //fistp dword ptr[esp]
1535 fpu_cast();
1536 OpBuffer[obp++]=(char)0xDB;
1537 OpBuffer[obp++]=(char)0x1C;
1538 OpBuffer[obp++]=(char)0x24;
1539 fpu_cast_end();
1540 }
1541 else if(type[sp-2]==DEF_SINGLE){
1542 //fld dword ptr[esp]
1543 op_fld_ptr_esp(DEF_SINGLE);
1544
1545 //fistp dword ptr[esp]
1546 fpu_cast();
1547 OpBuffer[obp++]=(char)0xDB;
1548 OpBuffer[obp++]=(char)0x1C;
1549 OpBuffer[obp++]=(char)0x24;
1550 fpu_cast_end();
1551 }
1552
1553 //pop eax
1554 op_pop(REG_EAX);
1555
1556 //sub esp,4
1557 op_sub_esp(4);
1558
1559 if(type[sp-2]==DEF_DWORD){
1560 //shr eax,cl
1561 OpBuffer[obp++]=(char)0xD3;
1562 OpBuffer[obp++]=(char)0xE8;
1563 }
1564 else{
1565 //sar eax,cl
1566 OpBuffer[obp++]=(char)0xD3;
1567 OpBuffer[obp++]=(char)0xF8;
1568 }
1569
1570 //mov dword ptr[esp],eax
1571 OpBuffer[obp++]=(char)0x89;
1572 OpBuffer[obp++]=(char)0x04;
1573 OpBuffer[obp++]=(char)0x24;
1574
1575 sp--;
1576
1577 //整数以外の型だったときはLong型にする
1578 if(!IsWholeNumberType(type[sp-1])) type[sp-1]=DEF_LONG;
1579 }
1580
1581 *pStackPointer=sp;
1582 return 1;
1583}
Note: See TracBrowser for help on using the repository browser.