4 from __future__
import print_function
8 CODE32 = b
"\xc0\xe0\x02"
9 CODE32 += b
"\xc0\xf6\x02"
10 CODE32 += b
"\xc1\xf6\x00"
11 CODE32 += b
"\x82\xc0\x00"
12 CODE32 += b
"\x0f\x1a\x00"
13 CODE32 += b
"\xf7\xc0\x11\x22\x33\x44"
14 CODE32 += b
"\xf7\xc8\x11\x22\x33\x44"
15 CODE32 += b
"\xf7\x88\x00\x00\x00\x00\x00\x00\x00\x00"
16 CODE32 += b
"\xf6\x88\x00\x00\x00\x00\x00"
21 CODE32 += b
"\x0f\x20\x00"
22 CODE32 += b
"\x0f\x20\x40"
23 CODE32 += b
"\x0f\x20\x80"
25 CODE32 += b
"\x0f\x22\x00"
26 CODE32 += b
"\x0f\x22\x40"
27 CODE32 += b
"\x0f\x22\x80"
29 CODE32 += b
"\x0f\x21\x00"
30 CODE32 += b
"\x0f\x21\x40"
31 CODE32 += b
"\x0f\x21\x80"
33 CODE32 += b
"\x0f\x23\x00"
34 CODE32 += b
"\x0f\x23\x40"
35 CODE32 += b
"\x0f\x23\x80"
37 CODE32 += b
"\x66\x2e\x0f\x58\xc0"
38 CODE32 += b
"\x2e\x66\x0f\x58\xc0"
39 CODE32 += b
"\x66\xf2\x0f\x38\xf1\xc3"
40 CODE32 += b
"\xf2\x0f\x38\xf1\x8c\xcb\xef\xbe\xad\xde"
42 CODE32_MEMREF = b
"\x8b\x84\x91\x23\x01\x00\x00"
43 CODE32_MEMREF += b
"\x8b\x04\x95\x23\x01\x00\x00"
44 CODE32_MEMREF += b
"\x8b\x04\x95\xdd\xfe\xff\xff"
45 CODE32_MEMREF += b
"\xa1\x23\x01\x00\x00"
46 CODE32_MEMREF += b
"\xa1\x00\x00\x00\x00"
47 CODE32_MEMREF += b
"\xa1\xdd\xfe\xff\xff"
48 CODE32_MEMREF += b
"\x8b\x04\x91"
50 CODE64_MEMREF = b
"\xa3\x0b\x00\x00\x0f\xbe\xc0\x48\x83"
51 CODE64_MEMREF += b
"\xa0\x71\xfa\xff\x48\x85\xc0\x48\x89"
53 CODE32_ARITH = b
"\x83\xe0\xf7"
54 CODE32_ARITH += b
"\x83\xe0\x10"
55 CODE32_ARITH += b
"\x83\xe0\x00"
56 CODE32_ARITH += b
"\x80\x23\x10"
58 CODE64_ARITH = b
"\x41\x83\xe0\xfa"
59 CODE64_ARITH += b
"\x48\x83\xe4\xf0"
61 CODE32_IMM = b
"\xc2\xb8\xc0"
62 CODE32_IMM += b
"\xc2\x0f\x92"
63 CODE32_IMM += b
"\x02\x2d\x00\x00\x00\x83"
67 _python3 = sys.version_info.major == 3
70 (CS_ARCH_X86, CS_MODE_32, CODE32,
"X86 32 (Intel syntax)", 0),
71 (CS_ARCH_X86, CS_MODE_32, CODE32,
"X86 32 (ATT syntax)", CS_OPT_SYNTAX_ATT),
73 (CS_ARCH_X86, CS_MODE_32, CODE32_MEMREF,
"X86 32 MemRef (Intel syntax)", 0),
74 (CS_ARCH_X86, CS_MODE_32, CODE32_MEMREF,
"X86 32 MemRef (ATT syntax)", CS_OPT_SYNTAX_ATT),
75 (CS_ARCH_X86, CS_MODE_64, CODE64_MEMREF,
"X86 64 (Intel syntax)", 0),
77 (CS_ARCH_X86, CS_MODE_32, CODE32_ARITH,
"X86 32 (Intel syntax)", 0),
78 (CS_ARCH_X86, CS_MODE_64, CODE64_ARITH,
"X86 64 (Intel syntax)", 0),
80 (CS_ARCH_X86, CS_MODE_32, CODE32_IMM,
"X86 32 (Intel syntax)", 0),
81 (CS_ARCH_X86, CS_MODE_32, CODE32_IMM,
"X86 32 (Intel syntax)", CS_OPT_SYNTAX_ATT),
87 return " ".join(
"0x{0:02x}".format(c)
for c
in s)
89 return " ".join(
"0x{0:02x}".format(ord(c))
for c
in s)
93 for (arch, mode, code, comment, syntax)
in all_tests:
94 print(
"Platform: %s" % comment)
95 print(
"Code: %s" %(
to_hex(code))),
100 for insn
in md.disasm(code, 0x1000):
101 print(
"0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
105 if __name__ ==
'__main__':
def test_cs_disasm_quick()