Instruction

class iced_x86.Instruction

A 16/32/64-bit x86 instruction. Created by Decoder or by Instruction.create*() methods.

Examples:

A decoder is usually used to create instructions:

from iced_x86 import *

# xchg ah,[rdx+rsi+16h]
data = b"\x86\x64\x32\x16"
decoder = Decoder(64, data, ip=0x1234_5678)

instr = decoder.decode()

# Instruction supports __bool__() and returns True if it's
# a valid instruction:
if not instr:
    print("Invalid instruction (garbage, data, etc)")
# The above code is the same as:
if instr.code == Code.INVALID:
    print("Not an instruction")

But there are also static Instruction.create*() methods that can be used to create instructions:

nop = Instruction.create(Code.NOPD)
xor = Instruction.create_reg_i32(Code.XOR_RM64_IMM8, Register.R14, -1)
rep_stosd = Instruction.create_rep_stosd(64)
add = Instruction.create_mem_i32(Code.ADD_RM64_IMM8, MemoryOperand(Register.RCX, Register.RDX, 8, 0x1234_5678), 2)
print(f"{nop}")
print(f"{xor}")
print(f"{rep_stosd}")
print(f"{add}")

Output:

nop
xor r14,0FFFFFFFFFFFFFFFFh
rep stosd
add qword ptr [rcx+rdx*8+12345678h],2

Once you have an instruction you can format it either by using a Formatter or by calling the instruction’s __repr__(), __str__() or __format__() methods.

# Continued from the above example

formatter = Formatter(FormatterSyntax.INTEL)

# Change some options
formatter.uppercase_mnemonics = True
formatter.space_after_operand_separator = True
formatter.first_operand_char_index = 8

print(f"disasm  : {formatter.format(instr)}")
# `instr.mnemonic` also returns a `Mnemonic` enum
print(f"mnemonic: {formatter.format_mnemonic(instr, FormatMnemonicOptions.NO_PREFIXES)}")
print(f"operands: {formatter.format_all_operands(instr)}")
# `instr.op0_kind`/etc return operand kind, see also `instr.op0_register`, etc to get reg/mem info
print(f"op #0   : {formatter.format_operand(instr, 0)}")
print(f"op #1   : {formatter.format_operand(instr, 1)}")
print(f"reg RCX : {formatter.format_register(Register.RCX)}")

Output:

disasm  : XCHG    [rdx+rsi+16h], ah
mnemonic: XCHG
operands: [rdx+rsi+16h], ah
op #0   : [rdx+rsi+16h]
op #1   : ah
reg RCX : rcx
# A formatter isn't needed if you like most of the default options.
# repr() == str() == format() all return the same thing.
print(f"disasm  : {repr(instr)}")
print(f"disasm  : {str(instr)}")
print(f"disasm  : {instr}")

Output:

disasm  : xchg ah,[rdx+rsi+16h]
disasm  : xchg ah,[rdx+rsi+16h]
disasm  : xchg ah,[rdx+rsi+16h]
# __format__() supports a format spec argument, see the table below
print(f"disasm  : {instr:f}")
print(f"disasm  : {instr:g}")
print(f"disasm  : {instr:i}")
print(f"disasm  : {instr:m}")
print(f"disasm  : {instr:n}")
print(f"disasm  : {instr:gxsSG}")

Output:

disasm  : xchg [rdx+rsi+16h],ah
disasm  : xchg %ah,0x16(%rdx,%rsi)
disasm  : xchg [rdx+rsi+16h],ah
disasm  : xchg ah,[rdx+rsi+16h]
disasm  : xchg ah,[rdx+rsi+16h]
disasm  : xchgb %ah, %ds:0x16(%rdx,%rsi)

The following format specifiers are supported in any order. If you omit the formatter kind, the default formatter is used (eg. masm):

F-Spec

Description

f

Fast formatter (masm-like syntax)

g

GNU Assembler formatter

i

Intel (XED) formatter

m

masm formatter

n

nasm formatter

X

Uppercase hex numbers with 0x prefix

x

Lowercase hex numbers with 0x prefix

H

Uppercase hex numbers with h suffix

h

Lowercase hex numbers with h suffix

r

RIP-relative memory operands use RIP register instead of abs addr ([rip+123h] vs [123456789ABCDEF0h])

U

Uppercase everything except numbers and hex prefixes/suffixes (ignored by fast fmt)

s

Add a space after the operand separator

S

Always show the segment register (memory operands)

B

Don’t show the branch size (SHORT or NEAR PTR) (ignored by fast fmt)

G

(GNU Assembler): Add mnemonic size suffix (eg. movl vs mov)

M

Always show the memory size (eg. BYTE PTR) even when not needed

_

Use digit separators (eg. 0x12345678 vs 0x1234_5678) (ignored by fast fmt)

as_near_branch()

Converts Jcc/JMP SHORT to Jcc/JMP NEAR and does nothing if it’s not a Jcc/JMP SHORT instruction

Examples:

from iced_x86 import *

# jbe short label
data = b"\x76\x5A"
decoder = Decoder(64, data)

instr = decoder.decode()
assert instr.code == Code.JBE_REL8_64
instr.as_near_branch()
assert instr.code == Code.JBE_REL32_64
instr.as_near_branch()
assert instr.code == Code.JBE_REL32_64
as_short_branch()

Converts Jcc/JMP NEAR to Jcc/JMP SHORT and does nothing if it’s not a Jcc/JMP NEAR instruction

Examples:

from iced_x86 import *

# jbe near ptr label
data = b"\x0F\x86\x5A\xA5\x12\x34"
decoder = Decoder(64, data)

instr = decoder.decode()
assert instr.code == Code.JBE_REL32_64
instr.as_short_branch()
assert instr.code == Code.JBE_REL8_64
instr.as_short_branch()
assert instr.code == Code.JBE_REL8_64
code

Gets the instruction code (a Code enum value), see also Instruction.mnemonic

Type:

Code

code_size

Gets the code size (a CodeSize enum value) when the instruction was decoded.

Note

This value is informational and can be used by a formatter.

Type:

CodeSize

condition_code

Gets the condition code (a ConditionCode enum value) if it’s Jcc, SETcc, CMOVcc, CMPccXADD, LOOPcc else ConditionCode.NONE is returned

Examples:

from iced_x86 import *

# setbe al
# jl short label
# cmovne ecx,esi
# nop
data = b"\x0F\x96\xC0\x7C\x5A\x0F\x45\xCE\x90"
decoder = Decoder(64, data)

# setbe al
instr = decoder.decode()
assert instr.condition_code == ConditionCode.BE

# jl short label
instr = decoder.decode()
assert instr.condition_code == ConditionCode.L

