Ignore:
Timestamp:
Jul 30, 2007, 4:12:54 PM (17 years ago)
Author:
dai_9181
Message:
 
File:
1 edited

Legend:

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

    r251 r253  
    124124///////////////////
    125125
    126 void CodeGenerator::op_mov_MV( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType )
     126const PertialSchedule *CodeGenerator::op_mov_MV( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, long value, Schedule::Type valueScheduleType )
    127127{
    128128    //mov ptr[base_reg+offset],value
     129    const PertialSchedule *pPertialSchedule = NULL;
    129130
    130131    if( op_size == sizeof(char) )
     
    132133        pNativeCode->Put( (char)0xC6 );
    133134        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        }
    134141        pNativeCode->Put( offset, offsetScheduleType );
     142
    135143        pNativeCode->Put( (char)value );
    136144    }
     
    140148        pNativeCode->Put( (char)0xC7 );
    141149        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        }
    142156        pNativeCode->Put( offset, offsetScheduleType );
     157
    143158        pNativeCode->Put( (short)value );
    144159    }
     
    147162        pNativeCode->Put( (char)0xC7 );
    148163        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        }
    149170        pNativeCode->Put( offset, offsetScheduleType );
     171
    150172        pNativeCode->Put( value, valueScheduleType );
    151173    }
     174
     175    return pPertialSchedule;
    152176}
    153177void CodeGenerator::op_mov_RV(int reg,long offset, Schedule::Type scheduleType ){
     
    169193    pNativeCode->Put( (char)(0xC0| REGISTER_OPERAND(reg1)<<3 | REGISTER_OPERAND(reg2)) );
    170194}
    171 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
     195const PertialSchedule *CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
    172196    //mov reg32,dword ptr[base_reg+offset]
    173197    //mov reg16,word ptr[base_reg+offset]
     
    183207    else opcode=(char)0x8B;
    184208
    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}
     211const 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 ){
    188212    //mov reg32,dword ptr[base_reg1+base_reg2+offset]
    189213    //mov reg16,word ptr[base_reg1+base_reg2+offset]
    190214    //mov reg8,byte ptr[base_reg1+base_reg2+offset]
     215    const PertialSchedule *pPertialSchedule = NULL;
    191216
    192217    if(base_reg1==REG_ESP){
     
    215240
    216241        //オフセット値
     242        if( isPertialSchedule )
     243        {
     244            pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     245            pPertialSchedule = pertialSchedules.back();
     246        }
    217247        pNativeCode->Put( offset, scheduleType );
    218248    }
     
    228258        pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) );
    229259    }
    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}
     262const PertialSchedule *CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
    232263    //mov dword ptr[base_reg+offset],reg32
    233264    //mov word ptr[base_reg+offset],reg16
     
    243274    else opcode=(char)0x89;
    244275
    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}
     278const 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 ){
    248279    //mov dword ptr[base_reg1+base_reg2+offset],reg32
    249280    //mov word ptr[base_reg1+base_reg2+offset],reg16
    250281    //mov byte ptr[base_reg1+base_reg2+offset],reg8
     282    const PertialSchedule *pPertialSchedule = NULL;
    251283
    252284    if(base_reg1==REG_ESP){
     
    275307
    276308        //オフセット値
     309        if( isPertialSchedule )
     310        {
     311            pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     312            pPertialSchedule = pertialSchedules.back();
     313        }
    277314        pNativeCode->Put( offset, scheduleType );
    278315    }
     
    288325        pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) );
    289326    }
     327    return pPertialSchedule;
    290328}
    291329
     
    355393//////////////////////////////////
    356394
    357 void CodeGenerator::op_lea_RM( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType )
     395const PertialSchedule *CodeGenerator::op_lea_RM( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType, bool isPertialSchedule )
    358396{
    359397    //16ビット演算の命令プリフィックス
     
    363401    char opcode=(char)0x8D;
    364402
    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 );
    366404}
    367405
     
    408446    pNativeCode->Put( cValue );
    409447}
    410 void CodeGenerator::op_add_RV( int reg, long offset, Schedule::Type scheduleType )
     448const PertialSchedule *CodeGenerator::op_add_RV( int reg, long offset, Schedule::Type scheduleType, bool isPertialSchedule )
    411449{
    412450    // add reg,offset
     451    const PertialSchedule *pPertialSchedule = NULL;
    413452
    414453    if( reg == REG_EAX )
     
    416455        // eaxのみ特殊
    417456        pNativeCode->Put( (char)0x05 );
    418         pNativeCode->Put( offset, scheduleType );
    419457    }
    420458    else
     
    422460        pNativeCode->Put( (char)0x81 );
    423461        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;
    426473}
    427474void CodeGenerator::op_add_RR( int reg1, int reg2 )
     
    435482    __op_format(op_prefix,opcode,0,reg1,reg2,0,MOD_REG);
    436483}
    437 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
     484const PertialSchedule *CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType, bool isPertialSchedule ){
    438485    //add reg32,dword ptr[base_reg+offset]
    439486    //add reg16,word ptr[base_reg+offset]
     
    449496    else opcode=(char)0x03;
    450497
    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 );
    452499}
    453500void CodeGenerator::op_adc_RV8(int reg,char cValue){
     
    787834    }
    788835}
    789 void CodeGenerator::op_sub_esp(long num){
     836const PertialSchedule *CodeGenerator::op_sub_esp( long num, bool isPertialSchedule ){
    790837    //スタックポインタの減算(push方向)
     838    const PertialSchedule *pPertialSchedule = NULL;
    791839
    792840    //sub esp,num
    793     if(0xFFFFFF80&num){
     841    if( (0xFFFFFF80&num) != 0 || isPertialSchedule ){
    794842        pNativeCode->Put( (char)0x81 );
    795843        pNativeCode->Put( (char)0xEC );
     844
     845        if( isPertialSchedule )
     846        {
     847            pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     848            pPertialSchedule = pertialSchedules.back();
     849        }
    796850        pNativeCode->Put( num );
    797851    }
     
    802856        pNativeCode->Put( (char)num );
    803857    }
     858
     859    return pPertialSchedule;
    804860}
    805861
     
    922978    }
    923979}
    924 void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){
     980const PertialSchedule *CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType, bool isPertialSchedule ){
    925981    //fld ptr[reg+offset]
     982    const PertialSchedule *pPertialSchedule = NULL;
    926983
    927984    //オペコード
     
    940997
    941998    //オフセット値
     999    if( isPertialSchedule )
     1000    {
     1001        pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     1002        pPertialSchedule = pertialSchedules.back();
     1003    }
    9421004    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}
     1008const PertialSchedule *CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){
    9451009    //fld ptr[base_reg1+base_reg2+offset]
     1010    const PertialSchedule *pPertialSchedule = NULL;
    9461011
    9471012    if(base_reg1==REG_ESP){
     
    9691034
    9701035        //オフセット値
     1036        if( isPertialSchedule )
     1037        {
     1038            pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     1039            pPertialSchedule = pertialSchedules.back();
     1040        }
    9711041        pNativeCode->Put( offset, scheduleType );
    9721042    }
     
    9821052        pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) );
    9831053    }
     1054
     1055    return pPertialSchedule;
    9841056}
    9851057void CodeGenerator::op_fstp_basereg(int type,int base_reg){
     
    10031075    }
    10041076}
    1005 void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){
     1077const PertialSchedule *CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType, bool isPertialSchedule ){
    10061078    //fstp ptr[reg+offset]
     1079    const PertialSchedule *pPertialSchedule = NULL;
    10071080
    10081081    //オペコード
     
    10211094
    10221095    //オフセット値
     1096    if( isPertialSchedule )
     1097    {
     1098        pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     1099        pPertialSchedule = pertialSchedules.back();
     1100    }
    10231101    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}
     1105const PertialSchedule *CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType, bool isPertialSchedule ){
    10261106    //fstp ptr[base_reg1+base_reg2+offset]
     1107    const PertialSchedule *pPertialSchedule = NULL;
    10271108
    10281109    if(base_reg1==REG_ESP){
     
    10501131
    10511132        //オフセット値
     1133        if( isPertialSchedule )
     1134        {
     1135            pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
     1136            pPertialSchedule = pertialSchedules.back();
     1137        }
    10521138        pNativeCode->Put( offset, scheduleType );
    10531139    }
     
    10631149        pNativeCode->Put( (char)(REGISTER_OPERAND(base_reg1)<<3 | REGISTER_OPERAND(base_reg2)) );
    10641150    }
     1151
     1152    return pPertialSchedule;
    10651153}
    10661154void CodeGenerator::op_fistp_ptr_esp( int typeSize ){
Note: See TracChangeset for help on using the changeset viewer.