Changeset 229 in dev for trunk/abdev/BasicCompiler32/CodeGenerator.cpp
- Timestamp:
- Jul 24, 2007, 11:35:33 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/CodeGenerator.cpp
r225 r229 19 19 #define INDEX_NON 0x04 20 20 21 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp ){21 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType ){ 22 22 if(mod==MOD_DISP32){ 23 23 //ModR/Mバイト … … 59 59 else 60 60 { 61 pNativeCode->Put( disp );61 pNativeCode->Put( disp, scheduleType ); 62 62 } 63 63 } … … 75 75 pNativeCode->Put( (char)(opcode|REGISTER_OPERAND(reg)) ); 76 76 } 77 void CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod ){77 void CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 78 78 //命令プリフィックス 79 79 if(op_prefix) … … 90 90 91 91 //ModR/M, SIB, disp 92 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset );92 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType ); 93 93 } 94 94 … … 99 99 /////////////////// 100 100 101 void CodeGenerator::op_mov_RV(int reg,long offset ){101 void CodeGenerator::op_mov_RV(int reg,long offset, Schedule::Type scheduleType ){ 102 102 //mov reg,value 103 103 … … 106 106 107 107 //DISP32 108 pNativeCode->Put( offset ); 109 } 110 void CodeGenerator::op_mov_RV(int op_size,int reg,int offset){ 111 if(op_size==PTR_SIZE) op_mov_RV(reg,offset); 112 else SetError(300,NULL,cp); 108 pNativeCode->Put( offset, scheduleType ); 113 109 } 114 110 void CodeGenerator::op_mov_RR(int reg1,int reg2){ … … 121 117 pNativeCode->Put( (char)(0xC0| REGISTER_OPERAND(reg1)<<3 | REGISTER_OPERAND(reg2)) ); 122 118 } 123 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod ){119 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 124 120 //mov reg32,dword ptr[base_reg+offset] 125 121 //mov reg16,word ptr[base_reg+offset] … … 135 131 else opcode=(char)0x8B; 136 132 137 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod );138 } 139 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){133 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 134 } 135 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 140 136 //mov reg32,dword ptr[base_reg1+base_reg2+offset] 141 137 //mov reg16,word ptr[base_reg1+base_reg2+offset] … … 167 163 168 164 //オフセット値 169 pNativeCode->Put( offset );165 pNativeCode->Put( offset, scheduleType ); 170 166 } 171 167 else{ … … 181 177 } 182 178 } 183 void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod ){179 void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 184 180 //mov dword ptr[base_reg+offset],reg32 185 181 //mov word ptr[base_reg+offset],reg16 … … 195 191 else opcode=(char)0x89; 196 192 197 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod );198 } 199 void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){193 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 194 } 195 void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 200 196 //mov dword ptr[base_reg1+base_reg2+offset],reg32 201 197 //mov word ptr[base_reg1+base_reg2+offset],reg16 … … 227 223 228 224 //オフセット値 229 pNativeCode->Put( offset );225 pNativeCode->Put( offset, scheduleType ); 230 226 } 231 227 else{ … … 353 349 __op_format(op_prefix,opcode,0,reg1,reg2,0,MOD_REG); 354 350 } 355 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod ){351 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 356 352 //add reg32,dword ptr[base_reg+offset] 357 353 //add reg16,word ptr[base_reg+offset] … … 367 363 else opcode=(char)0x03; 368 364 369 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod );365 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 370 366 } 371 367 void CodeGenerator::op_adc_RV8(int reg,char cValue){ … … 656 652 __op_format( (char)0xFF, (char)0x30, base_reg ); 657 653 } 654 void CodeGenerator::op_push_M( int base_reg, long offset, Schedule::Type scheduleType ) 655 { 656 if( base_reg == REG_NON ) 657 { 658 // push dword ptr[offset] 659 __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, 0, offset, MOD_DISP32, scheduleType ); 660 } 661 else 662 { 663 // push dword ptr[base_reg+offset] 664 __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, base_reg, offset, MOD_BASE_DISP32, scheduleType ); 665 } 666 } 658 667 void CodeGenerator::op_pop(int reg){ 659 668 //pop reg … … 821 830 } 822 831 } 823 void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset ){832 void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){ 824 833 //fld ptr[reg+offset] 825 834 … … 839 848 840 849 //オフセット値 841 pNativeCode->Put( offset );842 } 843 void CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){850 pNativeCode->Put( offset, scheduleType ); 851 } 852 void CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 844 853 //fld ptr[base_reg1+base_reg2+offset] 845 854 … … 868 877 869 878 //オフセット値 870 pNativeCode->Put( offset );879 pNativeCode->Put( offset, scheduleType ); 871 880 } 872 881 else{ … … 902 911 } 903 912 } 904 void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset ){913 void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){ 905 914 //fstp ptr[reg+offset] 906 915 … … 920 929 921 930 //オフセット値 922 pNativeCode->Put( offset );923 } 924 void CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){931 pNativeCode->Put( offset, scheduleType ); 932 } 933 void CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 925 934 //fstp ptr[base_reg1+base_reg2+offset] 926 935 … … 949 958 950 959 //オフセット値 951 pNativeCode->Put( offset );960 pNativeCode->Put( offset, scheduleType ); 952 961 } 953 962 else{
Note:
See TracChangeset
for help on using the changeset viewer.