# cmovne ecx,esi
instr = decoder.decode()
assert instr.condition_code == ConditionCode.NE

# nop
instr = decoder.decode()
assert instr.condition_code == ConditionCode.NONE
Type:

ConditionCode

copy()

Returns a copy of this instance.

Returns:

A copy of this instance

Return type:

Instruction

cpuid_features()

Gets the CPU or CPUID feature flags (a list of CpuidFeature enum values)

Returns:

CPU or CPUID feature flags

Return type:

List[CpuidFeature]

Examples:

from iced_x86 import *

# vmovaps xmm1,xmm5
# vmovaps xmm10{k3}{z},xmm19
data = b"\xC5\xF8\x28\xCD\x62\x31\x7C\x8B\x28\xD3"
decoder = Decoder(64, data)

# vmovaps xmm1,xmm5
instr = decoder.decode()
cpuid = instr.cpuid_features()
assert len(cpuid) == 1
assert cpuid[0] == CpuidFeature.AVX

# vmovaps xmm10{k3}{z},xmm19
instr = decoder.decode()
cpuid = instr.cpuid_features()
assert len(cpuid) == 2
assert cpuid[0] == CpuidFeature.AVX512VL
assert cpuid[1] == CpuidFeature.AVX512F
static create(code)

Creates an instruction with no operands

Parameters:

code (Code) – Code value

Returns:

Created instruction

Return type:

Instruction

static create_branch(code, target)

Creates a new near/short branch instruction

Parameters:
  • code (Code) – Code value

  • target (int) – (u64) Target address

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If the created instruction doesn’t have a near branch operand

static create_cmpsb(address_size, segment_prefix=0, rep_prefix=0)

Creates a CMPSB instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_cmpsd(address_size, segment_prefix=0, rep_prefix=0)

Creates a CMPSD instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_cmpsq(address_size, segment_prefix=0, rep_prefix=0)

Creates a CMPSQ instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_cmpsw(address_size, segment_prefix=0, rep_prefix=0)

Creates a CMPSW instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_declare_byte(data)

Creates a db/.byte asm directive

Parameters:

data (bytes, bytearray) – Data

Returns:

Created instruction

Return type:

Instruction

Raises:
static create_declare_byte_1(b0)

Creates a db/.byte asm directive

Parameters:

