5 from __future__
import print_function
8 from xprint
import to_x, to_hex
11 XCORE_CODE = b
"\xfe\x0f\xfe\x17\x13\x17\xc6\xfe\xec\x17\x97\xf8\xec\x4f\x1f\xfd\xec\x37\x07\xf2\x45\x5b\xf9\xfa\x02\x06\x1b\x10\x09\xfd\xec\xa7"
14 (CS_ARCH_XCORE, 0, XCORE_CODE,
"XCore"),
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 == XCORE_OP_REG:
31 print(
"\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
32 if i.type == XCORE_OP_IMM:
33 print(
"\t\toperands[%u].type: IMM = 0x%s" % (c,
to_x(i.imm)))
34 if i.type == XCORE_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.index: REG = %s" \
41 % (c, insn.reg_name(i.mem.index)))
43 print(
"\t\t\toperands[%u].mem.disp: 0x%s" \
44 % (c,
to_x(i.mem.disp)))
46 print(
"\t\t\toperands[%u].mem.direct: -1" % c)
53 for (arch, mode, code, comment)
in all_tests:
55 print(
"Platform: %s" %comment)
56 print(
"Code: %s" %
to_hex(code))
62 for insn
in md.disasm(code, 0x1000):
65 print(
"0x%x:\n" % (insn.address + insn.size))
70 if __name__ ==
'__main__':
def print_insn_detail(insn)
def to_hex(s, prefix_0x=True)