def __init__(self, *args, **kwargs): """Supported forms: * VPCLMULQDQ(xmm, xmm, xmm/m128, imm8) [AVX and PCLMULQDQ] """ origin = kwargs.get("origin") prototype = kwargs.get("prototype") if origin is None and prototype is None and peachpy.x86_64.options.get_debug_level( ) > 0: origin = inspect.stack() super(VPCLMULQDQ, self).__init__("VPCLMULQDQ", origin=origin, prototype=prototype) self.operands = tuple(map(check_operand, args)) if len(self.operands) != 4: raise SyntaxError("Instruction \"VPCLMULQDQ\" requires 4 operands") self.in_regs = (False, True, True, False) self.out_regs = (True, False, False, False) self.out_operands = (True, False, False, False) self.avx_mode = True self.isa_extensions = frozenset( [peachpy.x86_64.isa.avx, peachpy.x86_64.isa.pclmulqdq]) if is_xmm(self.operands[0]) and is_xmm(self.operands[1]) and is_xmm( self.operands[2]) and is_imm(self.operands[3]): if not is_imm8(self.operands[3]): raise ValueError("Argument #3 can not be encoded as imm8") self.encodings.append((0x00, lambda op: bytearray([ 0xC4, 0xE3 ^ (op[0].hcode << 7) ^ (op[2].hcode << 5), 0x79 ^ (op[1].hlcode << 3), 0x44, 0xC0 | op[0].lcode << 3 | op[ 2].lcode, op[3] & 0xFF ]))) elif is_xmm(self.operands[0]) and is_xmm(self.operands[1]) and is_m128( self.operands[2]) and is_imm(self.operands[3]): if not is_imm8(self.operands[3]): raise ValueError("Argument #3 can not be encoded as imm8") self.encodings.append( (0x10, lambda op, sib=False, min_disp=0: vex3( 0xC4, 0b11, 0x01, op[0].hcode, op[2].address, op[1].hlcode) + bytearray([0x44]) + modrm_sib_disp(op[0].lcode, op[ 2].address, sib, min_disp) + bytearray([op[3] & 0xFF]))) else: raise SyntaxError( "Invalid operand types: VPCLMULQDQ " + ", ".join(map(format_operand_type, self.operands))) if peachpy.stream.active_stream is not None: peachpy.stream.active_stream.add_instruction(self)
def __init__(self, *args, **kwargs): """Supported forms: * VAESENCLAST(xmm, xmm, xmm/m128) [AVX and AES] """ origin = kwargs.get("origin") prototype = kwargs.get("prototype") if origin is None and prototype is None and peachpy.x86_64.options.get_debug_level( ) > 0: origin = inspect.stack() super(VAESENCLAST, self).__init__("VAESENCLAST", origin=origin, prototype=prototype) self.operands = tuple(map(check_operand, args)) if len(self.operands) != 3: raise SyntaxError( "Instruction \"VAESENCLAST\" requires 3 operands") self.in_regs = (False, True, True) self.out_regs = (True, False, False) self.out_operands = (True, False, False) self.avx_mode = True self.isa_extensions = frozenset( [peachpy.x86_64.isa.avx, peachpy.x86_64.isa.aes]) if is_xmm(self.operands[0]) and is_xmm(self.operands[1]) and is_xmm( self.operands[2]): self.encodings.append((0x00, lambda op: bytearray([ 0xC4, 0xE2 ^ (op[0].hcode << 7) ^ (op[2].hcode << 5), 0x79 ^ (op[1].hlcode << 3), 0xDD, 0xC0 | op[0].lcode << 3 | op[2 ].lcode ]))) elif is_xmm(self.operands[0]) and is_xmm(self.operands[1]) and is_m128( self.operands[2]): self.encodings.append(( 0x10, lambda op, sib=False, min_disp=0: vex3(0xC4, 0b10, 0x01, op[ 0].hcode, op[2].address, op[1].hlcode) + bytearray([0xDD]) + modrm_sib_disp(op[0].lcode, op[2].address, sib, min_disp))) else: raise SyntaxError( "Invalid operand types: VAESENCLAST " + ", ".join(map(format_operand_type, self.operands))) if peachpy.stream.active_stream is not None: peachpy.stream.active_stream.add_instruction(self)