source: dev/BasicCompiler64/NumOpe_Logical.cpp@ 3

Last change on this file since 3 was 3, checked in by dai_9181, 17 years ago
File size: 2.4 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2#include "Opcode.h"
3
4BOOL CalcTwoTerm_Logical(int idCalc,int *type,LONG_PTR *index_stack,int *pStackPointer){
5 //value[sp-2] xor= value[sp-1]
6 //xor演算
7
8 int sp;
9 sp=*pStackPointer;
10
11 if(IsRealNumberType(type[sp-2])||IsRealNumberType(type[sp-1])){
12 //いずれかの項が実数のとき
13 SetError(45,"xor",cp);
14 return 0;
15 }
16
17 int reg1,reg2;
18
19 if(Is64Type(type[sp-2])||Is64Type(type[sp-1])){
20 //////////////////////
21 // 64ビット整数演算
22 //////////////////////
23
24 SetTowTermToReg_Whole64Calc(type,sp,&reg1,&reg2);
25
26 if(idCalc==CALC_XOR){
27 //xor reg1,reg2
28 op_xor_reg(sizeof(_int64),reg1,reg2);
29 }
30 else if(idCalc==CALC_OR){
31 //or reg1,reg2
32 op_or_reg(sizeof(_int64),reg1,reg2);
33 }
34 else if(idCalc==CALC_AND){
35 //and reg1,reg2
36 op_and_reg(sizeof(_int64),reg1,reg2);
37 }
38
39 if(reg1==REG_R14){
40 //mov qword ptr[rsp+offset],r14 ※スタックフレームを利用
41 pobj_sf->push(REG_R14);
42 }
43
44 sp--;
45 type[sp-1]=NeutralizationType(type[sp-1],index_stack[sp-1],type[sp],index_stack[sp]);
46 }
47 else{
48 //32ビット以下の整数演算
49
50 SetTowTermToReg_Whole32Calc(type,sp,&reg1,&reg2);
51
52 if(idCalc==CALC_ADDITION){
53 //add reg1,reg2
54 op_xor_reg(sizeof(long),reg1,reg2);
55 }
56 else if(idCalc==CALC_OR){
57 //or reg1,reg2
58 op_or_reg(sizeof(long),reg1,reg2);
59 }
60 else if(idCalc==CALC_AND){
61 //and reg1,reg2
62 op_and_reg(sizeof(long),reg1,reg2);
63 }
64
65 if(reg1==REG_R14){
66 //mov qword ptr[rsp+offset],r14 ※スタックフレームを利用
67 pobj_sf->push(REG_R14);
68 }
69
70 sp--;
71 type[sp-1]=NeutralizationType(type[sp-1],index_stack[sp-1],type[sp],index_stack[sp]);
72 }
73
74 *pStackPointer=sp;
75 return 1;
76}
77
78BOOL Calc_Not(int *type,int sp){
79 //value[sp-1]=Not value[sp-1]
80 //NOT演算子
81
82 if(IsRealNumberType(type[sp-1])){
83 //実数のとき
84 SetError(45,"Not",cp);
85 return 0;
86 }
87
88 int reg;
89
90 if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){
91 SetOneTermToReg_Whole64Calc(type[sp-1],&reg);
92
93 //not reg
94 op_not_reg(sizeof(_int64),reg);
95
96 if(reg==REG_R14){
97 //mov qword ptr[rsp+offset],r14 ※スタックフレームを利用
98 pobj_sf->push(REG_R14);
99 }
100 }
101 else if(IsWholeNumberType(type[sp-1])){
102 SetOneTermToReg_Whole32Calc(type[sp-1],&reg);
103
104 //not reg
105 op_not_reg(sizeof(long),reg);
106
107 if(reg==REG_R14){
108 //mov qword ptr[rsp+offset],r14 ※スタックフレームを利用
109 pobj_sf->push(REG_R14);
110 }
111 }
112
113 return 1;
114}
Note: See TracBrowser for help on using the repository browser.