Changeset 230 in dev
- Timestamp:
- Jul 24, 2007, 7:11:26 PM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/CodeGenerator.cpp
r229 r230 300 300 301 301 ////////////////////////////////// 302 // lea関連 303 ////////////////////////////////// 304 305 void CodeGenerator::op_lea_RM( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType ) 306 { 307 //16ビット演算の命令プリフィックス 308 char op_prefix=0; 309 310 //オペコード 311 char opcode=(char)0x8D; 312 313 __op_format( op_prefix, opcode, 0, reg, base_reg, offset, mod, scheduleType ); 314 } 315 316 317 318 ////////////////////////////////// 302 319 // インクリメント・デクリメント 303 320 ////////////////////////////////// … … 338 355 pNativeCode->Put( (char)(0xC0|REGISTER_OPERAND(reg)) ); 339 356 pNativeCode->Put( cValue ); 357 } 358 void CodeGenerator::op_add_RV( int reg, long offset, Schedule::Type scheduleType ) 359 { 360 // add reg,offset 361 pNativeCode->Put( (char)0x81 ); 362 pNativeCode->Put( (char)(0xC0|REGISTER_OPERAND(reg)) ); 363 pNativeCode->Put( offset, scheduleType ); 340 364 } 341 365 void CodeGenerator::op_add_RR( int reg1, int reg2 ) -
trunk/abdev/BasicCompiler32/Compile_Set_Var.cpp
r225 r230 95 95 if(pRelativeVar->bOffsetOffset){ 96 96 //fstp ptr[ecx+offset] 97 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_ECX,(int)pRelativeVar->offset); 98 obp-=sizeof(long); 99 pobj_GlobalVarSchedule->add(); 100 obp+=sizeof(long); 97 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_ECX,(int)pRelativeVar->offset, Schedule::GlobalVar ); 101 98 } 102 99 else{ 103 100 //mov ecx,offset 104 compiler.codeGenerator.op_mov_RV(REG_ECX,(int)pRelativeVar->offset); 105 obp-=sizeof(long); 106 pobj_GlobalVarSchedule->add(); 107 obp+=sizeof(long); 101 compiler.codeGenerator.op_mov_RV(REG_ECX,(int)pRelativeVar->offset, Schedule::GlobalVar ); 108 102 109 103 //fstp ptr[ecx] … … 114 108 if(pRelativeVar->bOffsetOffset){ 115 109 //add ecx,qword ptr[offset] 116 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32 );110 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar ); 117 111 } 118 112 else{ 119 113 //mov ecx,qword ptr[offset] 120 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 121 } 122 obp-=sizeof(long); 123 pobj_GlobalVarSchedule->add(); 124 obp+=sizeof(long); 114 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar ); 115 } 125 116 126 117 goto directmem; … … 129 120 if(pRelativeVar->bOffsetOffset){ 130 121 //fstp ptr[ebp+ecx+offset] 131 compiler.codeGenerator.op_fstp_base_offset_ex(VarType,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET );122 compiler.codeGenerator.op_fstp_base_offset_ex(VarType,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar ); 132 123 } 133 124 else{ 134 125 //fstp ptr[ebp+offset] 135 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_EBP,(int)pRelativeVar->offset); 136 } 137 obp-=sizeof(long); 138 AddLocalVarAddrSchedule(); 139 obp+=sizeof(long); 126 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_EBP,(int)pRelativeVar->offset, Schedule::LocalVar ); 127 } 140 128 } 141 129 else if(pRelativeVar->dwKind==VAR_REFLOCAL){ 142 130 if(pRelativeVar->bOffsetOffset){ 143 131 //add ecx,qword ptr[ebp+offset] 144 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32 );132 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 145 133 } 146 134 else{ 147 135 //mov ecx,qword ptr[ebp+offset] 148 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 149 } 150 obp-=sizeof(long); 151 AddLocalVarAddrSchedule(); 152 obp+=sizeof(long); 136 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 137 } 153 138 154 139 goto directmem; … … 328 313 if(pRelative->bOffsetOffset){ 329 314 //mov ptr[ecx+offset],eax/ax/al 330 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_ECX,(int)pRelative->offset,MOD_BASE_DISP32 );315 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_ECX,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::GlobalVar ); 331 316 } 332 317 else{ 333 318 //mov ptr[offset],eax/ax/al 334 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,0,(int)pRelative->offset,MOD_DISP32); 335 } 336 obp-=sizeof(long); 337 pobj_GlobalVarSchedule->add(); 338 obp+=sizeof(long); 319 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,0,(int)pRelative->offset,MOD_DISP32, Schedule::GlobalVar ); 320 } 339 321 } 340 322 else if(pRelative->dwKind==VAR_REFGLOBAL){ … … 344 326 if(pRelative->bOffsetOffset){ 345 327 //add ecx,qword ptr[offset] 346 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32 );328 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32, Schedule::GlobalVar ); 347 329 } 348 330 else{ 349 331 //mov ecx,qword ptr[offset] 350 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32); 351 } 352 obp-=sizeof(long); 353 pobj_GlobalVarSchedule->add(); 354 obp+=sizeof(long); 332 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32, Schedule::GlobalVar ); 333 } 355 334 356 335 goto directmem; … … 359 338 if(pRelative->bOffsetOffset){ 360 339 //mov ptr[ebp+ecx+offset],eax/ax/al 361 compiler.codeGenerator.op_mov_MR_ex(varSize,REG_EAX,REG_EBP,REG_ECX,(int)pRelative->offset,USE_OFFSET );340 compiler.codeGenerator.op_mov_MR_ex(varSize,REG_EAX,REG_EBP,REG_ECX,(int)pRelative->offset,USE_OFFSET, Schedule::LocalVar ); 362 341 } 363 342 else{ 364 343 //mov ptr[ebp+offset],eax/ax/al 365 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32); 366 } 367 obp-=sizeof(long); 368 AddLocalVarAddrSchedule(); 369 obp+=sizeof(long); 344 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 345 } 370 346 } 371 347 else if(pRelative->dwKind==VAR_REFLOCAL){ 372 348 if(pRelative->bOffsetOffset){ 373 349 //add ecx,ptr[ebp+offset] 374 compiler.codeGenerator.op_add_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32 );350 compiler.codeGenerator.op_add_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 375 351 } 376 352 else{ 377 353 //mov ecx,ptr[ebp+offset] 378 compiler.codeGenerator.op_mov_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32); 379 } 380 obp-=sizeof(long); 381 AddLocalVarAddrSchedule(); 382 obp+=sizeof(long); 354 compiler.codeGenerator.op_mov_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 355 } 383 356 384 357 goto directmem; -
trunk/abdev/BasicCompiler32/Compile_Var.cpp
r225 r230 857 857 858 858 //mov dword ptr[offset],eax 859 OpBuffer[obp++]=(char)0xA3; 860 *((long *)(OpBuffer+obp))=offset; 861 pobj_GlobalVarSchedule->add(); 862 obp+=sizeof(long); 859 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, 0, offset, MOD_DISP32, Schedule::GlobalVar ); 863 860 } 864 861 else{ … … 1250 1247 if(pRelativeVar->bOffsetOffset){ 1251 1248 //lea eax,dword ptr[ecx+offset] 1252 OpBuffer[obp++]=(char)0x8D; 1253 OpBuffer[obp++]=(char)0x81; 1254 *((long *)(OpBuffer+obp))=pRelativeVar->offset; 1255 pobj_GlobalVarSchedule->add(); 1256 obp+=sizeof(long); 1249 compiler.codeGenerator.op_lea_RM( REG_EAX, REG_ECX, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar ); 1257 1250 } 1258 1251 else{ 1259 1252 //mov eax,offset 1260 OpBuffer[obp++]=(char)0xB8; 1261 *((long *)(OpBuffer+obp))=pRelativeVar->offset; 1262 pobj_GlobalVarSchedule->add(); 1263 obp+=sizeof(long); 1253 compiler.codeGenerator.op_mov_RV( REG_EAX, pRelativeVar->offset, Schedule::GlobalVar ); 1264 1254 } 1265 1255 } … … 1271 1261 1272 1262 //add eax,dword ptr[offset] 1273 compiler.codeGenerator.op_add_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );1263 compiler.codeGenerator.op_add_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32, Schedule::GlobalVar ); 1274 1264 } 1275 1265 else{ 1276 1266 //mov eax,dword ptr[offset] 1277 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 ); 1278 } 1279 obp-=sizeof(long); 1280 pobj_GlobalVarSchedule->add(); 1281 obp+=sizeof(long); 1267 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32, Schedule::GlobalVar ); 1268 } 1282 1269 } 1283 1270 else if(pRelativeVar->dwKind==VAR_LOCAL){ 1284 1271 if(pRelativeVar->bOffsetOffset){ 1285 1272 //add ecx,offset 1286 OpBuffer[obp++]=(char)0x81; 1287 OpBuffer[obp++]=(char)0xC1; 1288 *((long *)(OpBuffer+obp))=pRelativeVar->offset; 1289 AddLocalVarAddrSchedule(); 1290 obp+=sizeof(long); 1273 compiler.codeGenerator.op_add_RV( REG_ECX, pRelativeVar->offset, Schedule::LocalVar ); 1291 1274 1292 1275 //lea eax,dword ptr[ebp+ecx] … … 1297 1280 } 1298 1281 else{ 1299 //lea eax,dword ptr[ebp+offset] 1300 OpBuffer[obp++]=(char)0x8D; 1301 OpBuffer[obp++]=(char)0x85; 1302 *((long *)(OpBuffer+obp))=pRelativeVar->offset; 1303 AddLocalVarAddrSchedule(); 1304 obp+=sizeof(long); 1282 //lea eax,dword ptr[ecx+offset] 1283 compiler.codeGenerator.op_lea_RM( REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1305 1284 } 1306 1285 } -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r229 r230 142 142 void op_movsx_R32R8 (int reg32,int reg8 = REG_NON); 143 143 void op_movsx_R16R8 (int reg16,int reg8 = REG_NON); 144 void op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None ); 144 145 void op_inc (int reg); 145 146 void op_dec (int reg); 146 147 void op_add_RV8 (int reg,char cValue); 148 void op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None ); 147 149 void op_add_RR ( int reg1, int reg2 ); 148 150 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );
Note:
See TracChangeset
for help on using the changeset viewer.