diff --git a/public/jit/jit_helpers.h b/public/jit/jit_helpers.h index c882a307..c6c18fda 100644 --- a/public/jit/jit_helpers.h +++ b/public/jit/jit_helpers.h @@ -62,6 +62,14 @@ public: } outptr++; } + inline void write_ushort(unsigned short c) + { + if (outbase) + { + *(unsigned short *)outptr = c; + } + outptr += sizeof(unsigned short); + } inline void write_byte(jit_int8_t c) { if (outbase) diff --git a/public/jit/x86/x86_macros.h b/public/jit/x86/x86_macros.h index 72f5c29c..5e83e66a 100644 --- a/public/jit/x86/x86_macros.h +++ b/public/jit/x86/x86_macros.h @@ -107,6 +107,7 @@ #define IA32_JCC_IMM32_1 0x0F // opcode part 1 #define IA32_JCC_IMM32_2 0x80 // encoding is +cc #define IA32_RET 0xC3 // no extra encoding +#define IA32_RETN 0xC2 // encoding is #define IA32_NEG_RM 0xF7 // encoding is /3 #define IA32_INC_REG 0x40 // encoding is +r #define IA32_INC_RM 0xFF // encoding is /0 @@ -1349,6 +1350,12 @@ inline void IA32_Return(JitWriter *jit) jit->write_ubyte(IA32_RET); } +inline void IA32_Return_Popstack(JitWriter *jit, unsigned short bytes) +{ + jit->write_ubyte(IA32_RETN); + jit->write_ushort(bytes); +} + inline void IA32_Test_Rm_Reg(JitWriter *jit, jit_uint8_t reg1, jit_uint8_t reg2, jit_uint8_t mode) { jit->write_ubyte(IA32_TEST_RM_REG);