Changeset 253 in dev for trunk/abdev/BasicCompiler32/x86CodeGenerator.cpp
- Timestamp:
- Jul 30, 2007, 4:12:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/x86CodeGenerator.cpp
r251 r253 124 124 /////////////////// 125 125 126 void CodeGenerator::op_mov_MV( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType )126 const PertialSchedule *CodeGenerator::op_mov_MV( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, long value, Schedule::Type valueScheduleType ) 127 127 { 128 128 //mov ptr[base_reg+offset],value 129 const PertialSchedule *pPertialSchedule = NULL; 129 130 130 131 if( op_size == sizeof(char) ) … … 132 133 pNativeCode->Put( (char)0xC6 ); 133 134 pNativeCode->Put( (char)(0x80|REGISTER_OPERAND(base_reg)) ); 135 136 if( isPertialSchedule ) 137 { 138 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 139 pPertialSchedule = pertialSchedules.back(); 140 } 134 141 pNativeCode->Put( offset, offsetScheduleType ); 142 135 143 pNativeCode->Put( (char)value ); 136 144 } … … 140 148 pNativeCode->Put( (char)0xC7 ); 141 149 pNativeCode->Put( (char)(0x80|REGISTER_OPERAND(base_reg)) ); 150 151 if( isPertialSchedule ) 152 { 153 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 154 pPertialSchedule = pertialSchedules.back(); 155 } 142 156 pNativeCode->Put( offset, offsetScheduleType ); 157 143 158 pNativeCode->Put( (short)value ); 144 159 } … … 147 162 pNativeCode->Put( (char)0xC7 ); 148 163 pNativeCode->Put( (char)(0x80|REGISTER_OPERAND(base_reg)) ); 164 165 if( isPertialSchedule ) 166 { 167 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 168 pPertialSchedule = pertialSchedules.back(); 169 } 149 170 pNativeCode->Put( offset, offsetScheduleType ); 171 150 172 pNativeCode->Put( value, valueScheduleType ); 151 173 } 174 175 return pPertialSchedule; 152 176 } 153 177 void CodeGenerator::op_mov_RV(int reg,long offset, Schedule::Type scheduleType ){ … … 169 193 pNativeCode->Put( (char)(0xC0| REGISTER_OPERAND(reg1)<<3 | REGISTER_OPERAND(reg2)) ); 170 194 } 171 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){195 const PertialSchedule *CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 172 196 //mov reg32,dword ptr[base_reg+offset] 173 197 //mov reg16,word ptr[base_reg+offset] … … 183 207 else opcode=(char)0x8B; 184 208 185 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );186 } 187 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){209 return __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 210 } 211 const PertialSchedule *CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){ 188 212 //mov reg32,dword ptr[base_reg1+base_reg2+offset] 189 213 //mov reg16,word ptr[base_reg1+base_reg2+offset] 190 214 //mov reg8,byte ptr[base_reg1+base_reg2+offset] 215 const PertialSchedule *pPertialSchedule = NULL; 191 216 192 217 if(base_reg1==REG_ESP){ … … 215 240 216 241 //オフセット値 242 if( isPertialSchedule ) 243 { 244 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 245 pPertialSchedule = pertialSchedules.back(); 246 } 217 247 pNativeCode->Put( offset, scheduleType ); 218 248 } … … 228 258 pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) ); 229 259 } 230 } 231 void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 260 return pPertialSchedule; 261 } 262 const PertialSchedule *CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 232 263 //mov dword ptr[base_reg+offset],reg32 233 264 //mov word ptr[base_reg+offset],reg16 … … 243 274 else opcode=(char)0x89; 244 275 245 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );246 } 247 void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){276 return __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 277 } 278 const PertialSchedule *CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){ 248 279 //mov dword ptr[base_reg1+base_reg2+offset],reg32 249 280 //mov word ptr[base_reg1+base_reg2+offset],reg16 250 281 //mov byte ptr[base_reg1+base_reg2+offset],reg8 282 const PertialSchedule *pPertialSchedule = NULL; 251 283 252 284 if(base_reg1==REG_ESP){ … … 275 307 276 308 //オフセット値 309 if( isPertialSchedule ) 310 { 311 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 312 pPertialSchedule = pertialSchedules.back(); 313 } 277 314 pNativeCode->Put( offset, scheduleType ); 278 315 } … … 288 325 pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) ); 289 326 } 327 return pPertialSchedule; 290 328 } 291 329 … … 355 393 ////////////////////////////////// 356 394 357 void CodeGenerator::op_lea_RM( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType )395 const PertialSchedule *CodeGenerator::op_lea_RM( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType, bool isPertialSchedule ) 358 396 { 359 397 //16ビット演算の命令プリフィックス … … 363 401 char opcode=(char)0x8D; 364 402 365 __op_format( op_prefix, opcode, 0, reg, base_reg, offset, mod, scheduleType );403 return __op_format( op_prefix, opcode, 0, reg, base_reg, offset, mod, scheduleType, isPertialSchedule ); 366 404 } 367 405 … … 408 446 pNativeCode->Put( cValue ); 409 447 } 410 void CodeGenerator::op_add_RV( int reg, long offset, Schedule::Type scheduleType )448 const PertialSchedule *CodeGenerator::op_add_RV( int reg, long offset, Schedule::Type scheduleType, bool isPertialSchedule ) 411 449 { 412 450 // add reg,offset 451 const PertialSchedule *pPertialSchedule = NULL; 413 452 414 453 if( reg == REG_EAX ) … … 416 455 // eaxのみ特殊 417 456 pNativeCode->Put( (char)0x05 ); 418 pNativeCode->Put( offset, scheduleType );419 457 } 420 458 else … … 422 460 pNativeCode->Put( (char)0x81 ); 423 461 pNativeCode->Put( (char)(0xC0|REGISTER_OPERAND(reg)) ); 424 pNativeCode->Put( offset, scheduleType ); 425 } 462 } 463 464 // オフセット値 465 if( isPertialSchedule ) 466 { 467 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 468 pPertialSchedule = pertialSchedules.back(); 469 } 470 pNativeCode->Put( offset, scheduleType ); 471 472 return pPertialSchedule; 426 473 } 427 474 void CodeGenerator::op_add_RR( int reg1, int reg2 ) … … 435 482 __op_format(op_prefix,opcode,0,reg1,reg2,0,MOD_REG); 436 483 } 437 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){484 const PertialSchedule *CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){ 438 485 //add reg32,dword ptr[base_reg+offset] 439 486 //add reg16,word ptr[base_reg+offset] … … 449 496 else opcode=(char)0x03; 450 497 451 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );498 return __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType, isPertialSchedule ); 452 499 } 453 500 void CodeGenerator::op_adc_RV8(int reg,char cValue){ … … 787 834 } 788 835 } 789 void CodeGenerator::op_sub_esp(long num){836 const PertialSchedule *CodeGenerator::op_sub_esp( long num, bool isPertialSchedule ){ 790 837 //スタックポインタの減算(push方向) 838 const PertialSchedule *pPertialSchedule = NULL; 791 839 792 840 //sub esp,num 793 if( 0xFFFFFF80&num){841 if( (0xFFFFFF80&num) != 0 || isPertialSchedule ){ 794 842 pNativeCode->Put( (char)0x81 ); 795 843 pNativeCode->Put( (char)0xEC ); 844 845 if( isPertialSchedule ) 846 { 847 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 848 pPertialSchedule = pertialSchedules.back(); 849 } 796 850 pNativeCode->Put( num ); 797 851 } … … 802 856 pNativeCode->Put( (char)num ); 803 857 } 858 859 return pPertialSchedule; 804 860 } 805 861 … … 922 978 } 923 979 } 924 void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){980 const PertialSchedule *CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType, bool isPertialSchedule ){ 925 981 //fld ptr[reg+offset] 982 const PertialSchedule *pPertialSchedule = NULL; 926 983 927 984 //オペコード … … 940 997 941 998 //オフセット値 999 if( isPertialSchedule ) 1000 { 1001 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 1002 pPertialSchedule = pertialSchedules.back(); 1003 } 942 1004 pNativeCode->Put( offset, scheduleType ); 943 } 944 void CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 1005 1006 return pPertialSchedule; 1007 } 1008 const PertialSchedule *CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){ 945 1009 //fld ptr[base_reg1+base_reg2+offset] 1010 const PertialSchedule *pPertialSchedule = NULL; 946 1011 947 1012 if(base_reg1==REG_ESP){ … … 969 1034 970 1035 //オフセット値 1036 if( isPertialSchedule ) 1037 { 1038 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 1039 pPertialSchedule = pertialSchedules.back(); 1040 } 971 1041 pNativeCode->Put( offset, scheduleType ); 972 1042 } … … 982 1052 pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) ); 983 1053 } 1054 1055 return pPertialSchedule; 984 1056 } 985 1057 void CodeGenerator::op_fstp_basereg(int type,int base_reg){ … … 1003 1075 } 1004 1076 } 1005 void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){1077 const PertialSchedule *CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType, bool isPertialSchedule ){ 1006 1078 //fstp ptr[reg+offset] 1079 const PertialSchedule *pPertialSchedule = NULL; 1007 1080 1008 1081 //オペコード … … 1021 1094 1022 1095 //オフセット値 1096 if( isPertialSchedule ) 1097 { 1098 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 1099 pPertialSchedule = pertialSchedules.back(); 1100 } 1023 1101 pNativeCode->Put( offset, scheduleType ); 1024 } 1025 void CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 1102 1103 return pPertialSchedule; 1104 } 1105 const PertialSchedule *CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){ 1026 1106 //fstp ptr[base_reg1+base_reg2+offset] 1107 const PertialSchedule *pPertialSchedule = NULL; 1027 1108 1028 1109 if(base_reg1==REG_ESP){ … … 1050 1131 1051 1132 //オフセット値 1133 if( isPertialSchedule ) 1134 { 1135 pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) ); 1136 pPertialSchedule = pertialSchedules.back(); 1137 } 1052 1138 pNativeCode->Put( offset, scheduleType ); 1053 1139 } … … 1063 1149 pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) ); 1064 1150 } 1151 1152 return pPertialSchedule; 1065 1153 } 1066 1154 void CodeGenerator::op_fistp_ptr_esp( int typeSize ){
Note:
See TracChangeset
for help on using the changeset viewer.