5 from __future__
import print_function
8 from xprint
import to_hex, to_x_32
11 SPARC_CODE = b
"\x80\xa0\x40\x02\x85\xc2\x60\x08\x85\xe8\x20\x01\x81\xe8\x00\x00\x90\x10\x20\x01\xd5\xf6\x10\x16\x21\x00\x00\x0a\x86\x00\x40\x02\x01\x00\x00\x00\x12\xbf\xff\xff\x10\xbf\xff\xff\xa0\x02\x00\x09\x0d\xbf\xff\xff\xd4\x20\x60\x00\xd4\x4e\x00\x16\x2a\xc2\x80\x03"
12 SPARCV9_CODE = b
"\x81\xa8\x0a\x24\x89\xa0\x10\x20\x89\xa0\x1a\x60\x89\xa0\x00\xe0"
15 (CS_ARCH_SPARC, CS_MODE_BIG_ENDIAN, SPARC_CODE,
"Sparc"),
16 (CS_ARCH_SPARC, CS_MODE_BIG_ENDIAN+CS_MODE_V9, SPARCV9_CODE,
"SparcV9"),
22 print(
"0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
28 if len(insn.operands) > 0:
29 print(
"\top_count: %u" %
len(insn.operands))
31 for i
in insn.operands:
32 if i.type == SPARC_OP_REG:
33 print(
"\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
34 if i.type == SPARC_OP_IMM:
35 print(
"\t\toperands[%u].type: IMM = 0x%s" % (c,
to_x_32(i.imm)))
36 if i.type == SPARC_OP_MEM:
37 print(
"\t\toperands[%u].type: MEM" % c)
39 print(
"\t\t\toperands[%u].mem.base: REG = %s" \
40 % (c, insn.reg_name(i.mem.base)))
42 print(
"\t\t\toperands[%u].mem.index: REG = %s" \
43 % (c, insn.reg_name(i.mem.index)))
45 print(
"\t\t\toperands[%u].mem.disp: 0x%s" \
50 print(
"\tCode condition: %u" % insn.cc)
52 print(
"\tHint code: %u" % insn.hint)
57 for (arch, mode, code, comment)
in all_tests:
59 print(
"Platform: %s" % comment)
60 print(
"Code: %s" %
to_hex(code))
66 for insn
in md.disasm(code, 0x1000):
69 print(
"0x%x:\n" % (insn.address + insn.size))
74 if __name__ ==
'__main__':
def print_insn_detail(insn)
def to_hex(s, prefix_0x=True)