4 from __future__
import print_function
7 from xprint
import to_hex, to_x
9 MOS65XX_CODE = b
"\x0d\x34\x12\x00\x81\x65\x6c\x01\x00\x85\xFF\x10\x00\x19\x42\x42\x00\x49\x42"
13 'implied addressing (no addressing mode)',
14 'accumulator addressing',
15 'absolute addressing',
16 'zeropage addressing',
17 '8 Bit immediate value',
18 'indexed absolute addressing by the X index register',
19 'indexed absolute addressing by the Y index register',
20 'indexed indirect addressing by the X index register',
21 'indirect indexed addressing by the Y index register',
22 'indexed zeropage addressing by the X index register',
23 'indexed zeropage addressing by the Y index register',
24 'relative addressing used by branches',
25 'absolute indirect addressing'
31 print(
"0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
36 print(
"\taddress mode: %s" % (address_modes[insn.am]))
37 print(
"\tmodifies flags: %s" % (
'true' if insn.modifies_flags != 0
else 'false'))
38 if len(insn.operands) > 0:
39 print(
"\top_count: %u" %
len(insn.operands))
41 for i
in insn.operands:
43 if i.type == MOS65XX_OP_REG:
44 print(
"\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
45 if i.type == MOS65XX_OP_IMM:
46 print(
"\t\toperands[%u].type: IMM = 0x%s" % (c,
to_x(i.imm)))
47 if i.type == MOS65XX_OP_MEM:
48 print(
"\t\toperands[%u].type: MEM = 0x%s" % (c,
to_x(i.mem)))
54 print(
"Platform: %s" %
"MOS65XX")
55 print(
"Code: %s" %
to_hex(MOS65XX_CODE))
59 md =
Cs(CS_ARCH_MOS65XX, 0)
61 for insn
in md.disasm(MOS65XX_CODE, 0x1000):
65 print(
"0x%x:\n" % (insn.address + insn.size))
67 print(
"ERROR: %s" % e)
70 if __name__ ==
'__main__':