1# Capstone Python bindings, by Nguyen Anh Quynnh <aquynh@gmail.com> 2 3import ctypes 4from . import copy_ctypes_list 5from .mos65xx_const import * 6 7# define the API 8class MOS65xxOpValue(ctypes.Union): 9 _fields_ = ( 10 ('reg', ctypes.c_uint), 11 ('imm', ctypes.c_uint8), 12 ('mem', ctypes.c_uint16), 13 ) 14 15class MOS65xxOp(ctypes.Structure): 16 _fields_ = ( 17 ('type', ctypes.c_uint), 18 ('value', MOS65xxOpValue), 19 ) 20 21 @property 22 def imm(self): 23 return self.value.imm 24 25 @property 26 def reg(self): 27 return self.value.reg 28 29 @property 30 def mem(self): 31 return self.value.mem 32 33 34class CsMOS65xx(ctypes.Structure): 35 _fields_ = ( 36 ('am', ctypes.c_uint), 37 ('modifies_flags', ctypes.c_uint8), 38 ('op_count', ctypes.c_uint8), 39 ('operands', MOS65xxOp * 3), 40 ) 41 42def get_arch_info(a): 43 return (a.am, a.modifies_flags, copy_ctypes_list(a.operands[:a.op_count])) 44 45 46