Ignore:
Timestamp:
Jul 24, 2007, 11:35:33 AM (17 years ago)
Author:
dai_9181
Message:
 
File:
1 edited

Legend:

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

    r225 r229  
    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){
     21void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType ){
    2222    if(mod==MOD_DISP32){
    2323        //ModR/Mバイト
     
    5959    else
    6060    {
    61         pNativeCode->Put( disp );
     61        pNativeCode->Put( disp, scheduleType );
    6262    }
    6363}
     
    7575    pNativeCode->Put( (char)(opcode|REGISTER_OPERAND(reg)) );
    7676}
    77 void CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod){
     77void CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
    7878    //命令プリフィックス
    7979    if(op_prefix)
     
    9090
    9191    //ModR/M, SIB, disp
    92     set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset);
     92    set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType );
    9393}
    9494
     
    9999///////////////////
    100100
    101 void CodeGenerator::op_mov_RV(int reg,long offset){
     101void CodeGenerator::op_mov_RV(int reg,long offset, Schedule::Type scheduleType ){
    102102    //mov reg,value
    103103
     
    106106
    107107    //DISP32
    108     pNativeCode->Put( offset );
    109 }
    110 void CodeGenerator::op_mov_RV(int op_size,int reg,int offset){
    111     if(op_size==PTR_SIZE) op_mov_RV(reg,offset);
    112     else SetError(300,NULL,cp);
     108    pNativeCode->Put( offset, scheduleType );
    113109}
    114110void CodeGenerator::op_mov_RR(int reg1,int reg2){
     
    121117    pNativeCode->Put( (char)(0xC0| REGISTER_OPERAND(reg1)<<3 | REGISTER_OPERAND(reg2)) );
    122118}
    123 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod){
     119void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
    124120    //mov reg32,dword ptr[base_reg+offset]
    125121    //mov reg16,word ptr[base_reg+offset]
     
    135131    else opcode=(char)0x8B;
    136132
    137     __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod);
    138 }
    139 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset){
     133    __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );
     134}
     135void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){
    140136    //mov reg32,dword ptr[base_reg1+base_reg2+offset]
    141137    //mov reg16,word ptr[base_reg1+base_reg2+offset]
     
    167163
    168164        //オフセット値
    169         pNativeCode->Put( offset );
     165        pNativeCode->Put( offset, scheduleType );
    170166    }
    171167    else{
     
    181177    }
    182178}
    183 void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod){
     179void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
    184180    //mov dword ptr[base_reg+offset],reg32
    185181    //mov word ptr[base_reg+offset],reg16
     
    195191    else opcode=(char)0x89;
    196192
    197     __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod);
    198 }
    199 void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset){
     193    __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );
     194}
     195void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){
    200196    //mov dword ptr[base_reg1+base_reg2+offset],reg32
    201197    //mov word ptr[base_reg1+base_reg2+offset],reg16
     
    227223
    228224        //オフセット値
    229         pNativeCode->Put( offset );
     225        pNativeCode->Put( offset, scheduleType );
    230226    }
    231227    else{
     
    353349    __op_format(op_prefix,opcode,0,reg1,reg2,0,MOD_REG);
    354350}
    355 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod){
     351void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){
    356352    //add reg32,dword ptr[base_reg+offset]
    357353    //add reg16,word ptr[base_reg+offset]
     
    367363    else opcode=(char)0x03;
    368364
    369     __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod);
     365    __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType );
    370366}
    371367void CodeGenerator::op_adc_RV8(int reg,char cValue){
     
    656652    __op_format( (char)0xFF, (char)0x30, base_reg );
    657653}
     654void CodeGenerator::op_push_M( int base_reg, long offset, Schedule::Type scheduleType )
     655{
     656    if( base_reg == REG_NON )
     657    {
     658        // push dword ptr[offset]
     659        __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, 0, offset, MOD_DISP32, scheduleType );
     660    }
     661    else
     662    {
     663        // push dword ptr[base_reg+offset]
     664        __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, base_reg, offset, MOD_BASE_DISP32, scheduleType );
     665    }
     666}
    658667void CodeGenerator::op_pop(int reg){
    659668    //pop reg
     
    821830    }
    822831}
    823 void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset){
     832void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){
    824833    //fld ptr[reg+offset]
    825834
     
    839848
    840849    //オフセット値
    841     pNativeCode->Put( offset );
    842 }
    843 void CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset){
     850    pNativeCode->Put( offset, scheduleType );
     851}
     852void CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){
    844853    //fld ptr[base_reg1+base_reg2+offset]
    845854
     
    868877
    869878        //オフセット値
    870         pNativeCode->Put( offset );
     879        pNativeCode->Put( offset, scheduleType );
    871880    }
    872881    else{
     
    902911    }
    903912}
    904 void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset){
     913void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){
    905914    //fstp ptr[reg+offset]
    906915
     
    920929
    921930    //オフセット値
    922     pNativeCode->Put( offset );
    923 }
    924 void CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset){
     931    pNativeCode->Put( offset, scheduleType );
     932}
     933void CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){
    925934    //fstp ptr[base_reg1+base_reg2+offset]
    926935
     
    949958
    950959        //オフセット値
    951         pNativeCode->Put( offset );
     960        pNativeCode->Put( offset, scheduleType );
    952961    }
    953962    else{
Note: See TracChangeset for help on using the changeset viewer.