4 from __future__
import print_function
7 from xprint
import to_hex, to_x_32
9 PPC_CODE = b
"\x43\x20\x0c\x07\x41\x56\xff\x17\x80\x20\x00\x00\x80\x3f\x00\x00\x10\x43\x23\x0e\xd0\x44\x00\x80\x4c\x43\x22\x02\x2d\x03\x00\x80\x7c\x43\x20\x14\x7c\x43\x20\x93\x4f\x20\x00\x21\x4c\xc8\x00\x21\x40\x82\x00\x14"
10 PPC_CODE2 = b
"\x10\x60\x2a\x10\x10\x64\x28\x88\x7c\x4a\x5d\x0f"
13 (CS_ARCH_PPC, CS_MODE_BIG_ENDIAN, PPC_CODE,
"PPC-64"),
14 (CS_ARCH_PPC, CS_MODE_BIG_ENDIAN + CS_MODE_QPX, PPC_CODE2,
"PPC-64 + QPX"),
20 print(
"0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
26 if len(insn.operands) > 0:
27 print(
"\top_count: %u" %
len(insn.operands))
29 for i
in insn.operands:
30 if i.type == PPC_OP_REG:
31 print(
"\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
32 if i.type == PPC_OP_IMM:
33 print(
"\t\toperands[%u].type: IMM = 0x%s" % (c,
to_x_32(i.imm)))
34 if i.type == PPC_OP_MEM:
35 print(
"\t\toperands[%u].type: MEM" % c)
37 print(
"\t\t\toperands[%u].mem.base: REG = %s" \
38 % (c, insn.reg_name(i.mem.base)))
40 print(
"\t\t\toperands[%u].mem.disp: 0x%s" \
42 if i.type == PPC_OP_CRX:
43 print(
"\t\toperands[%u].type: CRX" % c)
44 print(
"\t\t\toperands[%u].crx.scale: = %u" \
47 print(
"\t\t\toperands[%u].crx.reg: REG = %s" \
48 % (c, insn.reg_name(i.crx.reg)))
50 print(
"\t\t\toperands[%u].crx.cond: 0x%x" \
55 print(
"\tBranch code: %u" % insn.bc)
57 print(
"\tBranch hint: %u" % insn.bh)
59 print(
"\tUpdate-CR0: True")
65 for (arch, mode, code, comment)
in all_tests:
67 print(
"Platform: %s" % comment)
68 print(
"Code: %s" %
to_hex(code))
74 for insn
in md.disasm(code, 0x1000):
77 print(
"0x%x:\n" % (insn.address + insn.size))
79 print(
"ERROR: %s" % e)
82 if __name__ ==
'__main__':
def print_insn_detail(insn)
def to_hex(s, prefix_0x=True)