def __init__(self, *args, **kwargs): """Supported forms: * AESKEYGENASSIST(xmm, xmm/m128, imm8) [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(AESKEYGENASSIST, self).__init__("AESKEYGENASSIST", origin=origin, prototype=prototype) self.operands = tuple(map(check_operand, args)) if len(self.operands) != 3: raise SyntaxError( "Instruction \"AESKEYGENASSIST\" requires 3 operands") self.go_name = "AESKEYGENASSIST" self.in_regs = (False, True, False) self.out_regs = (True, False, False) self.out_operands = (True, False, False) self.avx_mode = False self.isa_extensions = frozenset([peachpy.x86_64.isa.aes]) if is_xmm(self.operands[0]) and is_xmm(self.operands[1]) and is_imm( self.operands[2]): if not is_imm8(self.operands[2]): raise ValueError("Argument #2 can not be encoded as imm8") self.encodings.append((0x20, lambda op, rex=False: bytearray( [0x66]) + optional_rex(op[0].hcode, op[1], rex) + bytearray([ 0x0F, 0x3A, 0xDF, 0xC0 | op[0].lcode << 3 | op[1].lcode, op[2] & 0xFF ]))) elif is_xmm(self.operands[0]) and is_m128(self.operands[1]) and is_imm( self.operands[2]): if not is_imm8(self.operands[2]): raise ValueError("Argument #2 can not be encoded as imm8") self.encodings.append( (0x30, lambda op, rex=False, sib=False, min_disp=0: bytearray( [0x66]) + optional_rex(op[0].hcode, op[1].address, rex) + bytearray([0x0F, 0x3A, 0xDF]) + modrm_sib_disp( op[0].lcode, op[1].address, sib, min_disp) + bytearray( [op[2] & 0xFF]))) else: raise SyntaxError( "Invalid operand types: AESKEYGENASSIST " + ", ".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: * 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)
def __init__(self, *args, **kwargs): """Supported forms: * SHA256RNDS2(xmm, xmm/m128, xmm0) [SHA] """ 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(SHA256RNDS2, self).__init__("SHA256RNDS2", origin=origin, prototype=prototype) self.operands = tuple(map(check_operand, args)) if len(self.operands) != 3: raise SyntaxError( "Instruction \"SHA256RNDS2\" requires 3 operands") self.in_regs = (True, True, True) self.out_regs = (True, False, False) self.out_operands = (True, False, False) self.avx_mode = False self.isa_extensions = frozenset([peachpy.x86_64.isa.sha]) if is_xmm(self.operands[0]) and is_xmm(self.operands[1]) and is_xmm0( self.operands[2]): self.encodings.append((0x20, lambda op, rex=False: optional_rex( op[0].hcode, op[1], rex) + bytearray( [0x0F, 0x38, 0xCB, 0xC0 | op[0].lcode << 3 | op[1].lcode]) )) elif is_xmm(self.operands[0]) and is_m128( self.operands[1]) and is_xmm0(self.operands[2]): self.encodings.append( (0x30, lambda op, rex=False, sib=False, min_disp=0: optional_rex(op[0].hcode, op[1].address, rex) + bytearray( [0x0F, 0x38, 0xCB]) + modrm_sib_disp( op[0].lcode, op[1].address, sib, min_disp))) else: raise SyntaxError( "Invalid operand types: SHA256RNDS2 " + ", ".join(map(format_operand_type, self.operands))) if peachpy.stream.active_stream is not None: peachpy.stream.active_stream.add_instruction(self)