diff --git a/sourcepawn/vm/jit/x86/jit_x86.cpp b/sourcepawn/vm/jit/x86/jit_x86.cpp index 85e58322..cd791b91 100644 --- a/sourcepawn/vm/jit/x86/jit_x86.cpp +++ b/sourcepawn/vm/jit/x86/jit_x86.cpp @@ -1164,6 +1164,41 @@ inline void WriteOp_Lctrl(JitWriter *jit) } } +inline void WriteOp_Sctrl(JitWriter *jit) +{ + cell_t val = jit->read_cell(); + switch (val) + { + case 2: + { + //mov [esi+hea], eax + IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, AMX_INFO_HEAP, AMX_REG_PRI); + break; + } + case 4: + { + //lea ebp, [edi+eax] + IA32_Lea_Reg_DispRegMult(jit, AMX_REG_STK, AMX_REG_DAT, AMX_REG_PRI, NOSCALE); + break; + } + case 5: + { + //mov ebx, eax - overwrite frm + //mov frm, eax - overwrite stacked frame + //add ebx, edi - relocate local frm + IA32_Mov_Reg_Rm(jit, AMX_REG_FRM, AMX_REG_PRI, MOD_REG); + IA32_Mov_Rm_Reg(jit, AMX_INFO_FRM, AMX_REG_PRI, MOD_MEM_REG); + IA32_Add_Rm_Reg(jit, AMX_REG_FRM, AMX_REG_DAT, MOD_REG); + break; + } + case 6: + { + IA32_Jump_Reg(jit, AMX_REG_PRI); + break; + } + } +} + /************************************************* ************************************************* * JIT PROPER ************************************ @@ -1858,6 +1893,11 @@ IPluginContext *JITX86::CompileToContext(ICompilation *co, int *err) WriteOp_Lctrl(jit); break; } + case OP_SCTRL: + { + WriteOp_Sctrl(jit); + break; + } default: { AbortCompilation(co); diff --git a/sourcepawn/vm/jit/x86/opcode_helpers.h b/sourcepawn/vm/jit/x86/opcode_helpers.h index 7ecfe8f9..01942b03 100644 --- a/sourcepawn/vm/jit/x86/opcode_helpers.h +++ b/sourcepawn/vm/jit/x86/opcode_helpers.h @@ -64,7 +64,7 @@ typedef enum OP_ALIGN_PRI, //DONE OP_ALIGN_ALT, //DONE OP_LCTRL, //DONE - OP_SCTRL, + OP_SCTRL, //DONE OP_MOVE_PRI, //DONE OP_MOVE_ALT, //DONE OP_XCHG, //DONE diff --git a/sourcepawn/vm/jit/x86/x86_macros.h b/sourcepawn/vm/jit/x86/x86_macros.h index 5b93e10c..dc86e62f 100644 --- a/sourcepawn/vm/jit/x86/x86_macros.h +++ b/sourcepawn/vm/jit/x86/x86_macros.h @@ -65,6 +65,7 @@ #define IA32_SUB_RM_IMM32 0x81 // encoding is /5 #define IA32_JMP_IMM32 0xE9 // encoding is imm32 #define IA32_JMP_IMM8 0xEB // encoding is imm8 +#define IA32_JMP_RM 0xFF // encoding is /4 #define IA32_CALL_IMM32 0xE8 // relative call, #define IA32_CALL_RM 0xFF // encoding is /2 #define IA32_MOV_REG_IMM 0xB8 // encoding is +r @@ -734,6 +735,12 @@ inline jitoffs_t IA32_Jump_Cond_Imm32(JitWriter *jit, jit_uint8_t cond, jit_int3 return ptr; } +inline void IA32_Jump_Reg(JitWriter *jit, jit_uint8_t reg) +{ + jit->write_ubyte(IA32_JMP_RM); + jit->write_ubyte(ia32_modrm(MOD_REG, 4, reg)); +} + inline jitoffs_t IA32_Call_Imm32(JitWriter *jit, jit_int32_t disp) { jitoffs_t ptr;