Changeset 251 in dev for trunk


Ignore:
Timestamp:
Jul 30, 2007, 2:00:45 AM (17 years ago)
Author:
dai_9181
Message:
 
Location:
trunk/abdev
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp

    r248 r251  
    244244    extern HANDLE hHeap;
    245245    extern BOOL bDebugCompile;
    246     int i3,i4,LocalVarSchedule,EspOffsetSchedule,BaseOffset;
     246    int i3,i4,LocalVarSchedule,BaseOffset;
    247247    char temporary[VN_SIZE];
    248248
     
    440440    compiler.codeGenerator.ClearContinueArea();
    441441
     442    const PertialSchedule *pEspOffsetPertialSchedule = NULL;
    442443    if(bDebugCompile&&bDebugSupportProc==0){
    443444        //push dword ptr[ebp+(AllLocalVarSize-BaseOffset)](スケジュール)
    444         OpBuffer[obp++]=(char)0xFF;
    445         OpBuffer[obp++]=(char)0xB5;
    446         EspOffsetSchedule=obp;
    447         obp+=sizeof(long); 
     445        pEspOffsetPertialSchedule = compiler.codeGenerator.op_push_M( REG_EBP, 0, Schedule::None, true );
    448446
    449447        //push dword ptr[ebp](以前のebp)
     
    621619
    622620    if(bDebugCompile&&bDebugSupportProc==0){
    623         *((long *)(OpBuffer+EspOffsetSchedule))=AllLocalVarSize-BaseOffset-sizeof(long);
     621        compiler.codeGenerator.opfix( pEspOffsetPertialSchedule, AllLocalVarSize-BaseOffset-sizeof(long) );
    624622
    625623        //call _DebugSys_EndProc
  • trunk/abdev/BasicCompiler32/x86CodeGenerator.cpp

    r250 r251  
    1919#define INDEX_NON   0x04
    2020
    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 ){
     21const PertialSchedule * CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType, bool isPertialSchedule )
     22{
     23    const PertialSchedule *pPertialSchedule = NULL;
    2224
    2325    // エラーチェック
     
    3032        SetError();
    3133    }
     34    if( isPertialSchedule && !( mod == MOD_DISP32 || mod == MOD_BASE_DISP32 ) )
     35    {
     36        SetError();
     37    }
    3238
    3339    if(mod==MOD_DISP32){
     
    4551
    4652    //レジスタモードの場合は、ここで終了
    47     if(mod==MOD_REG) return;
     53    if(mod==MOD_REG) return pPertialSchedule;
    4854
    4955
     
    5763
    5864    //ディスプレースメントを必要としない場合は、ここで終了
    59     if(mod==MOD_BASE) return;
     65    if(mod==MOD_BASE) return pPertialSchedule;
    6066
    6167
     
    7076    else
    7177    {
     78        if( isPertialSchedule )
     79        {
     80            pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     81            pPertialSchedule = pertialSchedules.back();
     82        }
     83
    7284        pNativeCode->Put( disp, scheduleType );
    7385    }
     86
     87    return pPertialSchedule;
    7488}
    7589
     
    86100    pNativeCode->Put( (char)(opcode|REGISTER_OPERAND(reg)) );
    87101}
    88 void CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
     102const PertialSchedule *CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
    89103    //命令プリフィックス
    90104    if(op_prefix)
     
    101115
    102116    //ModR/M, SIB, disp
    103     set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType );
     117    return set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType, isPertialSchedule );
    104118}
    105119
     
    731745    }
    732746}
    733 void CodeGenerator::op_push_M( int base_reg, long offset, Schedule::Type scheduleType )
    734 {
     747const PertialSchedule *CodeGenerator::op_push_M( int base_reg, long offset, Schedule::Type scheduleType, bool isPertialSchedule )
     748{
     749    const PertialSchedule *pPertialSchedule = NULL;
    735750    if( base_reg == REG_NON )
    736751    {
    737752        // push dword ptr[offset]
    738         __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, 0, offset, MOD_DISP32, scheduleType );
     753        pPertialSchedule = __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, 0, offset, MOD_DISP32, scheduleType, isPertialSchedule );
    739754    }
    740755    else
    741756    {
    742757        // push dword ptr[base_reg+offset]
    743         __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, base_reg, offset, MOD_BASE_DISP32, scheduleType );
    744     }
     758        pPertialSchedule = __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, base_reg, offset, MOD_BASE_DISP32, scheduleType, isPertialSchedule );
     759    }
     760    return pPertialSchedule;
    745761}
    746762void CodeGenerator::op_pop(int reg){
  • trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h

    r250 r251  
    255255    void CheckUnresolveSchedule();
    256256
     257    void opfix( const PertialSchedule *pPertialSchedule, long newValue );
    257258    void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule );
    258259
     
    365366    /////////////////////////////////////////////////////////////////
    366367private:
    367     void set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType = Schedule::None );
     368    const PertialSchedule *set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType, bool isPertialSchedule );
    368369    void __op_format(char op_prefix,char opcode,int reg);
    369     void __op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );
     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 );
    370371public:
    371372    void op_mov_MV          ( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType = Schedule::None );
     
    409410    void op_push_V( long data, Schedule::Type scheduleType = Schedule::None );
    410411    void op_push_M( int base_reg );
    411     void op_push_M( int base_reg, long offset, Schedule::Type scheduleType = Schedule::None );
     412    const PertialSchedule *op_push_M( int base_reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
    412413    void op_pop(int reg = REG_NON);
    413414    void op_add_esp(long num);
  • trunk/abdev/BasicCompiler_Common/src/CommonCodeGenerator.cpp

    r250 r251  
    2727}
    2828
    29 
    30 // 分岐関連
    31 void CodeGenerator::opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule )
     29void CodeGenerator::opfix( const PertialSchedule *pPertialSchedule, long newValue )
    3230{
    3331    bool isSuccessful = false;
     
    3836        if( (*it) == pPertialSchedule )
    3937        {
    40             long newValue = pNativeCode->GetSize() - (pPertialSchedule->GetCodePos()+pPertialSchedule->GetTypeSize());
    41 
    42             extern int obp;
    43             long newValueOld = obp - (pPertialSchedule->GetObpOld()+pPertialSchedule->GetTypeSize());
    44 
    4538            if( pPertialSchedule->GetTypeSize() == sizeof(char) )
    4639            {
     
    5447
    5548                // TODO: 未完成(用が無くなったら消す)
     49                pNativeCode->OverwriteOld( pPertialSchedule->GetObpOld(), (char)newValue );
     50            }
     51            else if( pPertialSchedule->GetTypeSize() == sizeof(long) )
     52            {
     53                pNativeCode->Overwrite( pPertialSchedule->GetCodePos(), newValue );
     54
     55                // TODO: 未完成(用が無くなったら消す)
     56                pNativeCode->OverwriteOld( pPertialSchedule->GetObpOld(), newValue );
     57            }
     58            else
     59            {
     60                SetError();
     61            }
     62
     63            it = pertialSchedules.erase( it );
     64            delete pPertialSchedule;
     65
     66            isSuccessful = true;
     67        }
     68        else
     69        {
     70            it++;
     71        }
     72    }
     73
     74    if( isSuccessful == false )
     75    {
     76        SetError();
     77    }
     78}
     79
     80
     81// 分岐関連
     82void CodeGenerator::opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule )
     83{
     84    bool isSuccessful = false;
     85
     86    PertialSchedules::iterator it = pertialSchedules.begin();
     87    while( it != pertialSchedules.end() )
     88    {
     89        if( (*it) == pPertialSchedule )
     90        {
     91            long newValue = pNativeCode->GetSize() - (pPertialSchedule->GetCodePos()+pPertialSchedule->GetTypeSize());
     92
     93            extern int obp;
     94            long newValueOld = obp - (pPertialSchedule->GetObpOld()+pPertialSchedule->GetTypeSize());
     95
     96            if( pPertialSchedule->GetTypeSize() == sizeof(char) )
     97            {
     98                if( newValue < -128 || 127 < newValue )
     99                {
     100                    // 範囲外
     101                    SetError();
     102                }
     103
     104                pNativeCode->Overwrite( pPertialSchedule->GetCodePos(), (char)newValue );
     105
     106                // TODO: 未完成(用が無くなったら消す)
    56107                pNativeCode->OverwriteOld( pPertialSchedule->GetObpOld(), (char)newValueOld );
    57108            }
     
    130181    {
    131182        pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), op_size ) );
    132         pPertialSchedule = pertialSchedules[pertialSchedules.size()-1];
     183        pPertialSchedule = pertialSchedules.back();
    133184    }
    134185
Note: See TracChangeset for help on using the changeset viewer.