{ VX_CODEGEN by Anskya[2010] Email: Anskya[AT]live.com [说明]: 为了直观和降低使用难度,这里没有采用一般的Generater的生成法, 这里采用Morphine的设计方式.更加直观了(当然实际开发中还是用AsmJit这样的引擎) [0.22]: [+]针对BPE32的垃圾指令类型增加了所有相关的指令集 [+]调整修复了一些bug [+]发现shl reg32, imm8另外一种写法0C1h, 0F0h, 0FFh [0.21]: [+]增加全系列rol操作类函数,以后位操作全部以rol为准 [+]增加push reg64,pop reg64指令,尝试64位下的指令生成 [0.201]: [+]增加了版权说明 [*]修复了一些小bug [0.2]: [*]为了ETG 2.50更新了一些函数,目前已经可以实现了2.5的函数 [0.15]: [*]基于ETG 2.0增加了相关函数 [0.12]: [*]基于ETG 1.0增加了相关函数 [0.1]: [!]first version... } {$ifndef VXL_INLINE_MODE} unit VxCodeGen32; interface uses VxSystem; {$endif} type VX_REG64 = ( REG64_RAX = 0, REG64_RCX, REG64_RDX, REG64_RBX, REG64_RSP, REG64_RBP, REG64_RSI, REG64_RDI, REG64_R8, REG64_R9, REG64_R10, REG64_R11, REG64_R12, REG64_R13, REG64_R14, REG64_R15 ); VX_REG32 = ( REG32_EAX = 0, REG32_ECX, REG32_EDX, REG32_EBX, REG32_ESP, REG32_EBP, REG32_ESI, REG32_EDI ); VX_REG16 = ( REG16_AX = 0, REG16_CX, REG16_DX, REG16_BX, REG16_SP, REG16_BP, REG16_SI, REG16_DI ); VX_REG8 = ( REG8_AL, REG8_CL, REG8_DL, REG8_BL, REG8_AH, REG8_CH, REG8_DH, REG8_BH ); VX_REL8 = ShortInt; VX_REL32 = Integer; VX_IMM8 = Byte; VX_IMM16 = WORD; VX_IMM32 = LongWord; VX_IMM64 = UInt64; VX_IDX8 = Byte; VX_MEM8 = Byte; VX_MEM16 = WORD; VX_MEM32 = LongWord; VX_MEM64 = UInt64; {$ifndef VXL_INLINE_MODE} function Put_Bytes(lpDst: Pointer; nSize: SIZE_T; p: Pointer; n: SIZE_T): Integer; function db(lpDst: Pointer; nSize: SIZE_T; b: Byte): Integer; function dw(lpDst: Pointer; nSize: SIZE_T; w: Word): Integer; function dd(lpDst: Pointer; nSize: SIZE_T; d: LongWord): Integer; function VxCodeGen_Radmon(nSeed: LongWord): Longword; function prefix_es(lpDst: Pointer; nSize: SIZE_T): Integer; function prefix_fs(lpDst: Pointer; nSize: SIZE_T): Integer; function prefix_gs(lpDst: Pointer; nSize: SIZE_T): Integer; function prefix_lock(lpDst: Pointer; nSize: SIZE_T): Integer; function prefix_repnz(lpDst: Pointer; nSize: SIZE_T): Integer; function prefix_repx(lpDst: Pointer; nSize: SIZE_T): Integer; function nop(lpDst: Pointer; nSize: SIZE_T): Integer; // undoc function salc(lpDst: Pointer; nSize: SIZE_T): Integer; function clc(lpDst: Pointer; nSize: SIZE_T): Integer; function cwde(lpDst: Pointer; nSize: SIZE_T): Integer; function stc(lpDst: Pointer; nSize: SIZE_T): Integer; function cld(lpDst: Pointer; nSize: SIZE_T): Integer; // === function ret(lpDst: Pointer; nSize: SIZE_T): Integer; function ret__imm16(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM16): Integer; // === function pushad(lpDst: Pointer; nSize: SIZE_T): Integer; function popad(lpDst: Pointer; nSize: SIZE_T): Integer; function pushfd(lpDst: Pointer; nSize: SIZE_T): Integer; function popfd(lpDst: Pointer; nSize: SIZE_T): Integer; // push === function push__imm8(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM8): Integer; function push__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function push__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; function push__reg64(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG64): Integer; function push__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // pop === function pop__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; function pop__reg64(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG64): Integer; function pop__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // call === function call__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; function call__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; // jecxz === function jecxz__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; // jmp === function jmp__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; function jmp__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; function jmp__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // jb === function jb__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; // jnb === function jnb__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; // js & jns === function js__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; function jns__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; function js__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; function jns__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; // bswap === function bswap__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // inc === function inc__reg8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function inc__reg16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; function inc__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; function inc__Mem8_Reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; function inc__Mem16_Reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; function inc__Mem32_Reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // dec === function dec__reg8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function dec__reg16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; function dec__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // not === function not__reg8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function not__reg16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; function not__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // test === function test__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; function test__reg16__reg16(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG16): Integer; function test__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function test__al__imm8(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM8): Integer; function test__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; function test__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function test__reg32mem32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; // mov === function mov__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; function mov__reg8__reg8_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; function mov__reg16__reg16(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG16): Integer; function mov__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function mov__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function mov__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; function mov__reg8__imm8_x(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; function mov__reg16__imm16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16; nImm: VX_IMM16): Integer; function mov__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; function mov__reg32__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function mov__mem32_reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function mov__reg32__mem32_reg32_Idx8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32; nIdx8: VX_IDX8): Integer; // movzx === function movzx__reg32__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1: VX_REG32; nReg2: VX_REG8): Integer; // xchg === function xchg__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; function xchg__eax__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; // lea === function lea__reg32__mem32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nMem: VX_MEM32): Integer; // add === function add__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; function add__reg8__reg8_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; function add__al__imm8(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM8): Integer; function add__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; function add__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function add__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function add__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function add__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function add__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function add__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // or === function or__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function or__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function or__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function or__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function or__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function or__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // adc === function adc__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function adc__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function adc__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function adc__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function adc__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function adc__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // sbb === function sbb__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function sbb__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function sbb__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function sbb__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function sbb__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function sbb__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // and === function and__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function and__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function and__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function and__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function and__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function and__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // sub === function sub__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function sub__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function sub__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function sub__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function sub__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function sub__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // xor === function xor__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function xor__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function xor__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function xor__reg32__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function xor__mem32_reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function xor__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function xor__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // cmp === function cmp__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function cmp__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; function cmp__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; // imul === function imul__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function imul__reg32__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32; nImm: VX_IMM32): Integer; // rol === function rol__reg8__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function rol__reg8__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function rol__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; function rol__reg16__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; function rol__reg16__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; function rol__reg16__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16; nImm: VX_IMM8): Integer; function rol__reg32__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function rol__reg32__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function rol__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function rol__reg32mem32__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function rol__reg32mem32__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function rol__reg32mem32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; // ror === function ror__reg8__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; function ror__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; function ror__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; // rcl === function rcl__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; // rcr === function rcr__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; // shl === function shl__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; // shr === function shr__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; // shl x === function shl__reg32__imm8_x(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; // sar === function sar__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; // shld === function shld__reg32__reg32__cl(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function shld__reg32__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32; nImm: VX_IMM8): Integer; // xadd === function xadd__reg32mem8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1: VX_REG32; nReg2: VX_REG8): Integer; function bsf__reg32mem32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; function bt__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; function bt__reg32mem32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; implementation {$endif} function Put_Bytes(lpDst: Pointer; nSize: SIZE_T; p: Pointer; n: SIZE_T): Integer; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < n)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if (Not Vx_IsReadPtr(p, n)) then Exit; {$endif} Result := n; while (n > 0) do begin PByte(lpDst)^ := PByte(p)^; Inc(PByte(lpDst)); Inc(PByte(p)); Dec(n); end; end; function db(lpDst: Pointer; nSize: SIZE_T; b: Byte): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} PByte(lpDst)^ := b; Result := CODE_SIZE; end; function dw(lpDst: Pointer; nSize: SIZE_T; w: Word): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} PWord(lpDst)^ := w; Result := CODE_SIZE; end; function dd(lpDst: Pointer; nSize: SIZE_T; d: LongWord): Integer; const CODE_SIZE = 4; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} PLongWord(lpDst)^ := d; Result := CODE_SIZE; end; function VxCodeGen_Radmon(nSeed: LongWord): Longword; asm {$ifndef CPUX64} xchg ecx, eax {$endif} rdtsc ror eax, 7 add eax, edx ror eax, 3 test ecx, ecx jz @@end xor edx, edx div ecx mov eax, edx @@end: end; // ============================================================================ // ES:(Prefix) function prefix_es(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $26; Result := CODE_SIZE; end; // FS:(Prefix) function prefix_fs(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $64; Result := CODE_SIZE; end; // GS:(Prefix) function prefix_gs(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $65; Result := CODE_SIZE; end; // lock(Prefix) function prefix_lock(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $F0; Result := CODE_SIZE; end; // REPNZ(Prefix) function prefix_repnz(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $F2; Result := CODE_SIZE; end; // REPX(Prefix) function prefix_repx(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $F3; Result := CODE_SIZE; end; // ============================================================================ // nop function nop(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $90; Result := CODE_SIZE; end; // salc = 未文档指令集(BPE32b) function salc(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $D6; Result := CODE_SIZE; end; // clc function clc(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $F8; Result := CODE_SIZE; end; // cwde function cwde(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $98; Result := CODE_SIZE; end; // stc function stc(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $F9; Result := CODE_SIZE; end; // cld function cld(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $FC; Result := CODE_SIZE; end; // ret function ret(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $C3; Result := CODE_SIZE; end; function ret__imm16(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM16): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $C3; Inc(PByte(lpDst)); PWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // pushad function pushad(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $60; Result := CODE_SIZE; end; function popad(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $61; Result := CODE_SIZE; end; function pushfd(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $9C; Result := CODE_SIZE; end; function popfd(lpDst: Pointer; nSize: SIZE_T): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $9D; Result := CODE_SIZE; end; // ============================================================================ // push imm8 function push__imm8(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $6A; Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // push imm32 function push__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $68; Inc(PByte(lpDst)); PLongWord(lpDst)^ := LongWord(nImm); Result := CODE_SIZE; end; // push reg32 function push__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $50 + Byte(nReg); Result := CODE_SIZE; end; // push reg64 function push__reg64(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG64): Integer; const CODE_SIZE = 1; CODE_MAX_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_MAX_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} if (nReg < REG64_R8) then begin // opcode PByte(lpDst)^ := $50 + Byte(nReg); Result := CODE_SIZE; end else begin // opcode PByte(lpDst)^ := $41; Inc(PByte(lpDst)); PByte(lpDst)^ := $50 + Byte(nReg); Result := CODE_MAX_SIZE; end; end; // push dword ptr[reg32] function push__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $FF; Inc(PByte(lpDst)); case nReg of REG32_ESP: begin PByte(lpDst)^ := $34; Inc(PByte(lpDst)); PByte(lpDst)^ := $24; Inc(PByte(lpDst)); Result := CODE_SIZE + 1; end; REG32_EBP: begin PByte(lpDst)^ := $75; Inc(PByte(lpDst)); PByte(lpDst)^ := $00; Inc(PByte(lpDst)); Result := CODE_SIZE + 1; end; else PByte(lpDst)^ := $30 + Byte(nReg); Result := CODE_SIZE; end; end; // ============================================================================ // pop reg32 function pop__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $58 + Byte(nReg); Result := CODE_SIZE; end; // pop reg64 function pop__reg64(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG64): Integer; const CODE_SIZE = 1; CODE_MAX_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_MAX_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} if (nReg < REG64_R8) then begin // opcode PByte(lpDst)^ := $58 + Byte(nReg); Result := CODE_SIZE; end else begin // opcode PByte(lpDst)^ := $41; Inc(PByte(lpDst)); PByte(lpDst)^ := $58 + Byte(nReg); Result := CODE_MAX_SIZE; end; end; // pop [reg32] function pop__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $8F; Inc(PByte(lpDst)); case nReg of REG32_ESP: begin PByte(lpDst)^ := $04; Inc(PByte(lpDst)); PByte(lpDst)^ := $24; Inc(PByte(lpDst)); Result := CODE_SIZE + 1; end; REG32_EBP: begin PByte(lpDst)^ := $45; Inc(PByte(lpDst)); PByte(lpDst)^ := $00; Inc(PByte(lpDst)); Result := CODE_SIZE + 1; end; else PByte(lpDst)^ := Byte(nReg); Result := CODE_SIZE; end; end; // ============================================================================ // call function call__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $FF; Inc(PByte(lpDst)); PByte(lpDst)^ := $D0 + Byte(nReg); Result := CODE_SIZE; end; function call__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $E8; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nRel; Result := CODE_SIZE; end; // ============================================================================ // jmp rel8 function jmp__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $EB; Inc(PByte(lpDst)); PByte(lpDst)^ := nRel; Result := CODE_SIZE; end; // jmp rel32 function jmp__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $E9; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nRel; Result := CODE_SIZE; end; // jmp reg32 function jmp__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $FF; Inc(PByte(lpDst)); PByte(lpDst)^ := $E0 + Byte(nReg); Result := CODE_SIZE; end; // ============================================================================ // jecxz rel8 function jecxz__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $E3; Inc(PByte(lpDst)); PByte(lpDst)^ := nRel; Result := CODE_SIZE; end; // ============================================================================ // jb(jc) rel8 function jb__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $72; Inc(PByte(lpDst)); PByte(lpDst)^ := nRel; Result := CODE_SIZE; end; // jnb(jnc) rel8 function jnb__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $73; Inc(PByte(lpDst)); PByte(lpDst)^ := nRel; Result := CODE_SIZE; end; // ============================================================================ // js rel8 function js__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $78; Inc(PByte(lpDst)); PByte(lpDst)^ := nRel; Result := CODE_SIZE; end; // jns rel8 function jns__rel8(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $79; Inc(PByte(lpDst)); PByte(lpDst)^ := nRel; Result := CODE_SIZE; end; // js rel32 function js__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $88; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nRel; Result := CODE_SIZE; end; // jns rel32 function jns__rel32(lpDst: Pointer; nSize: SIZE_T; nRel: VX_REL32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $89; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nRel; Result := CODE_SIZE; end; // ============================================================================ // bswap reg32 function bswap__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $C8 + Byte(nReg); Result := CODE_SIZE; end; // ============================================================================ // inc reg8 function inc__Reg8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $FE; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Result := CODE_SIZE; end; // inc reg16 function inc__Reg16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $66; Inc(PByte(lpDst)); PByte(lpDst)^ := $40 + Byte(nReg); Result := CODE_SIZE; end; // inc reg32 function inc__Reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $40 + Byte(nReg); Result := CODE_SIZE; end; // inc byte ptr[reg32] function inc__Mem8_Reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $FE; Inc(PByte(lpDst)); case nReg of REG32_ESP: begin PByte(lpDst)^ := $04; Inc(PByte(lpDst)); PByte(lpDst)^ := $24; Result := CODE_SIZE + 1; end; REG32_EBP: begin PByte(lpDst)^ := $45; Inc(PByte(lpDst)); PByte(lpDst)^ := $00; Result := CODE_SIZE + 1; end; else PByte(lpDst)^ := Byte(nReg); Result := CODE_SIZE; end; end; // inc word ptr[reg32] function inc__Mem16_Reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 3; var nLen: Integer; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $66; Inc(PByte(lpDst)); Dec(nSize); nLen := inc__Mem32_Reg32(lpDst, nSize, nReg); if (nLen > 0) then Result := nLen + 1 else Result := 0; end; // inc dword ptr[reg32] function inc__Mem32_Reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $FF; Inc(PByte(lpDst)); case nReg of REG32_ESP: begin PByte(lpDst)^ := $04; Inc(PByte(lpDst)); PByte(lpDst)^ := $24; Result := CODE_SIZE + 1; end; REG32_EBP: begin PByte(lpDst)^ := $45; Inc(PByte(lpDst)); PByte(lpDst)^ := $00; Result := CODE_SIZE + 1; end; else PByte(lpDst)^ := Byte(nReg); Result := CODE_SIZE; end; end; // ============================================================================ // dec reg8 function dec__reg8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $FE; Inc(PByte(lpDst)); PByte(lpDst)^ := $C8 + Byte(nReg); Result := CODE_SIZE; end; // dec reg16 function dec__reg16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $66; Inc(PByte(lpDst)); PByte(lpDst)^ := $48 + Byte(nReg); Result := CODE_SIZE; end; // dec reg32 function dec__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $48 + Byte(nReg); Result := CODE_SIZE; end; // ============================================================================ // not reg8 function not__reg8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $F6; Inc(PByte(lpDst)); PByte(lpDst)^ := $D0 + Byte(nReg); Result := CODE_SIZE; end; // not reg16 function not__reg16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $66; Inc(PByte(lpDst)); PByte(lpDst)^ := $F7; Inc(PByte(lpDst)); PByte(lpDst)^ := $D0 + Byte(nReg); Result := CODE_SIZE; end; // not reg32 function not__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $F7; Inc(PByte(lpDst)); PByte(lpDst)^ := $D0 + Byte(nReg); Result := CODE_SIZE; end; // ============================================================================ // test reg8, reg8 function test__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $84; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; // test al, imm8 function test__al__imm8(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $A8; Inc(PByte(lpDst)); PUInt8(lpDst)^ := nImm; Result := CODE_SIZE; end; // test reg8, imm8 function test__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $F6; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PUInt8(lpDst)^ := nImm; Result := CODE_SIZE; end; function test__reg16__reg16(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG16): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // PByte(lpDst)^ := $66; Inc(PByte(lpDst)); // opcode PByte(lpDst)^ := $85; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; function test__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $85; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; // test reg32, [reg32] function test__reg32mem32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $85; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // test eax, 12345678h function test__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $A9; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // test reg32, 12345678h function test__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $F7; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // ============================================================================ // mov reg8, reg8 function mov__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $88; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; function mov__reg8__reg8_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $8A; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg2) + (Byte(nReg1) * 8); Result := CODE_SIZE; end; function mov__reg16__reg16(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG16): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // PByte(lpDst)^ := $66; Inc(PByte(lpDst)); // opcode PByte(lpDst)^ := $89; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; function mov__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $89; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; function mov__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $8B; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg2) + (Byte(nReg1) * 8); Result := CODE_SIZE; end; // mov reg32, dword ptr[reg32] function mov__reg32__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $8b; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // mov dword ptr[reg32], reg32 function mov__mem32_reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $89; Inc(PByte(lpDst)); case nReg1 of REG32_EBP: begin PByte(lpDst)^ := $45 + (Byte(nReg2) * 8); Inc(PByte(lpDst)); PByte(lpDst)^ := $00; Inc(PByte(lpDst)); Result := CODE_SIZE + 1; end; REG32_ESP: begin PByte(lpDst)^ := $04 + (Byte(nReg2) * 8); Inc(PByte(lpDst)); PByte(lpDst)^ := $24; Inc(PByte(lpDst)); Result := CODE_SIZE + 1; end; else PByte(lpDst)^ := Byte(nReg1) + (Byte(nReg2) * 8); Inc(PByte(lpDst)); Result := CODE_SIZE; end; end; // mov reg32, 12345678h function mov__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $B8 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // mov reg32, dword ptr [reg32+8] function mov__reg32__mem32_reg32_Idx8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32; nIdx8: VX_IDX8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $8b; Inc(PByte(lpDst)); PByte(lpDst)^ := $40 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); if (nReg2 = REG32_ESP) then begin PByte(lpDst)^ := $24; Inc(PByte(lpDst)); Result := CODE_SIZE + 1; end else begin Result := CODE_SIZE; end; PByte(lpDst)^ := nIdx8; end; // ============================================================================ // mov reg, imm8 function mov__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $B0 + Byte(nReg); Inc(PByte(lpDst)); PUInt8(lpDst)^ := nImm; Result := CODE_SIZE; end; function mov__reg8__imm8_x(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // PByte(lpDst)^ := $C6; Inc(PByte(lpDst)); // opcode PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PUInt8(lpDst)^ := nImm; Result := CODE_SIZE; end; function mov__reg16__imm16(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16; nImm: VX_IMM16): Integer; const CODE_SIZE = 4; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // PByte(lpDst)^ := $66; Inc(PByte(lpDst)); // opcode PByte(lpDst)^ := $B8 + Byte(nReg); Inc(PByte(lpDst)); PUInt16(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // movzx reg, r8/m8 function movzx__reg32__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1: VX_REG32; nReg2: VX_REG8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); // opcode PByte(lpDst)^ := $B6; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Result := CODE_SIZE; end; // ============================================================================ // xchg al, al function xchg__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // PByte(lpDst)^ := $86; Inc(PByte(lpDst)); // opcode PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Result := CODE_SIZE; end; // xchg eax, reg32 function xchg__eax__reg32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32): Integer; const CODE_SIZE = 1; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $90 + Byte(nReg); Result := CODE_SIZE; end; // ============================================================================ // lea reg32, [mem] function lea__reg32__mem32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nMem: VX_MEM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $8D; Inc(PByte(lpDst)); PByte(lpDst)^ := $05 + (Byte(nReg) * 8); Inc(PByte(lpDst)); PUInt32(lpDst)^ := nMem; Result := CODE_SIZE; end; // ============================================================================ // add al, al function add__reg8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $00; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Result := CODE_SIZE; end; function add__reg8__reg8_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $02; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Result := CODE_SIZE; end; // add al, 99h function add__al__imm8(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $04; Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // add al, imm8 function add__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $80; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // add reg32, reg32 function add__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $01; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // add reg32, reg32 function add__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $03; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // add reg32, 99h function add__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // add reg32, [reg32] function add__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $03; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // add eax, 12345678h function add__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $05; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // add reg32, 12345678h function add__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // or reg32, 99h function or__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $C8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // or reg32, reg32 function or__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $09; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // or reg32, reg32 function or__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0b; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // or reg32, [reg32] function or__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0B; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // or eax, 12345678h function or__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $0d; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // or reg32, 12345678h function or__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $C8 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // adc reg32, 99h function adc__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $D0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // adc reg32, reg32 function adc__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $11; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // adc reg32, reg32 function adc__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $13; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // adc reg32, [reg32] function adc__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $13; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // adc eax, 12345678h function adc__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $15; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // adc reg32, 12345678h function adc__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $D0 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // ============================================================================ // sbb reg32, 99h function sbb__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $D8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // sbb reg32, [reg32] function sbb__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $1b; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // sbb eax, 12345678h function sbb__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $1d; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // sbb reg32, reg32 function sbb__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $19; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // sbb reg32, reg32 function sbb__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $1b; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // sbb reg32, 12345678h function sbb__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $D8 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // and reg32, 99h function and__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $E0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // and reg32, [reg32] function and__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $23; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // and eax, 12345678h function and__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $25; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // and reg32, reg32 function and__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $21; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // and reg32, reg32 function and__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $23; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // and reg32, 12345678h function and__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $E0 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // sub reg32, 99h function sub__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $E8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // sub reg32, reg32 function sub__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $29; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // sub reg32, reg32 function sub__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $2b; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // sub reg32, [reg32] function sub__reg32__reg32mem32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $2b; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // sub eax, 12345678h function sub__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $2d; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // sub reg32, 12345678h function sub__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $E8 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // xor reg32, 99h function xor__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $F0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // xor reg32, reg32 function xor__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $31; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg2) * 8) + Byte(nReg1); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // xor reg32, reg32 function xor__reg32__reg32_x(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $33; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // xor reg32, dword ptr [reg32] function xor__reg32__mem32_reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $33; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + (Byte(nReg1) * 8) + Byte(nReg2); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // xor dword ptr[reg32], reg32 function xor__mem32_reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $31; Inc(PByte(lpDst)); case nReg1 of REG32_ESP: begin PByte(lpDst)^ := $04 + (Byte(nReg2) * 8); Inc(PByte(lpDst)); PByte(lpDst)^ := $24; Result := CODE_SIZE + 1; end; REG32_EBP: begin PByte(lpDst)^ := $45 + (Byte(nReg2) * 8); Inc(PByte(lpDst)); PByte(lpDst)^ := $00; Result := CODE_SIZE + 1; end; else PByte(lpDst)^ := $00 + (Byte(nReg2) * 8) + Byte(nReg1); Result := CODE_SIZE; end; end; // xor eax, 12345678h function xor__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $35; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // xor reg32, 12345678h function xor__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $F0 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // cmp reg32, 99h function cmp__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $83; Inc(PByte(lpDst)); PByte(lpDst)^ := $F8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // cmp eax, 12345678h function cmp__eax__imm32(lpDst: Pointer; nSize: SIZE_T; nImm: VX_IMM32): Integer; const CODE_SIZE = 5; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; {$endif} // opcode PByte(lpDst)^ := $3D; Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // cmp reg32, 12345678h function cmp__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $81; Inc(PByte(lpDst)); PByte(lpDst)^ := $F8 + Byte(nReg); Inc(PByte(lpDst)); PLongWord(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ function imul__reg32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $AF; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; function imul__reg32__reg32__imm32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32; nImm: VX_IMM32): Integer; const CODE_SIZE = 6; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $69; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg2) + (Byte(nReg1) * 8); Inc(PByte(lpDst)); PUInt32(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // rol reg8, 1 function rol__reg8__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $D0; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg8, cl function rol__reg8__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $D2; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg8, imm8 function rol__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C0; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // rol reg16, 1 function rol__reg16__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $66; Inc(PByte(lpDst)); PByte(lpDst)^ := $D1; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg16, cl function rol__reg16__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $66; Inc(PByte(lpDst)); PByte(lpDst)^ := $D3; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg16, imm8 function rol__reg16__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG16; nImm: VX_IMM8): Integer; const CODE_SIZE = 4; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $66; Inc(PByte(lpDst)); PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // rol reg32, 1 function rol__reg32__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $D1; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg32, cl function rol__reg32__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $D3; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg32, imm8 function rol__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // rol reg32mem32, 1 function rol__reg32mem32__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $D1; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg32mem32, cl function rol__reg32mem32__cl(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $D3; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // rol reg32mem32, imm8 function rol__reg32mem32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // ror reg8, 1 function ror__reg8__1(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8): Integer; const CODE_SIZE = 2; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $D0; Inc(PByte(lpDst)); PByte(lpDst)^ := $C8 + Byte(nReg); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // ror reg8, imm8 function ror__reg8__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG8; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C0; Inc(PByte(lpDst)); PByte(lpDst)^ := $C8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ror reg32, imm8 function ror__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $C8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // rcl reg32, imm8 function rcl__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $D0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // rcr reg32, imm8 function rcr__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $D8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // shl reg32, imm8 function shl__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $E0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // shr reg32, imm8 function shr__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $E8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // shl reg32, imm8 function shl__reg32__imm8_x(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $F0 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // sar reg32, imm8 function sar__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $C1; Inc(PByte(lpDst)); PByte(lpDst)^ := $F8 + Byte(nReg); Inc(PByte(lpDst)); PByte(lpDst)^ := Byte(nImm); Result := CODE_SIZE; end; // ============================================================================ // shld reg32, reg32, cl function shld__reg32__reg32__cl(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $A5; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // shld reg32, reg32, imm8 function shld__reg32__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 4; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $A4; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0 + Byte(nReg1) + (Byte(nReg2) * 8); Inc(PByte(lpDst)); PUInt8(lpDst)^ := nImm; Result := CODE_SIZE; end; // ============================================================================ // xadd reg32mem8, reg8 function xadd__reg32mem8__reg8(lpDst: Pointer; nSize: SIZE_T; nReg1: VX_REG32; nReg2: VX_REG8): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $C0; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + Byte(nReg1) + (Byte(nReg2) * 8); Inc(PByte(lpDst)); Result := CODE_SIZE; end; // ============================================================================ // bsf reg32, reg32mem32 function bsf__reg32mem32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $BC; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + Byte(nReg2) + (Byte(nReg1) * 8); Result := CODE_SIZE; end; // ============================================================================ // bt reg32, imm8 function bt__reg32__imm8(lpDst: Pointer; nSize: SIZE_T; nReg: VX_REG32; nImm: VX_IMM8): Integer; const CODE_SIZE = 4; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg in [Low(nReg)..High(nReg)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $BA; Inc(PByte(lpDst)); PByte(lpDst)^ := $E0 + Byte(nReg); Inc(PByte(lpDst)); PUInt8(lpDst)^ := nImm; Result := CODE_SIZE; end; // bt reg32mem32, reg32 function bt__reg32mem32__reg32(lpDst: Pointer; nSize: SIZE_T; nReg1, nReg2: VX_REG32): Integer; const CODE_SIZE = 3; begin {$ifndef VXL_INLINE_MODE} Result := 0; if ((lpDst = nil) or (nSize < CODE_SIZE)) then Exit; if (Not Vx_IsWritePtr(lpDst, nSize)) then Exit; if Not (nReg1 in [Low(nReg1)..High(nReg1)]) then Exit; if Not (nReg2 in [Low(nReg2)..High(nReg2)]) then Exit; {$endif} // opcode PByte(lpDst)^ := $0F; Inc(PByte(lpDst)); PByte(lpDst)^ := $A3; Inc(PByte(lpDst)); PByte(lpDst)^ := $00 + Byte(nReg1) + (Byte(nReg2) * 8); Result := CODE_SIZE; end; // ============================================================================ {$WARNINGS OFF} {$ifndef VXL_INLINE_MODE} end. {$endif} {$WARNINGS ON}