Changeset 253 in dev
- Timestamp:
- Jul 30, 2007, 4:12:54 PM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Calc_PushVar.cpp
r231 r253 26 26 if(pRelativeVar->bOffsetOffset){ 27 27 //fld ptr[ebp+ecx+offset] 28 compiler.codeGenerator.op_fld_base_offset_ex(type,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar ); 28 compiler.codeGenerator.localVarPertialSchedules.push_back( 29 compiler.codeGenerator.op_fld_base_offset_ex(type,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET, Schedule::None, true ) 30 ); 29 31 } 30 32 else{ 31 33 //fld ptr[ebp+offset] 32 compiler.codeGenerator.op_fld_base_offset(type,REG_EBP,(int)pRelativeVar->offset, Schedule::LocalVar ); 34 compiler.codeGenerator.localVarPertialSchedules.push_back( 35 compiler.codeGenerator.op_fld_base_offset(type,REG_EBP,(int)pRelativeVar->offset, Schedule::None, true ) 36 ); 33 37 } 34 38 } … … 36 40 if(pRelativeVar->bOffsetOffset){ 37 41 //add ecx,qword ptr[ebp+offset] 38 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 42 compiler.codeGenerator.localVarPertialSchedules.push_back( 43 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 44 ); 39 45 } 40 46 else{ 41 47 //mov ecx,qword ptr[ebp+offset] 42 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 48 compiler.codeGenerator.localVarPertialSchedules.push_back( 49 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 50 ); 43 51 } 44 52 … … 102 110 if(pRelativeVar->bOffsetOffset){ 103 111 //mov reg, ptr[ebp+ecx+offset] 104 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET, Schedule::LocalVar ); 112 compiler.codeGenerator.localVarPertialSchedules.push_back( 113 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET, Schedule::None, true ) 114 ); 105 115 } 106 116 else{ 107 117 //mov reg, ptr[ebp+offset] 108 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32, Schedule::LocalVar ); 118 compiler.codeGenerator.localVarPertialSchedules.push_back( 119 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32, Schedule::None, true ) 120 ); 109 121 } 110 122 } … … 112 124 if(pRelativeVar->bOffsetOffset){ 113 125 //add ecx,qword ptr[ebp+offset] 114 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 126 compiler.codeGenerator.localVarPertialSchedules.push_back( 127 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 128 ); 115 129 } 116 130 else{ 117 131 //mov ecx,qword ptr[ebp+offset] 118 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 132 compiler.codeGenerator.localVarPertialSchedules.push_back( 133 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 134 ); 119 135 } 120 136 … … 162 178 if(pRelativeVar->bOffsetOffset){ 163 179 //add ecx,offset 164 compiler.codeGenerator.op_add_RV( REG_ECX, pRelativeVar->offset, Schedule::LocalVar ); 180 compiler.codeGenerator.localVarPertialSchedules.push_back( 181 compiler.codeGenerator.op_add_RV( REG_ECX, pRelativeVar->offset, Schedule::None, true ) 182 ); 165 183 166 184 //push dword ptr[ebp+ecx] … … 174 192 else{ 175 193 //push dword ptr[ebp+offset] 176 compiler.codeGenerator.op_push_M( REG_EBP, pRelativeVar->offset, Schedule::LocalVar ); 194 compiler.codeGenerator.localVarPertialSchedules.push_back( 195 compiler.codeGenerator.op_push_M( REG_EBP, pRelativeVar->offset, Schedule::None, true ) 196 ); 177 197 } 178 198 } 179 199 else if(pRelativeVar->dwKind==VAR_REFLOCAL){ 180 200 //mov eax,dword ptr[ebp+offset] 181 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 201 compiler.codeGenerator.localVarPertialSchedules.push_back( 202 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true ) 203 ); 182 204 183 205 if(pRelativeVar->bOffsetOffset){ -
trunk/abdev/BasicCompiler32/Compile_CallProc.cpp
r250 r253 7 7 #include "../BasicCompiler_Common/common.h" 8 8 #include "Opcode.h" 9 10 //ローカル変数アドレススケジュール11 DWORD *pLocalVarAddrSchedule;12 int LocalVarAddrScheduleNum;13 9 14 10 void Call_DebugSys_SaveContext(){ … … 27 23 compiler.codeGenerator.op_call(pSub_DebugSys_SaveContext); 28 24 } 29 30 void AddLocalVarAddrSchedule(){31 extern HANDLE hHeap;32 33 //ローカル変数アドレススケジュールに追加する34 pLocalVarAddrSchedule=(DWORD *)HeapReAlloc(hHeap,0,pLocalVarAddrSchedule,(LocalVarAddrScheduleNum+1)*sizeof(DWORD));35 pLocalVarAddrSchedule[LocalVarAddrScheduleNum]=obp;36 LocalVarAddrScheduleNum++;37 }38 39 25 40 26 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer){ -
trunk/abdev/BasicCompiler32/Compile_Object.cpp
r250 r253 16 16 //をセットしておかなければならない 17 17 18 int jnz_back; 19 20 21 //jnzの番地 22 jnz_back=obp; 18 //jnzのジャンプ先番地 19 extern int obp; 20 int jnz_back = obp; 23 21 24 22 if(bSomeObjects){ … … 263 261 264 262 //jnzの番地 265 int jnz_back;266 jnz_back=obp;263 extern int obp; 264 int jnz_back = obp; 267 265 268 266 //push ecx -
trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
r252 r253 236 236 extern HANDLE hHeap; 237 237 extern BOOL bDebugCompile; 238 int i3,i4, LocalVarSchedule,BaseOffset;238 int i3,i4,BaseOffset; 239 239 char temporary[VN_SIZE]; 240 240 … … 263 263 else bDebugSupportProc=0; 264 264 265 extern int obp; 265 266 pUserProc->SetBeginOpAddress( obp ); 266 267 … … 306 307 extern int AllLocalVarSize; 307 308 AllLocalVarSize=0; 308 309 //ローカル変数アドレススケジュール310 extern DWORD *pLocalVarAddrSchedule;311 extern int LocalVarAddrScheduleNum;312 pLocalVarAddrSchedule=(DWORD *)HeapAlloc(hHeap,0,1);313 LocalVarAddrScheduleNum=0;314 309 315 310 //パラメータ用の変数データを考慮 … … 362 357 363 358 //sub esp,AllLocalVarSize(スケジュール) 364 compiler.codeGenerator.op_sub_esp(0xFFFFFFFF); 365 LocalVarSchedule=obp-sizeof(long); 359 const PertialSchedule *pAllLocalVarPertialSchedule = compiler.codeGenerator.op_sub_esp( 0, true ); 366 360 367 361 //push ebp … … 641 635 { 642 636 //fld qword ptr[ebp+offset] 643 compiler.codeGenerator.op_fld_base_offset( i3, REG_EBP, RelativeVar.offset, Schedule::LocalVar ); 637 compiler.codeGenerator.localVarPertialSchedules.push_back( 638 compiler.codeGenerator.op_fld_base_offset( i3, REG_EBP, RelativeVar.offset, Schedule::None, true ) 639 ); 644 640 } 645 641 else if(i3==DEF_INT64||i3==DEF_QWORD){ 646 642 //mov eax,dword ptr[ebp+offset] 647 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::LocalVar ); 643 compiler.codeGenerator.localVarPertialSchedules.push_back( 644 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::None, true ) 645 ); 648 646 649 647 //mov edx,dword ptr[ebp+offset+sizeof(long)] 650 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_EBP, RelativeVar.offset+sizeof(long), MOD_BASE_DISP32, Schedule::LocalVar ); 648 compiler.codeGenerator.localVarPertialSchedules.push_back( 649 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_EBP, RelativeVar.offset+sizeof(long), MOD_BASE_DISP32, Schedule::None, true ) 650 ); 651 651 } 652 652 else if(i3==DEF_LONG||i3==DEF_DWORD|| 653 IsPtrType(i3)){ 653 IsPtrType(i3)) 654 { 654 655 //mov eax,dword ptr[ebp+offset] 655 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::LocalVar ); 656 compiler.codeGenerator.localVarPertialSchedules.push_back( 657 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::None, true ) 658 ); 656 659 } 657 660 else if(i3==DEF_INTEGER||i3==DEF_WORD || (Smoothie::IsUnicode()&&i3==DEF_CHAR)){ … … 660 663 661 664 //mov ax,word ptr[ebp+offset] 662 compiler.codeGenerator.op_mov_RM( sizeof(short), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::LocalVar ); 665 compiler.codeGenerator.localVarPertialSchedules.push_back( 666 compiler.codeGenerator.op_mov_RM( sizeof(short), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::None, true ) 667 ); 663 668 } 664 669 else if(i3==DEF_SBYTE||i3==DEF_BYTE||i3==DEF_BOOLEAN || (Smoothie::IsUnicode()==false&&i3==DEF_CHAR)){ … … 667 672 668 673 //mov al,byte ptr[ebp+offset] 669 compiler.codeGenerator.op_mov_RM( sizeof(char), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::LocalVar ); 674 compiler.codeGenerator.localVarPertialSchedules.push_back( 675 compiler.codeGenerator.op_mov_RM( sizeof(char), REG_EAX, REG_EBP, RelativeVar.offset, MOD_BASE_DISP32, Schedule::None, true ) 676 ); 670 677 } 671 678 } 672 679 673 680 //ローカル変数アドレススケジュール 674 for(i3=0;i3<LocalVarAddrScheduleNum;i3++){ 675 *((long *)(OpBuffer+pLocalVarAddrSchedule[i3]))+=AllLocalVarSize; 676 } 677 HeapDefaultFree(pLocalVarAddrSchedule); 681 BOOST_FOREACH( const PertialSchedule *pPertialSchedule, compiler.codeGenerator.localVarPertialSchedules ) 682 { 683 compiler.codeGenerator.opfix_offset( pPertialSchedule, AllLocalVarSize ); 684 } 685 compiler.codeGenerator.localVarPertialSchedules.clear(); 678 686 BOOST_FOREACH( Variable *pVar, pUserProc->GetLocalVars() ){ 679 687 //後にデバッグで利用する … … 685 693 686 694 //ローカル変数用メモリを確保するためのスケジュール(subコマンド) 687 *((long *)(OpBuffer+LocalVarSchedule))=AllLocalVarSize-BaseOffset;695 compiler.codeGenerator.opfix( pAllLocalVarPertialSchedule, AllLocalVarSize - BaseOffset ); 688 696 689 697 //pop edi -
trunk/abdev/BasicCompiler32/Compile_Set_Var.cpp
r236 r253 120 120 if(pRelativeVar->bOffsetOffset){ 121 121 //fstp ptr[ebp+ecx+offset] 122 compiler.codeGenerator.op_fstp_base_offset_ex(VarType,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar ); 122 compiler.codeGenerator.localVarPertialSchedules.push_back( 123 compiler.codeGenerator.op_fstp_base_offset_ex(VarType,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET, Schedule::None, true ) 124 ); 123 125 } 124 126 else{ 125 127 //fstp ptr[ebp+offset] 126 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_EBP,(int)pRelativeVar->offset, Schedule::LocalVar ); 128 compiler.codeGenerator.localVarPertialSchedules.push_back( 129 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_EBP,(int)pRelativeVar->offset, Schedule::None, true ) 130 ); 127 131 } 128 132 } … … 130 134 if(pRelativeVar->bOffsetOffset){ 131 135 //add ecx,qword ptr[ebp+offset] 132 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 136 compiler.codeGenerator.localVarPertialSchedules.push_back( 137 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 138 ); 133 139 } 134 140 else{ 135 141 //mov ecx,qword ptr[ebp+offset] 136 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 142 compiler.codeGenerator.localVarPertialSchedules.push_back( 143 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true ) 144 ); 137 145 } 138 146 … … 239 247 // 64bitへ 240 248 // st(0) -> edx:eax 241 breakpoint;242 249 243 250 //push … … 338 345 if(pRelative->bOffsetOffset){ 339 346 //mov ptr[ebp+ecx+offset],eax/ax/al 340 compiler.codeGenerator.op_mov_MR_ex(varSize,REG_EAX,REG_EBP,REG_ECX,(int)pRelative->offset,USE_OFFSET, Schedule::LocalVar ); 347 compiler.codeGenerator.localVarPertialSchedules.push_back( 348 compiler.codeGenerator.op_mov_MR_ex(varSize,REG_EAX,REG_EBP,REG_ECX,(int)pRelative->offset,USE_OFFSET, Schedule::None, true ) 349 ); 341 350 } 342 351 else{ 343 352 //mov ptr[ebp+offset],eax/ax/al 344 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 353 compiler.codeGenerator.localVarPertialSchedules.push_back( 354 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 355 ); 345 356 } 346 357 } … … 348 359 if(pRelative->bOffsetOffset){ 349 360 //add ecx,ptr[ebp+offset] 350 compiler.codeGenerator.op_add_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 361 compiler.codeGenerator.localVarPertialSchedules.push_back( 362 compiler.codeGenerator.op_add_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 363 ); 351 364 } 352 365 else{ 353 366 //mov ecx,ptr[ebp+offset] 354 compiler.codeGenerator.op_mov_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 367 compiler.codeGenerator.localVarPertialSchedules.push_back( 368 compiler.codeGenerator.op_mov_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32, Schedule::None, true ) 369 ); 355 370 } 356 371 -
trunk/abdev/BasicCompiler32/Compile_Statement.cpp
r250 r253 240 240 241 241 //レキシカルスコープをレベルアップ 242 extern int obp; 242 243 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_IF ); 243 244 … … 308 309 { 309 310 //jmp ...(schedule) 310 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( (const std::string)(Parameter + 1), obp, cp ) ); 311 extern int obp; 312 compiler.codeGenerator.op_jmp_goto_schedule( (const std::string)(Parameter + 1), 0, cp ); 311 313 } 312 314 else 313 315 { 314 316 //jmp ... 317 extern int obp; 315 318 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 316 319 } … … 323 326 { 324 327 //jmp ...(schedule) 325 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( LineNum, obp, cp ) ); 328 extern int obp; 329 compiler.codeGenerator.op_jmp_goto_schedule( "", LineNum, cp ); 326 330 } 327 331 else 328 332 { 329 333 //jmp ... 334 extern int obp; 330 335 compiler.codeGenerator.op_jmp( i-obp, sizeof(long), false, true ); 331 336 } … … 436 441 437 442 //レキシカルスコープをレベルアップ 443 extern int obp; 438 444 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_WHILE ); 439 445 … … 552 558 553 559 //レキシカルスコープをレベルアップ 560 extern int obp; 554 561 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_FOR ); 555 562 … … 588 595 589 596 //レキシカルスコープをレベルアップ 597 extern int obp; 590 598 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_DO ); 591 599 … … 1030 1038 1031 1039 //レキシカルスコープをレベルアップ 1040 extern int obp; 1032 1041 compiler.codeGenerator.lexicalScopes.Start( obp, LexicalScope::SCOPE_TYPE_SELECT ); 1033 1042 … … 1079 1088 void OpcodeGosub(char *Parameter){ 1080 1089 extern HANDLE hHeap; 1090 extern int obp; 1081 1091 int i,LineNum; 1082 1092 … … 1087 1097 { 1088 1098 //jmp ...(schedule) 1089 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( (const std::string)(Parameter + 1), obp, cp ));1099 compiler.codeGenerator.op_jmp_goto_schedule( (const std::string)(Parameter + 1), 0, cp ); 1090 1100 } 1091 1101 else … … 1102 1112 { 1103 1113 //jmp ...(schedule) 1104 compiler.codeGenerator.op_jmp_goto_schedule( GotoLabelSchedule( LineNum, obp, cp ));1114 compiler.codeGenerator.op_jmp_goto_schedule( "", LineNum, cp ); 1105 1115 } 1106 1116 else -
trunk/abdev/BasicCompiler32/Compile_Var.cpp
r250 r253 963 963 964 964 //mov dword ptr[ebp+offset+sizeof(long)],eax 965 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset+sizeof(long), MOD_BASE_DISP32, Schedule::LocalVar ); 965 compiler.codeGenerator.localVarPertialSchedules.push_back( 966 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset+sizeof(long), MOD_BASE_DISP32, Schedule::None, true ) 967 ); 966 968 967 969 //mov eax,LOLONG(dbl) … … 969 971 970 972 //mov dword ptr[ebp+offset],eax 971 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::LocalVar ); 973 compiler.codeGenerator.localVarPertialSchedules.push_back( 974 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::None, true ) 975 ); 972 976 } 973 977 else if( type.IsSingle() ){ … … 979 983 980 984 //mov dword ptr[ebp+offset],eax 981 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::LocalVar ); 985 compiler.codeGenerator.localVarPertialSchedules.push_back( 986 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::None, true ) 987 ); 982 988 } 983 989 else if( type.Is64() ){ … … 986 992 987 993 //mov dword ptr[ebp+offset+sizeof(long)],eax 988 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset+sizeof(long), MOD_BASE_DISP32, Schedule::LocalVar ); 994 compiler.codeGenerator.localVarPertialSchedules.push_back( 995 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset+sizeof(long), MOD_BASE_DISP32, Schedule::None, true ) 996 ); 989 997 990 998 //mov eax,LOLONG(i64data) … … 992 1000 993 1001 //mov dword ptr[ebp+offset],eax 994 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1002 compiler.codeGenerator.localVarPertialSchedules.push_back( 1003 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::None, true ) 1004 ); 995 1005 } 996 1006 else if( type.IsDWord() || type.IsLong() || type.IsPointer() ){ … … 1012 1022 1013 1023 //mov dword ptr[ebp+offset],eax 1014 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1024 compiler.codeGenerator.localVarPertialSchedules.push_back( 1025 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::None, true ) 1026 ); 1015 1027 } 1016 1028 else if( type.IsWord() || type.IsInteger() ){ 1017 1029 //mov word ptr[ebp+offset],InitValue 1018 compiler.codeGenerator.op_mov_MV( sizeof(short), REG_EBP, offset, Schedule::LocalVar, (long)i64data ); 1030 compiler.codeGenerator.localVarPertialSchedules.push_back( 1031 compiler.codeGenerator.op_mov_MV( sizeof(short), REG_EBP, offset, Schedule::None, true, (long)i64data ) 1032 ); 1019 1033 } 1020 1034 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){ 1021 1035 //mov byte ptr[ebp+offset],InitValue 1022 compiler.codeGenerator.op_mov_MV( sizeof(char), REG_EBP, offset, Schedule::LocalVar, (long)i64data ); 1036 compiler.codeGenerator.localVarPertialSchedules.push_back( 1037 compiler.codeGenerator.op_mov_MV( sizeof(char), REG_EBP, offset, Schedule::None, true, (long)i64data ) 1038 ); 1023 1039 } 1024 1040 … … 1130 1146 1131 1147 //add eax,offset 1132 compiler.codeGenerator.op_add_RV( REG_EAX, -pVar->GetOffsetAddress(), Schedule::LocalVar ); 1148 compiler.codeGenerator.localVarPertialSchedules.push_back( 1149 compiler.codeGenerator.op_add_RV( REG_EAX, -pVar->GetOffsetAddress(), Schedule::None, true ) 1150 ); 1133 1151 1134 1152 //push eax … … 1193 1211 if(pRelativeVar->bOffsetOffset){ 1194 1212 //add ecx,offset 1195 compiler.codeGenerator.op_add_RV( REG_ECX, pRelativeVar->offset, Schedule::LocalVar ); 1213 compiler.codeGenerator.localVarPertialSchedules.push_back( 1214 compiler.codeGenerator.op_add_RV( REG_ECX, pRelativeVar->offset, Schedule::None, true ) 1215 ); 1196 1216 1197 1217 //lea eax,dword ptr[ebp+ecx] … … 1205 1225 else{ 1206 1226 //lea eax,dword ptr[ecx+offset] 1207 compiler.codeGenerator.op_lea_RM( REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1227 compiler.codeGenerator.localVarPertialSchedules.push_back( 1228 compiler.codeGenerator.op_lea_RM( REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true ) 1229 ); 1208 1230 } 1209 1231 } … … 1214 1236 1215 1237 //add eax,dword ptr[ebp+offset] 1216 compiler.codeGenerator.op_add_RM( sizeof(long), REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1238 compiler.codeGenerator.localVarPertialSchedules.push_back( 1239 compiler.codeGenerator.op_add_RM( sizeof(long), REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true ) 1240 ); 1217 1241 } 1218 1242 else{ 1219 1243 //mov eax,dword ptr[ebp+offset] 1220 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1244 compiler.codeGenerator.localVarPertialSchedules.push_back( 1245 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EBP, pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true ) 1246 ); 1221 1247 } 1222 1248 } -
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r248 r253 382 382 pobj_Reloc=new CReloc(); 383 383 384 extern char *OpBuffer; 385 extern int obp; 384 386 obp_AllocSize=8192*2; 385 387 OpBuffer=(char *)malloc(obp_AllocSize); … … 440 442 441 443 //未完成 442 // OpBuffer[obp++]=(char)0xCC;444 //breakpoint; 443 445 444 446 … … 471 473 472 474 //Goto未知ラベルスケジュールが存在したらエラーにする 473 BOOST_FOREACH( const GotoLabelSchedule &gotoLabelSchedule, compiler.codeGenerator.gotoLabelSchedules )475 BOOST_FOREACH( const GotoLabelSchedule *pGotoLabelSchedule, compiler.codeGenerator.gotoLabelSchedules ) 474 476 { 475 if( gotoLabelSchedule.GetName().size()>0){476 SetError(6, gotoLabelSchedule.GetName(),gotoLabelSchedule.GetSourceCodePos());477 if(pGotoLabelSchedule->GetName().size()>0){ 478 SetError(6,pGotoLabelSchedule->GetName(),pGotoLabelSchedule->GetSourceCodePos()); 477 479 } 478 480 else{ 479 sprintf(temporary,"%d", gotoLabelSchedule.GetLineNum());480 SetError(6,temporary, gotoLabelSchedule.GetSourceCodePos());481 sprintf(temporary,"%d",pGotoLabelSchedule->GetLineNum()); 482 SetError(6,temporary,pGotoLabelSchedule->GetSourceCodePos()); 481 483 } 482 484 } -
trunk/abdev/BasicCompiler32/NumOpe.cpp
r237 r253 631 631 632 632 //リテラル演算の場合を考慮した演算前のバッファ位置 633 int BeforeObp;634 BeforeObp=obp;633 extern int obp; 634 int BeforeObp = obp; 635 635 636 636 //リテラル演算の場合を考慮した演算前のプロシージャスケジュール位置 -
trunk/abdev/BasicCompiler32/Opcode.h
r250 r253 16 16 17 17 extern int cp; 18 extern int obp; 19 extern char *OpBuffer; 20 21 #define breakpoint OpBuffer[obp++]=(char)0xCC; 18 19 #define breakpoint compiler.codeGenerator.PutOld( (char)0xCC ); 22 20 23 21 … … 215 213 216 214 //Compile_CallProc.cpp 217 void AddLocalVarAddrSchedule();218 215 #define PROCFLAG_NEW 1 219 216 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer); … … 252 249 253 250 254 ////////////////////////////////255 // IA-32機械語生成に利用する関数郡256 ////////////////////////////////257 258 251 //op32_main.cpp 259 252 BOOL IsSafeReg(int reg); 260 /*261 void op_mov_RV (int reg,int offset);262 void op_mov_RV (int op_size,int reg,int offset);263 void op_mov_RR (int reg1,int reg2);264 void op_mov_RM (int op_size,int reg,int base_reg,int offset,char mod);265 void op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,int offset,BOOL bUseOffset);266 void op_mov_MR (int op_size,int reg,int base_reg,int offset,char mod);267 void op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,int offset,BOOL bUseOffset);268 void op_movsx_R32R16 (int reg32,int reg16);269 void op_movsx_R32R8 (int reg32,int reg8);270 void op_movsx_R16R8 (int reg16,int reg8);271 void op_inc (int reg);272 void op_dec (int reg);273 void op_add_RV8 (int reg,char cValue);274 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod);275 void op_adc_RV8 (int reg,char cValue);276 void op_sub_RV8 (int reg,char cValue);277 void op_sbb_RV8 (int reg,char cValue);278 void op_sbb_RR ( int reg1, int reg2 );279 void op_imul_RR (int reg1,int reg2);280 void op_imul_RV (int reg,int i32data);281 void op_and_RV (int reg,int value);282 void op_or_RR ( int op_size, int reg1, int reg2 );283 void op_neg ( int reg );284 void op_cdq ();285 286 void op_rep_movs (int op_size);287 288 void op_push(int reg);289 void op_push_V(long data);290 void op_pop(int reg = REG_NON);291 void op_add_esp(int num);292 void op_sub_esp(int num);293 void op_cmp_RR( int reg1, int reg2 );294 void op_cmp_value(int op_size,int reg,char byte_data);295 void op_setne( int reg );296 void op_test(int reg1,int reg2);297 void op_fld_ptr_esp(int type);298 void op_fld_basereg (int type,int base_reg);299 void op_fld_base_offset (int type,int base_reg,int offset);300 void op_fld_base_offset_ex (int type,int base_reg1,int base_reg2,int offset,BOOL bUseOffset);301 void op_fstp_basereg (int type,int base_reg);302 void op_fstp_base_offset (int type,int base_reg,int offset);303 void op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,int offset,BOOL bUseOffset);304 void op_fstp_push ( Type &type );305 void op_fistp_ptr_esp ( int typeSize );306 void op_zero_reg(int reg);307 void fpu_cast();308 void fpu_cast_end();309 310 void op_call(const UserProc *pUserProc);311 void op_ret();312 */ -
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 ){ -
trunk/abdev/BasicCompiler_Common/Compile.cpp
r250 r253 88 88 extern LINEINFO *pLineInfo; 89 89 if(MaxLineInfoNum){ 90 extern int obp; 90 91 if(pLineInfo[MaxLineInfoNum-1].TopObp==obp){ 91 92 pLineInfo[MaxLineInfoNum-1].TopCp=cp; … … 95 96 pLineInfo=(LINEINFO *)HeapReAlloc(hHeap,0,pLineInfo,(MaxLineInfoNum+1)*sizeof(LINEINFO)); 96 97 pLineInfo[MaxLineInfoNum].TopCp=cp; 98 extern int obp; 97 99 pLineInfo[MaxLineInfoNum].TopObp=obp; 98 100 … … 123 125 pLabelNames[MaxLabelNum].pName=(char *)HeapAlloc(hHeap,0,lstrlen(Command+1)+1); 124 126 lstrcpy(pLabelNames[MaxLabelNum].pName,Command+1); 127 extern int obp; 125 128 pLabelNames[MaxLabelNum].address=obp; 126 129 MaxLabelNum++; 127 130 128 131 //書き込みスケジュール 129 std::vector<GotoLabelSchedule>::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();132 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin(); 130 133 while( it != compiler.codeGenerator.gotoLabelSchedules.end() ) 131 134 { 132 if( it->GetName() == Command+1 )135 if( (*it)->GetName() == Command+1 ) 133 136 { 134 *((long *)( OpBuffer + it->GetNativeCodePos() ))=obp-(it->GetNativeCodePos()+sizeof(long));137 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) ); 135 138 136 139 //詰める … … 335 338 extern BOOL bDebugCompile; 336 339 //int 3 337 if(bDebugCompile) OpBuffer[obp++]=(char)0xCC; 340 if(bDebugCompile) 341 { 342 breakpoint; 343 } 338 344 #if defined(_DEBUG) 339 else OpBuffer[obp++]=(char)0xCC; 345 else 346 { 347 breakpoint; 348 } 340 349 #endif 341 350 break; … … 532 541 pLabelNames[MaxLabelNum].pName=0; 533 542 pLabelNames[MaxLabelNum].line=i3; 543 extern int obp; 534 544 pLabelNames[MaxLabelNum].address=obp; 535 545 MaxLabelNum++; 536 546 537 547 //書き込みスケジュール 538 std::vector<GotoLabelSchedule>::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin();548 GotoLabelSchedules::iterator it = compiler.codeGenerator.gotoLabelSchedules.begin(); 539 549 while( it != compiler.codeGenerator.gotoLabelSchedules.end() ) 540 550 { 541 if( it->GetName().size() == 0 && it->GetLineNum() == i3 )551 if( (*it)->GetName().size() == 0 && (*it)->GetLineNum() == i3 ) 542 552 { 543 *((long *)( OpBuffer + it->GetNativeCodePos() ))=obp-(it->GetNativeCodePos()+sizeof(long));544 553 compiler.codeGenerator.opfix_JmpPertialSchedule( (*it) ); 554 545 555 //詰める 546 556 it = compiler.codeGenerator.gotoLabelSchedules.erase( it ); -
trunk/abdev/BasicCompiler_Common/PESchedule.cpp
r242 r253 154 154 void CSchedule::add(){ 155 155 pObpValues=(int *)HeapReAlloc(hHeap,0,pObpValues,(num+1)*sizeof(int)); 156 extern int obp; 156 157 pObpValues[num]=obp; 157 158 num++; … … 227 228 if(!bCall){ 228 229 //リロケーション情報を追加する 230 extern int obp; 229 231 pobj_Reloc->AddSchedule_CodeSection(obp); 230 232 } -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r252 r253 12 12 void ReallocNativeCodeBuffer(); 13 13 14 //Goto未知ラベル15 class GotoLabelSchedule16 {17 std::string name;18 int line;19 int nativeCodePos;20 int sourceCodePos;21 public:22 GotoLabelSchedule( const std::string &name, int nativeCodePos, int sourceCodePos )23 : name( name )24 , line( -1 )25 , nativeCodePos( nativeCodePos )26 , sourceCodePos( sourceCodePos )27 {28 }29 GotoLabelSchedule( int line, int nativeCodePos, int sourceCodePos )30 : line( line )31 , nativeCodePos( nativeCodePos )32 , sourceCodePos( sourceCodePos )33 {34 }35 const std::string &GetName() const36 {37 return name;38 }39 int GetLineNum() const40 {41 return line;42 }43 int GetNativeCodePos() const44 {45 return nativeCodePos;46 }47 int GetSourceCodePos() const48 {49 return sourceCodePos;50 }51 };52 53 14 // コード生成時の部分的なスケジューリング 54 15 class PertialSchedule … … 85 46 typedef std::vector<const PertialSchedule *> PertialSchedules; 86 47 48 //Goto未知ラベル 49 class GotoLabelSchedule : public PertialSchedule 50 { 51 std::string name; 52 int line; 53 int sourceCodePos; 54 public: 55 GotoLabelSchedule( const std::string &name, int nativeCodePos, int sourceCodePos ) 56 : PertialSchedule( nativeCodePos, sizeof(long) ) 57 , name( name ) 58 , line( -1 ) 59 , sourceCodePos( sourceCodePos ) 60 { 61 } 62 GotoLabelSchedule( int line, int nativeCodePos, int sourceCodePos ) 63 : PertialSchedule( nativeCodePos, sizeof(long) ) 64 , line( line ) 65 , sourceCodePos( sourceCodePos ) 66 { 67 } 68 const std::string &GetName() const 69 { 70 return name; 71 } 72 int GetLineNum() const 73 { 74 return line; 75 } 76 int GetSourceCodePos() const 77 { 78 return sourceCodePos; 79 } 80 }; 81 typedef std::vector<const GotoLabelSchedule *> GotoLabelSchedules; 82 87 83 class LexicalScope 88 84 { … … 186 182 public: 187 183 184 // ローカル変数用スケジュールの管理 185 PertialSchedules localVarPertialSchedules; 186 188 187 // Exit Subスケジュールの管理 189 188 std::vector<long> exitSubCodePositions; … … 191 190 192 191 // Gotoスケジュールの管理 193 std::vector<GotoLabelSchedule>gotoLabelSchedules;192 GotoLabelSchedules gotoLabelSchedules; 194 193 195 194 // レキシカルスコープの管理 … … 256 255 257 256 void opfix( const PertialSchedule *pPertialSchedule, long newValue ); 257 void opfix_offset( const PertialSchedule *pPertialSchedule, long offset ); 258 258 void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule ); 259 259 … … 279 279 void op_jmp_continue(); 280 280 void op_jmp_exitsub(); 281 void op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule);281 void op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos ); 282 282 283 283 … … 370 370 const PertialSchedule *__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 371 371 public: 372 void op_mov_MV ( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType = Schedule::None );373 void op_mov_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None );374 void op_mov_RR (int reg1,int reg2);375 void op_mov_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );376 void op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );377 void op_mov_MR (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );378 void op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );379 void op_movsx_R32R16 (int reg32,int reg16 = REG_NON);380 void op_movsx_R32R8 (int reg32,int reg8 = REG_NON);381 void op_movsx_R16R8 (int reg16,int reg8 = REG_NON);382 void op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None );383 void op_inc (int reg);384 void op_dec (int reg);385 void op_add_RV8 (int reg,char cValue);386 void op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None );387 void op_add_RR ( int reg1, int reg2 );388 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );372 const PertialSchedule *op_mov_MV ( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, long value, Schedule::Type valueScheduleType = Schedule::None ); 373 void op_mov_RV ( int reg,long offset, Schedule::Type scheduleType = Schedule::None ); 374 void op_mov_RR ( int reg1,int reg2); 375 const PertialSchedule *op_mov_RM ( int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 376 const PertialSchedule *op_mov_RM_ex ( int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 377 const PertialSchedule *op_mov_MR ( int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 378 const PertialSchedule *op_mov_MR_ex ( int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 379 void op_movsx_R32R16 ( int reg32,int reg16 = REG_NON); 380 void op_movsx_R32R8 ( int reg32,int reg8 = REG_NON); 381 void op_movsx_R16R8 ( int reg16,int reg8 = REG_NON); 382 const PertialSchedule *op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 383 void op_inc (int reg); 384 void op_dec (int reg); 385 void op_add_RV8 (int reg,char cValue); 386 const PertialSchedule *op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 387 void op_add_RR ( int reg1, int reg2 ); 388 const PertialSchedule *op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 389 389 void op_adc_RV8 (int reg,char cValue); 390 390 void op_adc_RR ( int reg1, int reg2 ); … … 413 413 void op_pop(int reg = REG_NON); 414 414 void op_add_esp(long num); 415 void op_sub_esp(long num);415 const PertialSchedule *op_sub_esp( long num, bool isPertialSchedule = false ); 416 416 void op_cmp_RR( int reg1, int reg2 ); 417 417 void op_cmp_value(int op_size,int reg,char byte_data); … … 421 421 void op_fld_ptr_esp(int type); 422 422 void op_fld_basereg (int type,int base_reg); 423 void op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None );424 void op_fld_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None);423 const PertialSchedule *op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 424 const PertialSchedule *op_fld_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 425 425 void op_fstp_basereg (int type,int base_reg); 426 void op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None);427 void op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None);426 const PertialSchedule *op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 427 const PertialSchedule *op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 428 428 void op_fistp_ptr_esp ( int typeSize ); 429 429 void op_fstp_push ( Type &type ); … … 452 452 pNativeCode->Put( nativeCode ); 453 453 } 454 void PutOld( char c ) 455 { 456 pNativeCode->Put( c ); 457 } 454 458 void PutOld( char c1, char c2 ) 455 459 { -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r252 r253 7 7 #include <BoostSerializationSupport.h> 8 8 9 void AddLocalVarAddrSchedule();10 9 void ObpPlus( int step = 1 ); 11 10 … … 19 18 None = 10000, 20 19 GlobalVar, // グローバル変数スケジュール 21 LocalVar, // ローカル変数スケジュール22 20 DataTable, // データテーブル スケジュール 23 21 Relocation, // リロケーション情報スケジュール … … 172 170 } 173 171 172 long GetLong( int codePos ) const 173 { 174 return *(long *)(this->codeBuffer+codePos); 175 } 176 long _GetLong_ObpOld( int _obpOld ) const 177 { 178 extern char *OpBuffer; 179 return *(long *)(OpBuffer+_obpOld); 180 } 181 174 182 void Overwrite( int codePos, char c ) 175 183 { … … 236 244 pobj_GlobalVarSchedule->add(); 237 245 break; 238 case Schedule::LocalVar:239 AddLocalVarAddrSchedule();240 break;241 246 case Schedule::DataTable: 242 247 extern CSchedule *pobj_DataTableSchedule; -
trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp
r251 r253 65 65 66 66 isSuccessful = true; 67 break; 68 } 69 else 70 { 71 it++; 72 } 73 } 74 75 if( isSuccessful == false ) 76 { 77 SetError(); 78 } 79 } 80 81 void CodeGenerator::opfix_offset( const PertialSchedule *pPertialSchedule, long offset ) 82 { 83 bool isSuccessful = false; 84 85 PertialSchedules::iterator it = pertialSchedules.begin(); 86 while( it != pertialSchedules.end() ) 87 { 88 if( (*it) == pPertialSchedule ) 89 { 90 if( pPertialSchedule->GetTypeSize() == sizeof(long) ) 91 { 92 pNativeCode->Overwrite( 93 pPertialSchedule->GetCodePos(), 94 pNativeCode->GetLong(pPertialSchedule->GetCodePos()) + offset 95 ); 96 97 // TODO: 未完成(用が無くなったら消す) 98 pNativeCode->OverwriteOld( 99 pPertialSchedule->GetObpOld(), 100 pNativeCode->_GetLong_ObpOld(pPertialSchedule->GetObpOld()) + offset 101 ); 102 } 103 else 104 { 105 SetError(); 106 } 107 108 it = pertialSchedules.erase( it ); 109 delete pPertialSchedule; 110 111 isSuccessful = true; 112 break; 67 113 } 68 114 else … … 280 326 pNativeCode->Put( (long)0 ); 281 327 } 282 void CodeGenerator::op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule)328 void CodeGenerator::op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos ) 283 329 { 284 330 // オペコード 285 331 pNativeCode->Put( (char)0xE9 ); 286 332 287 gotoLabelSchedules.push_back( gotoLabelSchedule ); 333 const GotoLabelSchedule *pGotoLabelSchedule = NULL; 334 if( name.size() == 0 ) 335 { 336 pGotoLabelSchedule = new GotoLabelSchedule( name, pNativeCode->GetSize(), sourceCodePos ); 337 } 338 else 339 { 340 pGotoLabelSchedule = new GotoLabelSchedule( name, pNativeCode->GetSize(), sourceCodePos ); 341 } 342 gotoLabelSchedules.push_back( pGotoLabelSchedule ); 343 344 pertialSchedules.push_back( pGotoLabelSchedule ); 288 345 289 346 pNativeCode->Put( (long)0 ); -
trunk/abdev/BasicCompiler_Common/src/LexicalScope.cpp
r248 r253 136 136 137 137 //mov ecx,dword ptr[ebp+offset] 138 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32, Schedule::LocalVar ); 138 compiler.codeGenerator.localVarPertialSchedules.push_back( 139 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32, Schedule::None, true ) 140 ); 139 141 140 142 //push ecx
Note:
See TracChangeset
for help on using the changeset viewer.