Ignore:
Timestamp:
Aug 1, 2007, 3:37:09 AM (17 years ago)
Author:
dai_9181
Message:
 
File:
1 edited

Legend:

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

    r254 r255  
    3939
    4040        //sub rsp,スタックフレームサイズ
    41         int StackFrameSchedule;
    42         compiler.codeGenerator.op_sub_rsp(0xFFFFFFFF);
    43         StackFrameSchedule=obp-sizeof(long);
     41        const PertialSchedule *pStackFramePertialSchedule = compiler.codeGenerator.op_sub_rsp( 0, true );
    4442
    4543        extern BOOL bDebugCompile;
     
    6563
    6664        //スタックフレームスケジュール(subコマンドに渡す値)
    67         *((long *)(OpBuffer+StackFrameSchedule))=pobj_sf->GetFrameSize(0);
     65        compiler.codeGenerator.opfix( pStackFramePertialSchedule, pobj_sf->GetFrameSize(0) );
    6866
    6967        UserProc::CompileStartForUserProc( pBackUserProc );
     
    7775
    7876        //sub rsp,スタックフレームサイズ
    79         int StackFrameSchedule;
    80         compiler.codeGenerator.op_sub_rsp(0xFFFFFFFF);
    81         StackFrameSchedule=obp-sizeof(long);
     77        const PertialSchedule *pStackFramePertialSchedule = compiler.codeGenerator.op_sub_rsp( 0, true );
    8278
    8379        BOOST_FOREACH( Variable *pVar, compiler.GetMeta().GetGlobalVars() ){
     
    10298
    10399        //スタックフレームスケジュール(subコマンドに渡す値)
    104         *((long *)(OpBuffer+StackFrameSchedule))=pobj_sf->GetFrameSize(0);
     100        compiler.codeGenerator.opfix( pStackFramePertialSchedule, pobj_sf->GetFrameSize(0) );
    105101
    106102        //ret
     
    135131        //ret
    136132        compiler.codeGenerator.op_ret();
    137     }
    138     else if( userProc.GetName() == "_allrem" ){
    139         //乗除演算用の特殊関数(64ビット整数対応)
    140         BYTE Buffer_allrem[]={
    141             0x53,0x57,0x33,0xFF,0x8B,0x44,0x24,0x10,0x0B,0xC0,0x7D,0x14,0x47,0x8B,0x54,0x24,0x0C,0xF7,0xD8,0xF7,0xDA,0x83,0xD8,0x00,0x89,0x44,0x24,0x10,0x89,0x54,0x24,0x0C,0x8B,0x44,0x24,0x18,0x0B,0xC0,0x7D,0x13,0x8B,0x54,0x24,0x14,0xF7,0xD8,0xF7,0xDA,0x83,0xD8,0x00,0x89,0x44,0x24,0x18,0x89,0x54,0x24,0x14,0x0B,0xC0,0x75,0x1B,0x8B,0x4C,0x24,0x14,0x8B,0x44,0x24,0x10,0x33,0xD2,0xF7,0xF1,0x8B,0x44,0x24,0x0C,0xF7,0xF1,0x8B,0xC2,0x33,0xD2,0x4F,0x79,0x4E,0xEB,0x53,0x8B,0xD8,0x8B,0x4C,0x24,0x14,0x8B,0x54,0x24,0x10,0x8B,0x44,0x24,0x0C,0xD1,0xEB,0xD1,0xD9,0xD1,0xEA,0xD1,0xD8,0x0B,0xDB,0x75,0xF4,0xF7,0xF1,0x8B,0xC8,0xF7,0x64,0x24,0x18,0x91,0xF7,0x64,0x24,0x14,0x03,0xD1,0x72,0x0E,0x3B,0x54,0x24,0x10,0x77,0x08,0x72,0x0E,0x3B,0x44,0x24,0x0C,0x76,0x08,0x2B,0x44,0x24,0x14,0x1B,0x54,0x24,0x18,0x2B,0x44,0x24,0x0C,0x1B,0x54,0x24,0x10,0x4F,0x79,0x07,0xF7,0xDA,0xF7,0xD8,0x83,0xDA,0x00,0x5F,0x5B,0xC2,0x10,0x00
    142         };
    143 
    144         memcpy(OpBuffer+obp,Buffer_allrem,178);
    145         obp+=178;
    146     }
    147     else if( userProc.GetName() == "_allmul" ){
    148         //乗算用の特殊関数(64ビット整数対応)
    149         BYTE Buffer_allmul[]={
    150             0x8B,0x44,0x24,0x08,0x8B,0x4C,0x24,0x10,0x0B,0xC8,0x8B,0x4C,0x24,0x0C,0x75,0x09,0x8B,0x44,0x24,0x04,0xF7,0xE1,0xC2,0x10,0x00,0x53,0xF7,0xE1,0x8B,0xD8,0x8B,0x44,0x24,0x08,0xF7,0x64,0x24,0x14,0x03,0xD8,0x8B,0x44,0x24,0x08,0xF7,0xE1,0x03,0xD3,0x5B,0xC2,0x10,0x00
    151         };
    152 
    153         memcpy(OpBuffer+obp,Buffer_allmul,52);
    154         obp+=52;
    155     }
    156     else if( userProc.GetName() == "_alldiv" ){
    157         //除算用の特殊関数(64ビット整数対応)
    158         BYTE Buffer_alldiv[]={
    159             0x57,0x56,0x53,0x33,0xFF,0x8B,0x44,0x24,0x14,0x0B,0xC0,0x7D,0x14,0x47,0x8B,0x54,0x24,0x10,0xF7,0xD8,0xF7,0xDA,0x83,0xD8,0x00,0x89,0x44,0x24,0x14,0x89,0x54,0x24,0x10,0x8B,0x44,0x24,0x1C,0x0B,0xC0,0x7D,0x14,0x47,0x8B,0x54,0x24,0x18,0xF7,0xD8,0xF7,0xDA,0x83,0xD8,0x00,0x89,0x44,0x24,0x1C,0x89,0x54,0x24,0x18,0x0B,0xC0,0x75,0x18,0x8B,0x4C,0x24,0x18,0x8B,0x44,0x24,0x14,0x33,0xD2,0xF7,0xF1,0x8B,0xD8,0x8B,0x44,0x24,0x10,0xF7,0xF1,0x8B,0xD3,0xEB,0x41,0x8B,0xD8,0x8B,0x4C,0x24,0x18,0x8B,0x54,0x24,0x14,0x8B,0x44,0x24,0x10,0xD1,0xEB,0xD1,0xD9,0xD1,0xEA,0xD1,0xD8,0x0B,0xDB,0x75,0xF4,0xF7,0xF1,0x8B,0xF0,0xF7,0x64,0x24,0x1C,0x8B,0xC8,0x8B,0x44,0x24,0x18,0xF7,0xE6,0x03,0xD1,0x72,0x0E,0x3B,0x54,0x24,0x14,0x77,0x08,0x72,0x07,0x3B,0x44,0x24,0x10,0x76,0x01,0x4E,0x33,0xD2,0x8B,0xC6,0x4F,0x75,0x07,0xF7,0xDA,0xF7,0xD8,0x83,0xDA,0x00,0x5B,0x5E,0x5F,0xC2,0x10,0x00
    160         };
    161 
    162         memcpy(OpBuffer+obp,Buffer_alldiv,170);
    163         obp+=170;
    164     }
    165     else if( userProc.GetName() == "_allshl" ){
    166         //符号あり左ビットシフト用の特殊関数(64ビット整数対応)
    167         BYTE Buffer_allshl[]={
    168             0x80,0xF9,0x40,0x73,0x15,0x80,0xF9,0x20,0x73,0x06,0x0F,0xA5,0xC2,0xD3,0xE0,0xC3,0x8B,0xD0,0x33,0xC0,0x80,0xE1,0x1F,0xD3,0xE2,0xC3,0x33,0xC0,0x33,0xD2,0xC3
    169         };
    170 
    171         memcpy(OpBuffer+obp,Buffer_allshl,31);
    172         obp+=31;
    173     }
    174     else if( userProc.GetName() == "_allshr" ){
    175         //符号あり右ビットシフト用の特殊関数(64ビット整数対応)
    176         BYTE Buffer_allshr[]={
    177             0x80,0xF9,0x40,0x73,0x16,0x80,0xF9,0x20,0x73,0x06,0x0F,0xAD,0xD0,0xD3,0xFA,0xC3,0x8B,0xC2,0xC1,0xFA,0x1F,0x80,0xE1,0x1F,0xD3,0xF8,0xC3,0xC1,0xFA,0x1F,0x8B,0xC2,0xC3
    178         };
    179 
    180         memcpy(OpBuffer+obp,Buffer_allshr,33);
    181         obp+=33;
    182     }
    183     else if( userProc.GetName() == "_aullshr" ){
    184         //符号なし右ビットシフト用の特殊関数(64ビット整数対応)
    185         BYTE Buffer_aullshr[]={
    186             0x80,0xF9,0x40,         //cmp         cl,40h
    187             0x73,0x15,              //jae         RETZERO (0040d71a)
    188             0x80,0xF9,0x20,         //cmp         cl,20h
    189             0x73,0x06,              //jae         MORE32 (0040d710)
    190             0x0F,0xAD,0xD0,         //shrd        eax,edx,cl
    191             0xD3,0xEA,              //shr         edx,cl
    192             0xC3,                   //ret
    193             //MORE32:
    194             0x8B,0xC2,              //mov         eax,edx
    195             0x33,0xD2,              //xor         edx,edx
    196             0x80,0xE1,0x1F,         //and         cl,1Fh
    197             0xD3,0xE8,              //shr         eax,cl
    198             0xC3,                   //ret
    199             //RETZERO:
    200             0x33,0xC0,              //xor         eax,eax
    201             0x33,0xD2,              //xor         edx,edx
    202             0xC3                    //ret
    203         };
    204 
    205         memcpy(OpBuffer+obp,Buffer_aullshr,31);
    206         obp+=31;
    207133    }
    208134    else{
     
    441367
    442368    //sub rsp,スタックフレームサイズ
    443     int StackFrameSchedule;
    444     compiler.codeGenerator.op_sub_rsp(0xFFFFFFFF);
    445     StackFrameSchedule=obp-sizeof(long);
     369    const PertialSchedule *pStackFramePertialSchedule = compiler.codeGenerator.op_sub_rsp( 0, true );
    446370
    447371    //mov qword ptr[rsp+offset],reg     ※スタックフレームを利用
     
    482406    }
    483407
    484     int RspOffsetSchedule=0;
    485     int RspOffsetSchedule2;
     408    const PertialSchedule *pRspOffsetPertialSchedule1 = NULL;
     409    const PertialSchedule *pRspOffsetPertialSchedule2 = NULL;
    486410    if(bDebugCompile&&bDebugSupportProc==0){
    487411        //mov rdx, qword ptr[rsp+スタックフレームサイズ]
    488         compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_RDX,REG_RSP,0,MOD_BASE_DISP32);
    489         RspOffsetSchedule=obp-sizeof(long);
     412        pRspOffsetPertialSchedule1 = compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_RDX,REG_RSP,0,MOD_BASE_DISP32, Schedule::None, true );
    490413
    491414        //mov rcx,rsp
     
    493416
    494417        //add rcx,スタックフレームサイズ+sizeof(_int64) ※ret用のサイズを考慮
    495         compiler.codeGenerator.op_add_RV(REG_RCX,0);
    496         RspOffsetSchedule2=obp-sizeof(long);
     418        pRspOffsetPertialSchedule2 = compiler.codeGenerator.op_add_RV(REG_RCX,0, Schedule::None, true );
    497419
    498420        //call _DebugSys_StartProc
     
    713635    BOOST_FOREACH( const PertialSchedule *pPertialSchedule, compiler.codeGenerator.localVarPertialSchedules )
    714636    {
    715         compiler.codeGenerator.opfix_offset( pPertialSchedule, AllLocalVarSize );
     637        compiler.codeGenerator.opfix_offset( pPertialSchedule, AllLocalVarSize + stackFrameSize );
    716638    }
    717639    compiler.codeGenerator.localVarPertialSchedules.clear();
     
    742664
    743665    //デバッグ用
    744     if(RspOffsetSchedule){
    745         *((long *)(OpBuffer+RspOffsetSchedule))=stackFrameAndLocalParamSize;
    746         *((long *)(OpBuffer+RspOffsetSchedule2))=stackFrameAndLocalParamSize+sizeof(_int64);
     666    if( pRspOffsetPertialSchedule1 ){
     667        compiler.codeGenerator.opfix( pRspOffsetPertialSchedule1, stackFrameAndLocalParamSize );
     668        compiler.codeGenerator.opfix( pRspOffsetPertialSchedule2, stackFrameAndLocalParamSize + sizeof(_int64) );
    747669    }
    748670
    749671
    750672    //スタックフレームスケジュール(subコマンド)
    751     *((long *)(OpBuffer+StackFrameSchedule))=stackFrameAndLocalParamSize;
     673    compiler.codeGenerator.opfix( pStackFramePertialSchedule, stackFrameAndLocalParamSize );
    752674
    753675    //スタックフレームスケジュールを実行
Note: See TracChangeset for help on using the changeset viewer.