b0 (int) – (u8) Byte 0

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_10(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

  • b9 (int) – (u8) Byte 9

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_11(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

  • b9 (int) – (u8) Byte 9

  • b10 (int) – (u8) Byte 10

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_12(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

  • b9 (int) – (u8) Byte 9

  • b10 (int) – (u8) Byte 10

  • b11 (int) – (u8) Byte 11

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_13(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

  • b9 (int) – (u8) Byte 9

  • b10 (int) – (u8) Byte 10

  • b11 (int) – (u8) Byte 11

  • b12 (int) – (u8) Byte 12

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_14(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

  • b9 (int) – (u8) Byte 9

  • b10 (int) – (u8) Byte 10

  • b11 (int) – (u8) Byte 11

  • b12 (int) – (u8) Byte 12

  • b13 (int) – (u8) Byte 13

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_15(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

  • b9 (int) – (u8) Byte 9

  • b10 (int) – (u8) Byte 10

  • b11 (int) – (u8) Byte 11

  • b12 (int) – (u8) Byte 12

  • b13 (int) – (u8) Byte 13

  • b14 (int) – (u8) Byte 14

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_16(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

  • b9 (int) – (u8) Byte 9

  • b10 (int) – (u8) Byte 10

  • b11 (int) – (u8) Byte 11

  • b12 (int) – (u8) Byte 12

  • b13 (int) – (u8) Byte 13

  • b14 (int) – (u8) Byte 14

  • b15 (int) – (u8) Byte 15

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_2(b0, b1)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_3(b0, b1, b2)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_4(b0, b1, b2, b3)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_5(b0, b1, b2, b3, b4)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_6(b0, b1, b2, b3, b4, b5)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_7(b0, b1, b2, b3, b4, b5, b6)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_8(b0, b1, b2, b3, b4, b5, b6, b7)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

Returns:

Created instruction

Return type:

Instruction

static create_declare_byte_9(b0, b1, b2, b3, b4, b5, b6, b7, b8)

Creates a db/.byte asm directive

Parameters:
  • b0 (int) – (u8) Byte 0

  • b1 (int) – (u8) Byte 1

  • b2 (int) – (u8) Byte 2

  • b3 (int) – (u8) Byte 3

  • b4 (int) – (u8) Byte 4

  • b5 (int) – (u8) Byte 5

  • b6 (int) – (u8) Byte 6

  • b7 (int) – (u8) Byte 7

  • b8 (int) – (u8) Byte 8

Returns:

Created instruction

Return type:

Instruction

static create_declare_dword_1(d0)

Creates a dd/.int asm directive

Parameters:

d0 (int) – (u32) Dword 0

Returns:

Created instruction

Return type:

Instruction

static create_declare_dword_2(d0, d1)

Creates a dd/.int asm directive

Parameters:
  • d0 (int) – (u32) Dword 0

  • d1 (int) – (u32) Dword 1

Returns:

Created instruction

Return type:

Instruction

static create_declare_dword_3(d0, d1, d2)

Creates a dd/.int asm directive

Parameters:
  • d0 (int) – (u32) Dword 0

  • d1 (int) – (u32) Dword 1

  • d2 (int) – (u32) Dword 2

Returns:

Created instruction

Return type:

Instruction

static create_declare_dword_4(d0, d1, d2, d3)

Creates a dd/.int asm directive

Parameters:
  • d0 (int) – (u32) Dword 0

  • d1 (int) – (u32) Dword 1

  • d2 (int) – (u32) Dword 2

  • d3 (int) – (u32) Dword 3

Returns:

Created instruction

Return type:

Instruction

static create_declare_qword_1(q0)

Creates a dq/.quad asm directive

Parameters:

q0 (int) – (u64) Qword 0

Returns:

Created instruction

Return type:

Instruction

static create_declare_qword_2(q0, q1)

Creates a dq/.quad asm directive

Parameters:
  • q0 (int) – (u64) Qword 0

  • q1 (int) – (u64) Qword 1

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_1(w0)

Creates a dw/.word asm directive

Parameters:

w0 (int) – (u16) Word 0

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_2(w0, w1)

Creates a dw/.word asm directive

Parameters:
  • w0 (int) – (u16) Word 0

  • w1 (int) – (u16) Word 1

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_3(w0, w1, w2)

Creates a dw/.word asm directive

Parameters:
  • w0 (int) – (u16) Word 0

  • w1 (int) – (u16) Word 1

  • w2 (int) – (u16) Word 2

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_4(w0, w1, w2, w3)

Creates a dw/.word asm directive

Parameters:
  • w0 (int) – (u16) Word 0

  • w1 (int) – (u16) Word 1

  • w2 (int) – (u16) Word 2

  • w3 (int) – (u16) Word 3

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_5(w0, w1, w2, w3, w4)

Creates a dw/.word asm directive

Parameters:
  • w0 (int) – (u16) Word 0

  • w1 (int) – (u16) Word 1

  • w2 (int) – (u16) Word 2

  • w3 (int) – (u16) Word 3

  • w4 (int) – (u16) Word 4

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_6(w0, w1, w2, w3, w4, w5)

Creates a dw/.word asm directive

Parameters:
  • w0 (int) – (u16) Word 0

  • w1 (int) – (u16) Word 1

  • w2 (int) – (u16) Word 2

  • w3 (int) – (u16) Word 3

  • w4 (int) – (u16) Word 4

  • w5 (int) – (u16) Word 5

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_7(w0, w1, w2, w3, w4, w5, w6)

Creates a dw/.word asm directive

Parameters:
  • w0 (int) – (u16) Word 0

  • w1 (int) – (u16) Word 1

  • w2 (int) – (u16) Word 2

  • w3 (int) – (u16) Word 3

  • w4 (int) – (u16) Word 4

  • w5 (int) – (u16) Word 5

  • w6 (int) – (u16) Word 6

Returns:

Created instruction

Return type:

Instruction

static create_declare_word_8(w0, w1, w2, w3, w4, w5, w6, w7)

Creates a dw/.word asm directive

Parameters:
  • w0 (int) – (u16) Word 0

  • w1 (int) – (u16) Word 1

  • w2 (int) – (u16) Word 2

  • w3 (int) – (u16) Word 3

  • w4 (int) – (u16) Word 4

  • w5 (int) – (u16) Word 5

  • w6 (int) – (u16) Word 6

  • w7 (int) – (u16) Word 7

Returns:

Created instruction

Return type:

Instruction

static create_far_branch(code, selector, offset)

Creates a new far branch instruction

Parameters:
  • code (Code) – Code value

  • selector (int) – (u16) Selector/segment value

  • offset (int) – (u32) Offset

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If the created instruction doesn’t have a far branch operand

static create_i32(code, immediate)

Creates an instruction with 1 operand

Parameters:
  • code (Code) – Code value

  • immediate (int) – (i32) op0: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_i32_i32(code, immediate1, immediate2)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • immediate1 (int) – (i32) op0: Immediate value

  • immediate2 (int) – (i32) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_i32_reg(code, immediate, register)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • immediate (int) – (i32) op0: Immediate value

  • register (Register) – op1: Register

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_insb(address_size, rep_prefix=0)

Creates a INSB instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_insd(address_size, rep_prefix=0)

Creates a INSD instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_insw(address_size, rep_prefix=0)

Creates a INSW instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_lodsb(address_size, segment_prefix=0, rep_prefix=0)

Creates a LODSB instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_lodsd(address_size, segment_prefix=0, rep_prefix=0)

Creates a LODSD instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_lodsq(address_size, segment_prefix=0, rep_prefix=0)

Creates a LODSQ instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_lodsw(address_size, segment_prefix=0, rep_prefix=0)

Creates a LODSW instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_maskmovdqu(address_size, register1, register2, segment_prefix=0)

Creates a MASKMOVDQU instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_maskmovq(address_size, register1, register2, segment_prefix=0)

Creates a MASKMOVQ instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_mem(code, memory)

Creates an instruction with 1 operand

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_mem_i32(code, memory, immediate)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • memory (MemoryOperand) – op0: Memory operand

  • immediate (int) – (i32) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_mem_reg(code, memory, register)

Creates an instruction with 2 operands

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_mem_reg_i32(code, memory, register, immediate)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • memory (MemoryOperand) – op0: Memory operand

  • register (Register) – op1: Register

  • immediate (int) – (i32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_mem_reg_reg(code, memory, register1, register2)

Creates an instruction with 3 operands

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_mem_reg_u32(code, memory, register, immediate)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • memory (MemoryOperand) – op0: Memory operand

  • register (Register) – op1: Register

  • immediate (int) – (u32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_mem_u32(code, memory, immediate)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • memory (MemoryOperand) – op0: Memory operand

  • immediate (int) – (u32) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_movsb(address_size, segment_prefix=0, rep_prefix=0)

Creates a MOVSB instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_movsd(address_size, segment_prefix=0, rep_prefix=0)

Creates a MOVSD instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_movsq(address_size, segment_prefix=0, rep_prefix=0)

Creates a MOVSQ instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_movsw(address_size, segment_prefix=0, rep_prefix=0)

Creates a MOVSW instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_outsb(address_size, segment_prefix=0, rep_prefix=0)

Creates a OUTSB instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_outsd(address_size, segment_prefix=0, rep_prefix=0)

Creates a OUTSD instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_outsw(address_size, segment_prefix=0, rep_prefix=0)

Creates a OUTSW instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_reg(code, register)

Creates an instruction with 1 operand

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_i32(code, register, immediate)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • immediate (int) – (i32) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_i32_i32(code, register, immediate1, immediate2)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • immediate1 (int) – (i32) op1: Immediate value

  • immediate2 (int) – (i32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_i64(code, register, immediate)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • immediate (int) – (i64) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_mem(code, register, memory)

Creates an instruction with 2 operands

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_mem_i32(code, register, memory, immediate)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • memory (MemoryOperand) – op1: Memory operand

  • immediate (int) – (i32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_mem_reg(code, register1, memory, register2)

Creates an instruction with 3 operands

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_mem_u32(code, register, memory, immediate)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • memory (MemoryOperand) – op1: Memory operand

  • immediate (int) – (u32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg(code, register1, register2)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_i32(code, register1, register2, immediate)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • immediate (int) – (i32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_i32_i32(code, register1, register2, immediate1, immediate2)

Creates an instruction with 4 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • immediate1 (int) – (i32) op2: Immediate value

  • immediate2 (int) – (i32) op3: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_mem(code, register1, register2, memory)

Creates an instruction with 3 operands

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_mem_i32(code, register1, register2, memory, immediate)

Creates an instruction with 4 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • memory (MemoryOperand) – op2: Memory operand

  • immediate (int) – (i32) op3: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_mem_reg(code, register1, register2, memory, register3)

Creates an instruction with 4 operands

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_mem_reg_i32(code, register1, register2, memory, register3, immediate)

Creates an instruction with 5 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • memory (MemoryOperand) – op2: Memory operand

  • register3 (Register) – op3: Register

  • immediate (int) – (i32) op4: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_mem_reg_u32(code, register1, register2, memory, register3, immediate)

Creates an instruction with 5 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • memory (MemoryOperand) – op2: Memory operand

  • register3 (Register) – op3: Register

  • immediate (int) – (u32) op4: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_mem_u32(code, register1, register2, memory, immediate)

Creates an instruction with 4 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • memory (MemoryOperand) – op2: Memory operand

  • immediate (int) – (u32) op3: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg(code, register1, register2, register3)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_i32(code, register1, register2, register3, immediate)

Creates an instruction with 4 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

  • immediate (int) – (i32) op3: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_mem(code, register1, register2, register3, memory)

Creates an instruction with 4 operands

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_mem_i32(code, register1, register2, register3, memory, immediate)

Creates an instruction with 5 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

  • memory (MemoryOperand) – op3: Memory operand

  • immediate (int) – (i32) op4: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_mem_u32(code, register1, register2, register3, memory, immediate)

Creates an instruction with 5 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

  • memory (MemoryOperand) – op3: Memory operand

  • immediate (int) – (u32) op4: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_reg(code, register1, register2, register3, register4)

Creates an instruction with 4 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

  • register4 (Register) – op3: Register

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_reg_i32(code, register1, register2, register3, register4, immediate)

Creates an instruction with 5 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

  • register4 (Register) – op3: Register

  • immediate (int) – (i32) op4: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_reg_u32(code, register1, register2, register3, register4, immediate)

Creates an instruction with 5 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

  • register4 (Register) – op3: Register

  • immediate (int) – (u32) op4: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_reg_u32(code, register1, register2, register3, immediate)

Creates an instruction with 4 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • register3 (Register) – op2: Register

  • immediate (int) – (u32) op3: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_u32(code, register1, register2, immediate)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • immediate (int) – (u32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_reg_u32_u32(code, register1, register2, immediate1, immediate2)

Creates an instruction with 4 operands

Parameters:
  • code (Code) – Code value

  • register1 (Register) – op0: Register

  • register2 (Register) – op1: Register

  • immediate1 (int) – (u32) op2: Immediate value

  • immediate2 (int) – (u32) op3: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_u32(code, register, immediate)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • immediate (int) – (u32) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_u32_u32(code, register, immediate1, immediate2)

Creates an instruction with 3 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • immediate1 (int) – (u32) op1: Immediate value

  • immediate2 (int) – (u32) op2: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_reg_u64(code, register, immediate)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • register (Register) – op0: Register

  • immediate (int) – (u64) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_rep_insb(address_size)

Creates a REP INSB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_insd(address_size)

Creates a REP INSD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_insw(address_size)

Creates a REP INSW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_lodsb(address_size)

Creates a REP LODSB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_lodsd(address_size)

Creates a REP LODSD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_lodsq(address_size)

Creates a REP LODSQ instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_lodsw(address_size)

Creates a REP LODSW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_movsb(address_size)

Creates a REP MOVSB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_movsd(address_size)

Creates a REP MOVSD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_movsq(address_size)

Creates a REP MOVSQ instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_movsw(address_size)

Creates a REP MOVSW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_outsb(address_size)

Creates a REP OUTSB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_outsd(address_size)

Creates a REP OUTSD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_outsw(address_size)

Creates a REP OUTSW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_stosb(address_size)

Creates a REP STOSB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_stosd(address_size)

Creates a REP STOSD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_stosq(address_size)

Creates a REP STOSQ instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_rep_stosw(address_size)

Creates a REP STOSW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_cmpsb(address_size)

Creates a REPE CMPSB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_cmpsd(address_size)

Creates a REPE CMPSD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_cmpsq(address_size)

Creates a REPE CMPSQ instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_cmpsw(address_size)

Creates a REPE CMPSW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_scasb(address_size)

Creates a REPE SCASB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_scasd(address_size)

Creates a REPE SCASD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_scasq(address_size)

Creates a REPE SCASQ instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repe_scasw(address_size)

Creates a REPE SCASW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_cmpsb(address_size)

Creates a REPNE CMPSB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_cmpsd(address_size)

Creates a REPNE CMPSD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_cmpsq(address_size)

Creates a REPNE CMPSQ instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_cmpsw(address_size)

Creates a REPNE CMPSW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_scasb(address_size)

Creates a REPNE SCASB instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_scasd(address_size)

Creates a REPNE SCASD instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_scasq(address_size)

Creates a REPNE SCASQ instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_repne_scasw(address_size)

Creates a REPNE SCASW instruction

Parameters:

address_size (int) – (u32) 16, 32, or 64

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_scasb(address_size, rep_prefix=0)

Creates a SCASB instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_scasd(address_size, rep_prefix=0)

Creates a SCASD instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_scasq(address_size, rep_prefix=0)

Creates a SCASQ instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_scasw(address_size, rep_prefix=0)

Creates a SCASW instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_stosb(address_size, rep_prefix=0)

Creates a STOSB instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_stosd(address_size, rep_prefix=0)

Creates a STOSD instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_stosq(address_size, rep_prefix=0)

Creates a STOSQ instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_stosw(address_size, rep_prefix=0)

Creates a STOSW instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_u32(code, immediate)

Creates an instruction with 1 operand

Parameters:
  • code (Code) – Code value

  • immediate (int) – (u32) op0: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_u32_reg(code, immediate, register)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • immediate (int) – (u32) op0: Immediate value

  • register (Register) – op1: Register

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_u32_u32(code, immediate1, immediate2)

Creates an instruction with 2 operands

Parameters:
  • code (Code) – Code value

  • immediate1 (int) – (u32) op0: Immediate value

  • immediate2 (int) – (u32) op1: Immediate value

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If one of the operands is invalid (basic checks)

static create_vmaskmovdqu(address_size, register1, register2, segment_prefix=0)

Creates a VMASKMOVDQU instruction

Parameters:
Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If address_size is not one of 16, 32, 64.

static create_xbegin(bitness, target)

Creates a new XBEGIN instruction

Parameters:
  • bitness (int) – (u32) 16, 32, or 64

  • target (int) – (u64) Target address

Returns:

Created instruction

Return type:

Instruction

Raises:

ValueError – If bitness is not one of 16, 32, 64.

declare_data_len

(u8) Gets the number of elements in a db/dw/dd/dq directive.

Can only be called if Instruction.code is Code.DECLAREBYTE, Code.DECLAREWORD, Code.DECLAREDWORD, Code.DECLAREQWORD

Type:

int

encoding

Instruction encoding, eg. Legacy, 3DNow!, VEX, EVEX, XOP (an EncodingKind enum value)

Examples:

from iced_x86 import *

# vmovaps xmm1,xmm5
data = b"\xC5\xF8\x28\xCD"
decoder = Decoder(64, data)
instr = decoder.decode()

assert instr.encoding == EncodingKind.VEX
Type:

EncodingKind

eq_all_bits(other)

Checks if two instructions are equal, comparing all bits, not ignoring anything. == ignores some fields.

Parameters:

other (Instruction) – Other instruction

Returns:

True if other is exactly identical to this instance

Return type:

bool

far_branch16

(u16) Gets the operand’s branch target.

Use this method if the operand has kind OpKind.FAR_BRANCH16

Type:

int

far_branch32

(u32) Gets the operand’s branch target.

Use this method if the operand has kind OpKind.FAR_BRANCH32

Type:

int

far_branch_selector

(16`) Gets the operand’s branch target selector.

Use this method if the operand has kind OpKind.FAR_BRANCH16 or OpKind.FAR_BRANCH32

Type:

int

flow_control

Control flow info (a FlowControl enum value)

Examples:

from iced_x86 import *

# or ecx,esi
# ud0 rcx,rsi
# call rcx
data = b"\x0B\xCE\x48\x0F\xFF\xCE\xFF\xD1"
decoder = Decoder(64, data)

# or ecx,esi
instr = decoder.decode()
assert instr.flow_control == FlowControl.NEXT

# ud0 rcx,rsi
instr = decoder.decode()
assert instr.flow_control == FlowControl.EXCEPTION

# call rcx
instr = decoder.decode()
assert instr.flow_control == FlowControl.INDIRECT_CALL
Type:

FlowControl

fpu_stack_increment_info()

Gets the FPU status word’s TOP increment value and whether it’s a conditional or unconditional push/pop and whether TOP is written.

Returns:

FPU stack info

Return type:

FpuStackIncrementInfo

Examples:

from iced_x86 import *

# ficomp dword ptr [rax]
data = b"\xDA\x18"
decoder = Decoder(64, data)
instr = decoder.decode()

info = instr.fpu_stack_increment_info()
# It pops the stack once
assert info.increment == 1
assert not info.conditional
assert info.writes_top
get_declare_byte_value(index)

Gets a db value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREBYTE

Parameters:

index (int) – Index (0-15)

Returns:

(u8) The value

Return type:

int

Raises:

ValueError – If index is invalid

get_declare_byte_value_i8(index)

Gets a db value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREBYTE

Parameters:

index (int) – Index (0-15)

Returns:

(i8) The value

Return type:

int

Raises:

ValueError – If index is invalid

get_declare_dword_value(index)

Gets a dd value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREDWORD

Parameters:

index (int) – Index (0-3)

Returns:

(u32) The value

Return type:

int

Raises:

ValueError – If index is invalid

get_declare_dword_value_i32(index)

Gets a dd value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREDWORD

Parameters:

index (int) – Index (0-3)

Returns:

(i32) The value

Return type:

int

Raises:

ValueError – If index is invalid

get_declare_qword_value(index)

Gets a dq value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREQWORD

Parameters:

index (int) – Index (0-1)

Returns:

(u64) The value

Return type:

int

Raises:

ValueError – If index is invalid

get_declare_qword_value_i64(index)

Gets a dq value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREQWORD

Parameters:

index (int) – Index (0-1)

Returns:

(i64) The value

Return type:

int

Raises:

ValueError – If index is invalid

get_declare_word_value(index)

Gets a dw value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREWORD

Parameters:

index (int) – Index (0-7)

Returns:

(u16) The value

Return type:

int

Raises:

ValueError – If index is invalid

get_declare_word_value_i16(index)

Gets a dw value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREWORD

Parameters:

index (int) – Index (0-7)

Returns:

(i16) The value

Return type:

int

Raises:

ValueError – If index is invalid

has_lock_prefix

True if the instruction has the LOCK prefix (F0)

Type:

bool

has_op_mask

Checks if there’s an opmask register (Instruction.op_mask)

Type:

bool

has_rep_prefix

True if the instruction has the REPE or REP prefix (F3)

Type:

bool

has_repe_prefix

True if the instruction has the REPE or REP prefix (F3)

Type:

bool

has_repne_prefix

True if the instruction has the REPNE prefix (F2)

Type:

bool

has_segment_prefix

Checks if the instruction has a segment override prefix, see Instruction.segment_prefix

Type:

bool

has_xacquire_prefix

True if the instruction has the XACQUIRE prefix (F2)

Type:

bool

has_xrelease_prefix

True if the instruction has the XRELEASE prefix (F3)

Type:

bool

immediate(operand)

Gets an operand’s immediate value

Parameters:

operand (int) – Operand number, 0-4

Returns:

(u64) The immediate

Return type:

int

Raises:

ValueError – If operand is invalid or not immediate.

immediate16

(u16) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE16

Type:

int

immediate32

(u32) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE32

Type:

int

immediate32to64

(i64) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE32TO64

Type:

int

immediate64

(u64) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE64

Type:

int

immediate8

(u8) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE8

Type:

int

immediate8_2nd

(u8) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE8_2ND

Type:

int

immediate8to16

(i16) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE8TO16

Type:

int

immediate8to32

(i32) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE8TO32

Type:

int

immediate8to64

(i64) Gets the operand’s immediate value.

Use this method if the operand has kind OpKind.IMMEDIATE8TO64

Type:

int

ip

(u64) Gets the 64-bit IP of the instruction

Type:

int

ip16

(u16) Gets the 16-bit IP of the instruction

Type:

int

ip32

(u32) Gets the 32-bit IP of the instruction

Type:

int

ip_rel_memory_address

(u64) Gets the RIP/EIP releative address (Instruction.memory_displacement).

This method is only valid if there’s a memory operand with RIP/EIP relative addressing, see Instruction.is_ip_rel_memory_operand

Type:

int

is_broadcast

True if the data is broadcast (EVEX instructions only)

Type:

bool

is_call_far

Checks if it’s a CALL FAR instruction

Type:

bool

is_call_far_indirect

Checks if it’s a CALL FAR [mem] instruction

Type:

bool

is_call_near

Checks if it’s a CALL NEAR instruction

Type:

bool

is_call_near_indirect

Checks if it’s a CALL NEAR reg/[mem] instruction

Type:

bool

is_invalid

Checks if it’s an invalid instruction (Instruction.code == Code.INVALID)

Type:

bool

is_ip_rel_memory_operand

Checks if the memory operand is RIP/EIP relative

Type:

bool

is_jcc_near

Checks if it’s a Jcc NEAR instruction

Type:

bool

is_jcc_short

Checks if it’s a Jcc SHORT instruction

Type:

bool

is_jcc_short_or_near

Checks if it’s a Jcc SHORT or Jcc NEAR instruction

Type:

bool

is_jcx_short

Checks if it’s a JCXZ SHORT, JECXZ SHORT or JRCXZ SHORT instruction

Type:

bool

is_jkcc_near

Checks if it’s a JKccD NEAR instruction

Type:

bool

is_jkcc_short

Checks if it’s a JKccD SHORT instruction

Type:

bool

is_jkcc_short_or_near

Checks if it’s a JKccD SHORT or JKccD NEAR instruction

Type:

bool

is_jmp_far

Checks if it’s a JMP FAR instruction

Type:

bool

is_jmp_far_indirect

Checks if it’s a JMP FAR [mem] instruction

Type:

bool

is_jmp_near

Checks if it’s a JMP NEAR instruction

Type:

bool

is_jmp_near_indirect

Checks if it’s a JMP NEAR reg/[mem] instruction

Type:

bool

is_jmp_short

Checks if it’s a JMP SHORT instruction

Type:

bool

is_jmp_short_or_near

Checks if it’s a JMP SHORT or a JMP NEAR instruction

Type:

bool

is_loop

Checks if it’s a LOOP SHORT instruction

Type:

bool

is_loopcc

Checks if it’s a LOOPcc SHORT instruction

Type:

bool

is_mvex_eviction_hint

True if eviction hint bit is set ({eh}) (MVEX instructions only)

Type:

bool

is_privileged

True if it’s a privileged instruction (all CPL=0 instructions (except VMCALL) and IOPL instructions IN, INS, OUT, OUTS, CLI, STI)

Type:

bool

is_save_restore_instruction

True if it’s an instruction that saves or restores too many registers (eg. FXRSTOR, XSAVE, etc).

Type:

bool

is_stack_instruction

True if this is an instruction that implicitly uses the stack pointer (SP/ESP/RSP), eg. CALL, PUSH, POP, RET, etc.

See also Instruction.stack_pointer_increment

Examples:

from iced_x86 import *

# or ecx,esi
# push rax
data = b"\x0B\xCE\x50"
decoder = Decoder(64, data)

# or ecx,esi
instr = decoder.decode()
assert not instr.is_stack_instruction

# push rax
instr = decoder.decode()
assert instr.is_stack_instruction
assert instr.stack_pointer_increment == -8
Type:

bool

is_string_instruction

True if it’s a “string” instruction, such as MOVS, LODS, SCAS, etc.

Type:

bool

is_vsib

Checks if this is a VSIB instruction, see also Instruction.is_vsib32, Instruction.is_vsib64

Type:

bool

is_vsib32

VSIB instructions only (Instruction.is_vsib): True if it’s using 32-bit indexes, False if it’s using 64-bit indexes

Type:

bool

is_vsib64

VSIB instructions only (Instruction.is_vsib): True if it’s using 64-bit indexes, False if it’s using 32-bit indexes

Type:

bool

len

(u8) Gets the length of the instruction, 0-15 bytes.

You can also call len(instr) to get this value.

Note

This is just informational. If you modify the instruction or create a new one, this method could return the wrong value.

Type:

int

memory_base

Gets the memory operand’s base register (a Register enum value) or Register.NONE if none.

Use this method if the operand has kind OpKind.MEMORY

Type:

Register

memory_displ_size

(u8) Gets the size of the memory displacement in bytes.

Valid values are 0, 1 (16/32/64-bit), 2 (16-bit), 4 (32-bit), 8 (64-bit).

Note that the return value can be 1 and Instruction.memory_displacement may still not fit in a signed byte if it’s an EVEX/MVEX encoded instruction.

Use this method if the operand has kind OpKind.MEMORY

Type:

int

memory_displacement

(u64) Gets the memory operand’s displacement or the 64-bit absolute address if it’s an EIP or RIP relative memory operand.

Use this method if the operand has kind OpKind.MEMORY

Type:

int

memory_index

Gets the memory operand’s index register (a Register enum value) or Register.NONE if none.

Use this method if the operand has kind OpKind.MEMORY

Type:

Register

memory_index_scale

(u8) Gets the index register scale value, valid values are *1, *2, *4, *8.

Use this method if the operand has kind OpKind.MEMORY

Type:

int

memory_segment

Gets the effective segment register used to reference the memory location (a Register enum value).

Use this method if the operand has kind OpKind.MEMORY, OpKind.MEMORY_SEG_SI, OpKind.MEMORY_SEG_ESI, OpKind.MEMORY_SEG_RSI

Type:

Register

memory_size

Gets the size of the memory location (a MemorySize enum value) that is referenced by the operand.

See also Instruction.is_broadcast.

Use this method if the operand has kind OpKind.MEMORY, OpKind.MEMORY_SEG_SI, OpKind.MEMORY_SEG_ESI, OpKind.MEMORY_SEG_RSI, OpKind.MEMORY_ESDI, OpKind.MEMORY_ESEDI, OpKind.MEMORY_ESRDI

Type:

MemorySize

merging_masking

True if merging-masking, False if zeroing-masking.

Only used by most EVEX encoded instructions that use opmask registers.

Type:

bool

mnemonic

Gets the mnemonic (a Mnemonic enum value), see also Instruction.code

Type:

Mnemonic

mvex_reg_mem_conv

(MVEX) Register/memory operand conversion function (an MvexRegMemConv enum value)

Type:

MvexRegMemConv

near_branch16

(u16) Gets the operand’s branch target.

Use this method if the operand has kind OpKind.NEAR_BRANCH16

Type:

int

near_branch32

(u32) Gets the operand’s branch target.

Use this method if the operand has kind OpKind.NEAR_BRANCH32

Type:

int

near_branch64

(u64) Gets the operand’s branch target.

Use this method if the operand has kind OpKind.NEAR_BRANCH64

Type:

int

near_branch_target

(u64) Gets the near branch target if it’s a CALL/JMP/Jcc near branch instruction

(i.e., if Instruction.op0_kind is OpKind.NEAR_BRANCH16, OpKind.NEAR_BRANCH32 or OpKind.NEAR_BRANCH64)

Type:

int

negate_condition_code()

Negates the condition code, eg. JE -> JNE.

Can be used if it’s Jcc, SETcc, CMOVcc, CMPccXADD, LOOPcc and does nothing if the instruction doesn’t have a condition code.

Examples:

from iced_x86 import *

# setbe al
data = b"\x0F\x96\xC0"
decoder = Decoder(64, data)

instr = decoder.decode()
assert instr.code == Code.SETBE_RM8
assert instr.condition_code == ConditionCode.BE
instr.negate_condition_code()
assert instr.code == Code.SETA_RM8
assert instr.condition_code == ConditionCode.A
next_ip

(u64) Gets the 64-bit IP of the next instruction

Type:

int

next_ip16

(u16) Gets the 16-bit IP of the next instruction

Type:

int

next_ip32

(u32) Gets the 32-bit IP of the next instruction

Type:

int

op0_kind

Gets operand #0’s kind (an OpKind enum value) if the operand exists (see Instruction.op_count and Instruction.op_kind)

Type:

OpKind

op0_register

Gets operand #0’s register value (a Register enum value).

Use this method if operand #0 (Instruction.op0_kind) has kind OpKind.REGISTER, see Instruction.op_count and Instruction.op_register

Type:

Register

op1_kind

Gets operand #1’s kind (an OpKind enum value) if the operand exists (see Instruction.op_count and Instruction.op_kind)

Type:

OpKind

op1_register

Gets operand #1’s register value (a Register enum value).

Use this method if operand #1 (Instruction.op0_kind) has kind OpKind.REGISTER, see Instruction.op_count and Instruction.op_register

Type:

Register

op2_kind

Gets operand #2’s kind (an OpKind enum value) if the operand exists (see Instruction.op_count and Instruction.op_kind)

Type:

OpKind

op2_register

Gets operand #2’s register value (a Register enum value).

Use this method if operand #2 (Instruction.op0_kind) has kind OpKind.REGISTER, see Instruction.op_count and Instruction.op_register

Type:

Register

op3_kind

Gets operand #3’s kind (an OpKind enum value) if the operand exists (see Instruction.op_count and Instruction.op_kind)

Type:

OpKind

op3_register

Gets operand #3’s register value (a Register enum value).

Use this method if operand #3 (Instruction.op0_kind) has kind OpKind.REGISTER, see Instruction.op_count and Instruction.op_register

Type:

Register

op4_kind

Gets operand #4’s kind (an OpKind enum value) if the operand exists (see Instruction.op_count and Instruction.op_kind)

Type:

OpKind

op4_register

Gets operand #4’s register value (a Register enum value).

Use this method if operand #4 (Instruction.op0_kind) has kind OpKind.REGISTER, see Instruction.op_count and Instruction.op_register

Type:

Register

op_code()

Gets the OpCodeInfo

Returns:

Op code info

Return type:

OpCodeInfo

op_count

Gets the operand count. An instruction can have 0-5 operands.

Examples:

from iced_x86 import *

# add [rax],ebx
data = b"\x01\x18"
decoder = Decoder(64, data)
instr = decoder.decode()

assert instr.op_count == 2
Type:

int

op_kind(operand)

Gets an operand’s kind (an OpKind enum value) if it exists (see Instruction.op_count)

Parameters:

operand (int) – Operand number, 0-4

Returns:

The operand’s operand kind

Return type:

OpKind

Raises:

ValueError – If operand is invalid

Examples:

from iced_x86 import *

# add [rax],ebx
data = b"\x01\x18"
decoder = Decoder(64, data)
instr = decoder.decode()

assert instr.op_count == 2
assert instr.op_kind(0) == OpKind.MEMORY
assert instr.memory_base == Register.RAX
assert instr.memory_index == Register.NONE
assert instr.op_kind(1) == OpKind.REGISTER
assert instr.op_register(1) == Register.EBX
op_mask

Gets the opmask register (Register.K1 - Register.K7) or Register.NONE if none (a Register enum value)

Type:

Register

op_register(operand)

Gets the operand’s register value (a Register enum value).

Use this method if the operand has kind OpKind.REGISTER

Parameters:

operand (int) – Operand number, 0-4

Returns:

The operand’s register value

Return type:

Register

Raises:

ValueError – If operand is invalid

Examples:

from iced_x86 import *

# add [rax],ebx
data = b"\x01\x18"
decoder = Decoder(64, data)
instr = decoder.decode()

assert instr.op_count == 2
assert instr.op_kind(0) == OpKind.MEMORY
assert instr.op_kind(1) == OpKind.REGISTER
assert instr.op_register(1) == Register.EBX
rflags_cleared

All flags that are always cleared by the CPU.

This method returns an RflagsBits value. See also Instruction.rflags_modified.

Examples:

from iced_x86 import *

# adc rsi,rcx
# xor rdi,5Ah
data = b"\x48\x11\xCE\x48\x83\xF7\x5A"
decoder = Decoder(64, data)

# adc rsi,rcx
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.CF
assert instr.rflags_written == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.NONE
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.NONE
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF

# xor rdi,5Ah
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.NONE
assert instr.rflags_written == RflagsBits.SF | RflagsBits.ZF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.OF | RflagsBits.CF
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.AF
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
Type:

RflagsBits

rflags_modified

All flags that are modified by the CPU. This is rflags_written + rflags_cleared + rflags_set + rflags_undefined.

This method returns an RflagsBits value.

Examples:

from iced_x86 import *

# adc rsi,rcx
# xor rdi,5Ah
data = b"\x48\x11\xCE\x48\x83\xF7\x5A"
decoder = Decoder(64, data)

# adc rsi,rcx
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.CF
assert instr.rflags_written == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.NONE
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.NONE
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF

# xor rdi,5Ah
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.NONE
assert instr.rflags_written == RflagsBits.SF | RflagsBits.ZF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.OF | RflagsBits.CF
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.AF
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
Type:

RflagsBits

rflags_read

All flags that are read by the CPU when executing the instruction.

This method returns an RflagsBits value. See also Instruction.rflags_modified.

Examples:

from iced_x86 import *

# adc rsi,rcx
# xor rdi,5Ah
data = b"\x48\x11\xCE\x48\x83\xF7\x5A"
decoder = Decoder(64, data)

# adc rsi,rcx
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.CF
assert instr.rflags_written == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.NONE
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.NONE
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF

# xor rdi,5Ah
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.NONE
assert instr.rflags_written == RflagsBits.SF | RflagsBits.ZF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.OF | RflagsBits.CF
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.AF
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
Type:

RflagsBits

rflags_set

All flags that are always set by the CPU.

This method returns an RflagsBits value. See also Instruction.rflags_modified.

Examples:

from iced_x86 import *

# adc rsi,rcx
# xor rdi,5Ah
data = b"\x48\x11\xCE\x48\x83\xF7\x5A"
decoder = Decoder(64, data)

# adc rsi,rcx
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.CF
assert instr.rflags_written == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.NONE
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.NONE
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF

# xor rdi,5Ah
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.NONE
assert instr.rflags_written == RflagsBits.SF | RflagsBits.ZF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.OF | RflagsBits.CF
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.AF
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
Type:

RflagsBits

rflags_undefined

All flags that are undefined after executing the instruction.

This method returns an RflagsBits value. See also Instruction.rflags_modified.

Examples:

from iced_x86 import *

# adc rsi,rcx
# xor rdi,5Ah
data = b"\x48\x11\xCE\x48\x83\xF7\x5A"
decoder = Decoder(64, data)

# adc rsi,rcx
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.CF
assert instr.rflags_written == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.NONE
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.NONE
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF

# xor rdi,5Ah
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.NONE
assert instr.rflags_written == RflagsBits.SF | RflagsBits.ZF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.OF | RflagsBits.CF
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.AF
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
Type:

RflagsBits

rflags_written

All flags that are written by the CPU, except those flags that are known to be undefined, always set or always cleared.

This method returns an RflagsBits value. See also Instruction.rflags_modified.

Examples:

from iced_x86 import *

# adc rsi,rcx
# xor rdi,5Ah
data = b"\x48\x11\xCE\x48\x83\xF7\x5A"
decoder = Decoder(64, data)

# adc rsi,rcx
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.CF
assert instr.rflags_written == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.NONE
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.NONE
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF

# xor rdi,5Ah
instr = decoder.decode()
assert instr.rflags_read == RflagsBits.NONE
assert instr.rflags_written == RflagsBits.SF | RflagsBits.ZF | RflagsBits.PF
assert instr.rflags_cleared == RflagsBits.OF | RflagsBits.CF
assert instr.rflags_set == RflagsBits.NONE
assert instr.rflags_undefined == RflagsBits.AF
assert instr.rflags_modified == RflagsBits.OF | RflagsBits.SF | RflagsBits.ZF | RflagsBits.AF | RflagsBits.CF | RflagsBits.PF
Type:

RflagsBits

rounding_control

Gets the rounding control (a RoundingControl enum value) or RoundingControl.NONE if the instruction doesn’t use it.

Note

SAE is implied but Instruction.suppress_all_exceptions still returns False.

Type:

RoundingControl

segment_prefix

Gets the segment override prefix (a Register enum value) or Register.NONE if none.

See also Instruction.memory_segment.

Use this method if the operand has kind OpKind.MEMORY, OpKind.MEMORY_SEG_SI, OpKind.MEMORY_SEG_ESI, OpKind.MEMORY_SEG_RSI

Type:

Register

set_declare_byte_value(index, new_value)

Sets a new db value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREBYTE

Parameters:
  • index (int) – Index (0-15)

  • new_value (int) – (u8) New value

Raises:

ValueError – If index is invalid

set_declare_byte_value_i8(index, new_value)

Sets a new db value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREBYTE

Parameters:
  • index (int) – Index (0-15)

  • new_value (int) – (i8) New value

Raises:

ValueError – If index is invalid

set_declare_dword_value(index, new_value)

Sets a new dd value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREDWORD

Parameters:
  • index (int) – Index (0-3)

  • new_value (int) – (u32) New value

Raises:

ValueError – If index is invalid

set_declare_dword_value_i32(index, new_value)

Sets a new dd value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREDWORD

Parameters:
  • index (int) – Index (0-3)

  • new_value (int) – (i32) New value

Raises:

ValueError – If index is invalid

set_declare_qword_value(index, new_value)

Sets a new dq value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREQWORD

Parameters:
  • index (int) – Index (0-1)

  • new_value (int) – (u64) New value

Raises:

ValueError – If index is invalid

set_declare_qword_value_i64(index, new_value)

Sets a new dq value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREQWORD

Parameters:
  • index (int) – Index (0-1)

  • new_value (int) – (i64) New value

Raises:

ValueError – If index is invalid

set_declare_word_value(index, new_value)

Sets a new dw value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREWORD

Parameters:
  • index (int) – Index (0-7)

  • new_value (int) – (u16) New value

Raises:

ValueError – If index is invalid

set_declare_word_value_i16(index, new_value)

Sets a new dw value, see also Instruction.declare_data_len.

Can only be called if Instruction.code is Code.DECLAREWORD

Parameters:
  • index (int) – Index (0-7)

  • new_value (int) – (i16) New value

Raises:

ValueError – If index is invalid

set_immediate_i32(operand, new_value)

Sets an operand’s immediate value

Parameters:
  • operand (int) – Operand number, 0-4

  • new_value (int) – (i32) Immediate

Raises:

ValueError – If operand is invalid or if it’s not an immediate operand

set_immediate_i64(operand, new_value)

Sets an operand’s immediate value

Parameters:
  • operand (int) – Operand number, 0-4

  • new_value (int) – (i64) Immediate

Raises:

ValueError – If operand is invalid or if it’s not an immediate operand

set_immediate_u32(operand, new_value)

Sets an operand’s immediate value

Parameters:
  • operand (int) – Operand number, 0-4

  • new_value (int) – (u32) Immediate

Raises:

ValueError – If operand is invalid or if it’s not an immediate operand

set_immediate_u64(operand, new_value)

Sets an operand’s immediate value

Parameters:
  • operand (int) – Operand number, 0-4

  • new_value (int) – (u64) Immediate

Raises:

ValueError – If operand is invalid or if it’s not an immediate operand

set_op_kind(operand, op_kind)

Sets an operand’s kind

Parameters:
  • operand (int) – Operand number, 0-4

  • op_kind (OpKind) – Operand kind

Raises:

ValueError – If operand is invalid

set_op_register(operand, new_value)

Sets the operand’s register value.

Use this method if the operand has kind OpKind.REGISTER

Parameters:
  • operand (int) – Operand number, 0-4

  • new_value (Register) – New value

Raises:

ValueError – If operand is invalid

stack_pointer_increment

(i32) Gets the number of bytes added to SP/ESP/RSP or 0 if it’s not an instruction that pushes or pops data.

This method assumes the instruction doesn’t change the privilege level (eg. IRET/D/Q). If it’s the LEAVE instruction, this method returns 0.

Examples:

from iced_x86 import *

# pushfq
data = b"\x9C"
decoder = Decoder(64, data)
instr = decoder.decode()

assert instr.is_stack_instruction
assert instr.stack_pointer_increment == -8
Type:

int

suppress_all_exceptions

Gets the suppress all exceptions flag (EVEX/MVEX encoded instructions). Note that if Instruction.rounding_control is not RoundingControl.NONE, SAE is implied but this method will still return False.

Type:

bool

vsib

Checks if it’s a vsib instruction.

  • Returns True if it’s a VSIB instruction with 64-bit indexes

  • Returns False if it’s a VSIB instruction with 32-bit indexes

  • Returns None if it’s not a VSIB instruction.

Type:

bool, None

zeroing_masking

True if zeroing-masking, False if merging-masking.

Only used by most EVEX encoded instructions that use opmask registers.

Type:

bool