[184] | 1 | #pragma once
|
---|
| 2 |
|
---|
[225] | 3 | #include <NativeCode.h>
|
---|
[248] | 4 | #include <LexicalScope.h>
|
---|
[225] | 5 |
|
---|
| 6 | #ifdef _AMD64_
|
---|
| 7 | #include "../../BasicCompiler64/MachineFixed.h"
|
---|
| 8 | #else
|
---|
| 9 | #include "../../BasicCompiler32/MachineFixed.h"
|
---|
| 10 | #endif
|
---|
| 11 |
|
---|
[184] | 12 | void ReallocNativeCodeBuffer();
|
---|
[225] | 13 |
|
---|
[248] | 14 | // コード生成時の部分的なスケジューリング
|
---|
| 15 | class PertialSchedule
|
---|
[225] | 16 | {
|
---|
[248] | 17 | int codePos; // バッファ位置
|
---|
| 18 | int typeSize; // 対象サイズ(一般的には8bit/32bit)
|
---|
[225] | 19 |
|
---|
[248] | 20 | int _obpOld; // 未完成
|
---|
[237] | 21 | public:
|
---|
[248] | 22 | PertialSchedule( int codePos, int typeSize )
|
---|
| 23 | : codePos( codePos )
|
---|
| 24 | , typeSize( typeSize )
|
---|
| 25 | {
|
---|
| 26 | extern int obp;
|
---|
| 27 | _obpOld = obp;
|
---|
| 28 | }
|
---|
| 29 | ~PertialSchedule()
|
---|
| 30 | {
|
---|
| 31 | }
|
---|
[238] | 32 |
|
---|
[248] | 33 | int GetCodePos() const
|
---|
[237] | 34 | {
|
---|
[248] | 35 | return codePos;
|
---|
| 36 | }
|
---|
| 37 | int GetTypeSize() const
|
---|
| 38 | {
|
---|
| 39 | return typeSize;
|
---|
| 40 | }
|
---|
| 41 | int GetObpOld() const
|
---|
| 42 | {
|
---|
| 43 | return _obpOld;
|
---|
| 44 | }
|
---|
| 45 | };
|
---|
| 46 | typedef std::vector<const PertialSchedule *> PertialSchedules;
|
---|
[238] | 47 |
|
---|
[253] | 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 |
|
---|
[261] | 83 | //ラベルアドレス
|
---|
| 84 | class GotoLabel
|
---|
| 85 | {
|
---|
| 86 | public:
|
---|
| 87 | std::string name;
|
---|
| 88 | int line;
|
---|
| 89 | DWORD address;
|
---|
| 90 |
|
---|
| 91 | GotoLabel( const std::string &name, long nativeCodePos )
|
---|
| 92 | : name( name )
|
---|
| 93 | , line( -1 )
|
---|
| 94 | , address( nativeCodePos )
|
---|
| 95 | {
|
---|
| 96 | }
|
---|
| 97 | GotoLabel( int line, long nativeCodePos )
|
---|
| 98 | : name( "" )
|
---|
| 99 | , line( line )
|
---|
| 100 | , address( nativeCodePos )
|
---|
| 101 | {
|
---|
| 102 | }
|
---|
| 103 | };
|
---|
| 104 | typedef std::vector<GotoLabel> GotoLabels;
|
---|
| 105 |
|
---|
[248] | 106 | class LexicalScope
|
---|
| 107 | {
|
---|
| 108 | public:
|
---|
| 109 | enum SCOPE_TYPE{
|
---|
| 110 | //ベース
|
---|
| 111 | SCOPE_TYPE_BASE,
|
---|
[237] | 112 |
|
---|
[248] | 113 | //分岐
|
---|
| 114 | SCOPE_TYPE_IF,
|
---|
| 115 |
|
---|
| 116 | //ループ
|
---|
| 117 | SCOPE_TYPE_DO,
|
---|
| 118 | SCOPE_TYPE_FOR,
|
---|
| 119 | SCOPE_TYPE_WHILE,
|
---|
| 120 |
|
---|
| 121 | //ケース分け
|
---|
| 122 | SCOPE_TYPE_SELECT,
|
---|
[237] | 123 | };
|
---|
| 124 |
|
---|
[225] | 125 | private:
|
---|
[248] | 126 | int level;
|
---|
| 127 | int StartAddress;
|
---|
| 128 | SCOPE_TYPE TypeOfStatement;
|
---|
| 129 |
|
---|
| 130 | PertialSchedules breakPertialSchedules;
|
---|
| 131 |
|
---|
| 132 | public:
|
---|
| 133 | LexicalScope( int level, int addr, SCOPE_TYPE TypeOfStatement )
|
---|
| 134 | : level( level )
|
---|
| 135 | , StartAddress( addr )
|
---|
| 136 | , TypeOfStatement( TypeOfStatement )
|
---|
| 137 | {
|
---|
| 138 | }
|
---|
| 139 | ~LexicalScope()
|
---|
| 140 | {
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | int GetStartAddress()
|
---|
| 144 | {
|
---|
| 145 | return StartAddress;
|
---|
| 146 | }
|
---|
| 147 | SCOPE_TYPE GetTypeOfStatement()
|
---|
| 148 | {
|
---|
| 149 | return TypeOfStatement;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | void Break();
|
---|
| 153 | void RunScheduleOfBreak();
|
---|
| 154 | };
|
---|
| 155 |
|
---|
| 156 | class LexicalScopes
|
---|
| 157 | {
|
---|
| 158 | LexicalScope **ppScopes;
|
---|
| 159 | int level;
|
---|
| 160 |
|
---|
| 161 | public:
|
---|
| 162 |
|
---|
| 163 | LexicalScopes(){
|
---|
| 164 | ppScopes = (LexicalScope **)malloc( 1 );
|
---|
| 165 | level=0;
|
---|
| 166 | }
|
---|
| 167 | ~LexicalScopes(){
|
---|
| 168 | free( ppScopes );
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | //初期化(関数コンパイルの開始時に呼び出される)
|
---|
| 172 | void Init(int addr);
|
---|
| 173 |
|
---|
| 174 | // スコープを開始
|
---|
| 175 | void Start( int addr, LexicalScope::SCOPE_TYPE TypeOfStatement );
|
---|
| 176 |
|
---|
| 177 | // スコープを検索
|
---|
| 178 | LexicalScope *SearchScope( LexicalScope::SCOPE_TYPE TypeOfStatement );
|
---|
| 179 |
|
---|
| 180 | int GetNowLevel(void);
|
---|
| 181 | void SetNowLevel( int level );
|
---|
| 182 | int GetStartAddress(void);
|
---|
| 183 |
|
---|
| 184 | void End();
|
---|
| 185 |
|
---|
| 186 | //スコープ終了時のデストラクタ呼び出し
|
---|
| 187 | void CallDestructorsOfScopeEnd();
|
---|
| 188 |
|
---|
| 189 | //Returnステートメント用のデストラクタ呼び出し
|
---|
| 190 | void CallDestructorsOfReturn( int BaseLevel = 0 );
|
---|
| 191 | };
|
---|
| 192 |
|
---|
| 193 | class CodeGenerator
|
---|
| 194 | {
|
---|
| 195 | NativeCode *pNativeCode;
|
---|
| 196 |
|
---|
| 197 | private:
|
---|
[241] | 198 | // 部分スケジュールの管理
|
---|
[237] | 199 | PertialSchedules pertialSchedules;
|
---|
| 200 |
|
---|
[241] | 201 | // Continue用のコード位置情報の管理
|
---|
| 202 | std::vector<long> continueCodePositions;
|
---|
| 203 | std::vector<long> _continueCodePositions_ObpOld;
|
---|
| 204 |
|
---|
[237] | 205 | public:
|
---|
| 206 |
|
---|
[253] | 207 | // ローカル変数用スケジュールの管理
|
---|
| 208 | PertialSchedules localVarPertialSchedules;
|
---|
| 209 |
|
---|
[247] | 210 | // Exit Subスケジュールの管理
|
---|
| 211 | std::vector<long> exitSubCodePositions;
|
---|
| 212 | std::vector<int> _exitSubCodePositions_ObpOld;
|
---|
| 213 |
|
---|
[246] | 214 | // Gotoスケジュールの管理
|
---|
[261] | 215 | GotoLabels gotoLabels;
|
---|
[253] | 216 | GotoLabelSchedules gotoLabelSchedules;
|
---|
[246] | 217 |
|
---|
[248] | 218 | // レキシカルスコープの管理
|
---|
| 219 | LexicalScopes lexicalScopes;
|
---|
| 220 |
|
---|
[237] | 221 | CodeGenerator()
|
---|
| 222 | : pNativeCode( 0 )
|
---|
[225] | 223 | {
|
---|
| 224 | }
|
---|
[237] | 225 | ~CodeGenerator()
|
---|
| 226 | {
|
---|
| 227 | if( pNativeCode )
|
---|
| 228 | {
|
---|
| 229 | CheckUnresolveSchedule();
|
---|
| 230 | }
|
---|
| 231 | }
|
---|
[225] | 232 |
|
---|
| 233 | void Select( NativeCode &nativeCode )
|
---|
| 234 | {
|
---|
[237] | 235 | if( pNativeCode )
|
---|
| 236 | {
|
---|
| 237 | CheckUnresolveSchedule();
|
---|
| 238 | }
|
---|
[225] | 239 | pNativeCode = &nativeCode;
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[241] | 242 | long GetContinueCodePos() const
|
---|
| 243 | {
|
---|
| 244 | if( continueCodePositions.size() == 0 )
|
---|
| 245 | {
|
---|
| 246 | return -1;
|
---|
| 247 | }
|
---|
| 248 | return continueCodePositions[continueCodePositions.size()-1];
|
---|
| 249 | }
|
---|
| 250 | void ClearContinueArea()
|
---|
| 251 | {
|
---|
| 252 | continueCodePositions.clear();
|
---|
| 253 | _continueCodePositions_ObpOld.clear();
|
---|
| 254 | }
|
---|
| 255 | void ContinueAreaBegin()
|
---|
| 256 | {
|
---|
| 257 | continueCodePositions.push_back( pNativeCode->GetSize() );
|
---|
| 258 |
|
---|
| 259 | extern int obp;
|
---|
| 260 | _continueCodePositions_ObpOld.push_back( obp );
|
---|
| 261 | }
|
---|
| 262 | void ContinueAreaEnd()
|
---|
| 263 | {
|
---|
| 264 | continueCodePositions.pop_back();
|
---|
| 265 | _continueCodePositions_ObpOld.pop_back();
|
---|
| 266 | }
|
---|
| 267 | long GetContinueCodePosOld() const
|
---|
| 268 | {
|
---|
| 269 | if( _continueCodePositions_ObpOld.size() == 0 )
|
---|
| 270 | {
|
---|
| 271 | return -1;
|
---|
| 272 | }
|
---|
| 273 | return _continueCodePositions_ObpOld[_continueCodePositions_ObpOld.size()-1];
|
---|
| 274 | }
|
---|
[247] | 275 |
|
---|
| 276 | void ResolveExitSubSchedule();
|
---|
[241] | 277 |
|
---|
[237] | 278 | void CheckUnresolveSchedule();
|
---|
| 279 |
|
---|
[251] | 280 | void opfix( const PertialSchedule *pPertialSchedule, long newValue );
|
---|
[253] | 281 | void opfix_offset( const PertialSchedule *pPertialSchedule, long offset );
|
---|
[238] | 282 | void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule );
|
---|
[237] | 283 |
|
---|
| 284 |
|
---|
| 285 | /////////////////////////////////////////////////////////////////
|
---|
| 286 | // 32bit/64bit共通 機械語生成
|
---|
| 287 | /////////////////////////////////////////////////////////////////
|
---|
| 288 |
|
---|
| 289 | private:
|
---|
[245] | 290 | const PertialSchedule *__jmp_op_format( char opcode, long offset, int op_size, bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[237] | 291 | public:
|
---|
[250] | 292 | const PertialSchedule *op_jle( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 293 | const PertialSchedule *op_jbe( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 294 | const PertialSchedule *op_jge( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 295 | const PertialSchedule *op_jae( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 296 | const PertialSchedule *op_jl( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 297 | const PertialSchedule *op_jb( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 298 | const PertialSchedule *op_jg( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 299 | const PertialSchedule *op_ja( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 300 | const PertialSchedule *op_jne( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 301 | const PertialSchedule *op_je( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[245] | 302 | const PertialSchedule *op_jmp( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[241] | 303 | void op_jmp_continue();
|
---|
[247] | 304 | void op_jmp_exitsub();
|
---|
[253] | 305 | void op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos );
|
---|
[237] | 306 |
|
---|
| 307 |
|
---|
[225] | 308 | #ifdef _AMD64_
|
---|
[228] | 309 | /////////////////////////////////////////////////////////////////
|
---|
[237] | 310 | // 64ビット機械語生成
|
---|
[228] | 311 | /////////////////////////////////////////////////////////////////
|
---|
[226] | 312 | private:
|
---|
| 313 | void set_rex(int op_size,int reg,int index_reg,int base_reg);
|
---|
[254] | 314 | const PertialSchedule *set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 315 | const PertialSchedule *__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 316 | public:
|
---|
[232] | 317 | void op_mov_RV (int op_size,int reg,long i32data, Schedule::Type scheduleType = Schedule::None );
|
---|
[226] | 318 | void op_mov_RV64 (int reg,_int64 i64data);
|
---|
[254] | 319 | const PertialSchedule *op_mov_RM (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 320 | 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 );
|
---|
| 321 | const PertialSchedule *op_mov_MR (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 322 | 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 );
|
---|
| 323 | const PertialSchedule *op_mov_MV (int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, BOOL bUseOffset,long i32data);
|
---|
[226] | 324 | void op_mov_RR (int reg1,int reg2);
|
---|
| 325 | void op_movsxd (int reg64,int reg32);
|
---|
| 326 | void op_movsx64_FromReg16 (int reg64,int reg16);
|
---|
| 327 | void op_movsx64_FromReg8 (int reg64,int reg8);
|
---|
| 328 | void op_movsx32_FromReg16 (int reg32,int reg16);
|
---|
| 329 | void op_movsx32_FromReg8 (int reg32,int reg8);
|
---|
| 330 | void op_movsx16_FromReg8 (int reg32,int reg8);
|
---|
[228] | 331 | void op_cqo ();
|
---|
[226] | 332 | void op_inc (int reg);
|
---|
| 333 | void op_dec (int reg);
|
---|
[254] | 334 | 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 );
|
---|
| 335 | const PertialSchedule *op_add_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[228] | 336 | void op_add_RR (int reg1,int reg2);
|
---|
[226] | 337 | void op_add32_reg (int reg1,int reg2);
|
---|
| 338 | void op_sub_RV (int op_size,int reg,long i32data);
|
---|
| 339 | void op_sub64_reg (int reg1,int reg2);
|
---|
| 340 | void op_sub32_reg (int reg1,int reg2);
|
---|
| 341 | void op_sbb_RR ( int op_size, int reg1, int reg2 );
|
---|
| 342 | void op_imul_RR (int op_size,int reg1,int reg2);
|
---|
| 343 | void op_imul_RV (int op_size,int reg,long i32data);
|
---|
| 344 | void op_div64_reg (int reg);
|
---|
| 345 | void op_idiv64_reg (int reg);
|
---|
| 346 | void op_shl_reg (int op_size,int reg);
|
---|
| 347 | void op_sar_reg (int op_size,int reg);
|
---|
| 348 | void op_shr_reg (int op_size,int reg);
|
---|
| 349 | void op_and_reg (int op_size,int reg1,int reg2);
|
---|
| 350 | void op_and64_value (int reg,long offset);
|
---|
| 351 | void op_and32_value (int reg,long offset);
|
---|
| 352 | void op_or_reg (int op_size,int reg1,int reg2);
|
---|
| 353 | void op_xor_reg (int op_size,int reg1,int reg2);
|
---|
| 354 | void op_not_reg (int op_size,int reg);
|
---|
| 355 | void op_neg ( int reg );
|
---|
| 356 | void op_test (int reg1,int reg2);
|
---|
| 357 | void op_cmp_reg (int op_size,int reg1,int reg2);
|
---|
| 358 | void op_cmp_value (int op_size,int reg,char byte_data);
|
---|
| 359 | void op_setne (int reg);
|
---|
[254] | 360 | const PertialSchedule *op_movlpd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 361 | const PertialSchedule *op_movlpd_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 362 | void op_movsd_RR (int xmm_reg1,int xmm_reg2);
|
---|
[254] | 363 | const PertialSchedule *op_movsd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 364 | void op_movss_RR (int xmm_reg1,int xmm_reg2);
|
---|
[254] | 365 | const PertialSchedule *op_movss_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 366 | const PertialSchedule *op_movss_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 367 | void op_movd_RX (int reg,int xmm_reg);
|
---|
| 368 | void op_cvtsd2ss (int xmm_reg1,int xmm_reg2);
|
---|
| 369 | void op_cvtss2sd (int xmm_reg1,int xmm_reg2);
|
---|
| 370 | void op_cvttsd2si_xmm (int op_size,int reg,int xmm_reg);
|
---|
| 371 | void op_cvttss2si_xmm (int op_size,int reg,int xmm_reg);
|
---|
| 372 | void op_cvtsi2sd_reg (int op_size,int xmm_reg,int reg);
|
---|
| 373 | void op_cvtsi2ss_reg (int op_size,int xmm_reg,int reg);
|
---|
| 374 | void op_comisd (int xmm_reg1,int xmm_reg2);
|
---|
| 375 | void op_comiss (int xmm_reg1,int xmm_reg2);
|
---|
| 376 | void op_rep_movs (int op_size);
|
---|
| 377 | void op_add_rsp(long num);
|
---|
[255] | 378 | const PertialSchedule *op_sub_rsp( long num, bool isPertialSchedule = false );
|
---|
[226] | 379 | void op_fld_ptr_esp(int type);
|
---|
| 380 | void op_zero_reg(int reg);
|
---|
| 381 | void op_call( const UserProc *pUserProc );
|
---|
| 382 | void op_call( const DllProc *pDllProc );
|
---|
| 383 | void op_ret();
|
---|
| 384 |
|
---|
[225] | 385 | #else
|
---|
[228] | 386 | /////////////////////////////////////////////////////////////////
|
---|
[237] | 387 | // 32ビット機械語生成
|
---|
[228] | 388 | /////////////////////////////////////////////////////////////////
|
---|
[225] | 389 | private:
|
---|
[251] | 390 | 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 );
|
---|
[225] | 391 | void __op_format(char op_prefix,char opcode,int reg);
|
---|
[251] | 392 | 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 );
|
---|
[225] | 393 | public:
|
---|
[253] | 394 | 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 );
|
---|
| 395 | void op_mov_RV ( int reg,long offset, Schedule::Type scheduleType = Schedule::None );
|
---|
| 396 | void op_mov_RR ( int reg1,int reg2);
|
---|
| 397 | 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 );
|
---|
| 398 | 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 );
|
---|
| 399 | 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 );
|
---|
| 400 | 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 );
|
---|
| 401 | void op_movsx_R32R16 ( int reg32,int reg16 = REG_NON);
|
---|
| 402 | void op_movsx_R32R8 ( int reg32,int reg8 = REG_NON);
|
---|
| 403 | void op_movsx_R16R8 ( int reg16,int reg8 = REG_NON);
|
---|
| 404 | const PertialSchedule *op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 405 | void op_inc (int reg);
|
---|
| 406 | void op_dec (int reg);
|
---|
| 407 | void op_add_RV8 (int reg,char cValue);
|
---|
| 408 | const PertialSchedule *op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 409 | void op_add_RR ( int reg1, int reg2 );
|
---|
| 410 | 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 );
|
---|
[225] | 411 | void op_adc_RV8 (int reg,char cValue);
|
---|
| 412 | void op_adc_RR ( int reg1, int reg2 );
|
---|
| 413 | void op_sub_RV8 (int reg,char cValue);
|
---|
| 414 | void op_sub_RR ( int reg1, int reg2 );
|
---|
| 415 | void op_sbb_RV8 (int reg,char cValue);
|
---|
| 416 | void op_sbb_RR ( int reg1, int reg2 );
|
---|
| 417 | void op_imul_RR (int reg1,int reg2);
|
---|
| 418 | void op_imul_RV (int reg,long i32data);
|
---|
| 419 | void op_imul_RV8 (int reg,char cValue);
|
---|
| 420 | void op_div_R ( int reg );
|
---|
| 421 | void op_idiv_R ( int reg );
|
---|
| 422 | void op_and_RV (int reg,long value);
|
---|
| 423 | void op_and_RR ( int reg1, int reg2 );
|
---|
| 424 | void op_or_RR ( int op_size, int reg1, int reg2 );
|
---|
| 425 | void op_xor_RR ( int reg1, int reg2 = REG_NON );
|
---|
| 426 | void op_neg ( int reg );
|
---|
| 427 | void op_cdq ();
|
---|
| 428 |
|
---|
| 429 | void op_rep_movs (int op_size);
|
---|
| 430 |
|
---|
| 431 | void op_push(int reg);
|
---|
[237] | 432 | void op_push_V( long data, Schedule::Type scheduleType = Schedule::None );
|
---|
[225] | 433 | void op_push_M( int base_reg );
|
---|
[251] | 434 | const PertialSchedule *op_push_M( int base_reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[225] | 435 | void op_pop(int reg = REG_NON);
|
---|
| 436 | void op_add_esp(long num);
|
---|
[253] | 437 | const PertialSchedule *op_sub_esp( long num, bool isPertialSchedule = false );
|
---|
[225] | 438 | void op_cmp_RR( int reg1, int reg2 );
|
---|
| 439 | void op_cmp_value(int op_size,int reg,char byte_data);
|
---|
| 440 | void op_setne( int reg );
|
---|
| 441 | void op_test(int reg1,int reg2);
|
---|
| 442 | void op_test_ah( char cValue );
|
---|
| 443 | void op_fld_ptr_esp(int type);
|
---|
| 444 | void op_fld_basereg (int type,int base_reg);
|
---|
[253] | 445 | const PertialSchedule *op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 446 | 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 );
|
---|
[225] | 447 | void op_fstp_basereg (int type,int base_reg);
|
---|
[253] | 448 | const PertialSchedule *op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 449 | 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 );
|
---|
[225] | 450 | void op_fistp_ptr_esp ( int typeSize );
|
---|
| 451 | void op_fstp_push ( Type &type );
|
---|
| 452 | void op_fcompp();
|
---|
| 453 | void op_fnstsw_ax();
|
---|
| 454 | void op_zero_reg(int reg);
|
---|
| 455 | void fpu_cast();
|
---|
| 456 | void fpu_cast_end();
|
---|
| 457 |
|
---|
[235] | 458 | void op_call_R( int reg );
|
---|
[225] | 459 | void op_call(const UserProc *pUserProc);
|
---|
[250] | 460 | void op_call(const DllProc *pDllProc);
|
---|
[225] | 461 | void op_ret();
|
---|
[240] | 462 | void op_ret( short stackFrameSize );
|
---|
[244] | 463 | void op_addressof( int reg, const UserProc *pUserProc );
|
---|
[225] | 464 | #endif
|
---|
| 465 |
|
---|
| 466 |
|
---|
| 467 |
|
---|
[242] | 468 | void PutOld( long l, Schedule::Type scheduleType )
|
---|
| 469 | {
|
---|
| 470 | pNativeCode->Put( l, scheduleType );
|
---|
| 471 | }
|
---|
[254] | 472 | const PertialSchedule *PutOld( long l, bool isPertialSchedule )
|
---|
| 473 | {
|
---|
| 474 | const PertialSchedule *pPertialSchedule;
|
---|
| 475 | if( isPertialSchedule )
|
---|
| 476 | {
|
---|
| 477 | pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
|
---|
| 478 | pPertialSchedule = pertialSchedules.back();
|
---|
| 479 | }
|
---|
| 480 | pNativeCode->Put( l, Schedule::None );
|
---|
| 481 | return pPertialSchedule;
|
---|
| 482 | }
|
---|
[252] | 483 | void PutOld( const NativeCode &nativeCode )
|
---|
| 484 | {
|
---|
[258] | 485 | pNativeCode->Put( nativeCode, true );
|
---|
[252] | 486 | }
|
---|
[253] | 487 | void PutOld( char c )
|
---|
| 488 | {
|
---|
| 489 | pNativeCode->Put( c );
|
---|
| 490 | }
|
---|
[225] | 491 | void PutOld( char c1, char c2 )
|
---|
| 492 | {
|
---|
| 493 | pNativeCode->Put( c1 );
|
---|
| 494 | pNativeCode->Put( c2 );
|
---|
| 495 | }
|
---|
| 496 | void PutOld( char c1, char c2, char c3 )
|
---|
| 497 | {
|
---|
| 498 | pNativeCode->Put( c1 );
|
---|
| 499 | pNativeCode->Put( c2 );
|
---|
| 500 | pNativeCode->Put( c3 );
|
---|
| 501 | }
|
---|
| 502 | void PutOld( char c1, char c2, char c3, char c4 )
|
---|
| 503 | {
|
---|
| 504 | pNativeCode->Put( c1 );
|
---|
| 505 | pNativeCode->Put( c2 );
|
---|
| 506 | pNativeCode->Put( c3 );
|
---|
| 507 | pNativeCode->Put( c4 );
|
---|
| 508 | }
|
---|
[228] | 509 | void PutOld( char c1, char c2, char c3, long l )
|
---|
| 510 | {
|
---|
| 511 | pNativeCode->Put( c1 );
|
---|
| 512 | pNativeCode->Put( c2 );
|
---|
| 513 | pNativeCode->Put( c3 );
|
---|
| 514 | pNativeCode->Put( l );
|
---|
| 515 | }
|
---|
[225] | 516 | void PutOld( char c1, char c2, char c3, char c4, char c5 )
|
---|
| 517 | {
|
---|
| 518 | pNativeCode->Put( c1 );
|
---|
| 519 | pNativeCode->Put( c2 );
|
---|
| 520 | pNativeCode->Put( c3 );
|
---|
| 521 | pNativeCode->Put( c4 );
|
---|
| 522 | pNativeCode->Put( c5 );
|
---|
| 523 | }
|
---|
| 524 | void PutOld( char c1, char c2, char c3, char c4, char c5, char c6 )
|
---|
| 525 | {
|
---|
| 526 | pNativeCode->Put( c1 );
|
---|
| 527 | pNativeCode->Put( c2 );
|
---|
| 528 | pNativeCode->Put( c3 );
|
---|
| 529 | pNativeCode->Put( c4 );
|
---|
| 530 | pNativeCode->Put( c5 );
|
---|
| 531 | pNativeCode->Put( c6 );
|
---|
| 532 | }
|
---|
| 533 | };
|
---|