Rizin
unix-like reverse engineering framework and cli tools
m68k.py
Go to the documentation of this file.
1 # Capstone Python bindings, by Nicolas PLANEL <nplanel@gmail.com>
2 
3 import ctypes
4 from . import copy_ctypes_list
5 from .m68k_const import *
6 
7 # define the API
8 class M68KOpMem(ctypes.Structure):
9  _fields_ = (
10  ('base_reg', ctypes.c_uint),
11  ('index_reg', ctypes.c_uint),
12  ('in_base_reg', ctypes.c_uint),
13  ('in_disp', ctypes.c_uint),
14  ('out_disp', ctypes.c_uint),
15  ('disp', ctypes.c_short),
16  ('scale', ctypes.c_ubyte),
17  ('bitfield', ctypes.c_ubyte),
18  ('width', ctypes.c_ubyte),
19  ('offset', ctypes.c_ubyte),
20  ('index_size', ctypes.c_ubyte),
21  )
22 
23 class M68KOpRegPair(ctypes.Structure):
24  _fields_ = (
25  ('reg_0', ctypes.c_uint),
26  ('reg_1', ctypes.c_uint),
27  )
28 
29 class M68KOpValue(ctypes.Union):
30  _fields_ = (
31  ('imm', ctypes.c_int64),
32  ('dimm', ctypes.c_double),
33  ('simm', ctypes.c_float),
34  ('reg', ctypes.c_uint),
35  ('reg_pair', M68KOpRegPair),
36  )
37 
38 class M68KOpBrDisp(ctypes.Structure):
39  _fields_ = (
40  ('disp', ctypes.c_int),
41  ('disp_size', ctypes.c_ubyte),
42  )
43 
44 class M68KOp(ctypes.Structure):
45  _fields_ = (
46  ('value', M68KOpValue),
47  ('mem', M68KOpMem),
48  ('br_disp', M68KOpBrDisp),
49  ('register_bits', ctypes.c_uint),
50  ('type', ctypes.c_uint),
51  ('address_mode', ctypes.c_uint),
52  )
53 
54  @property
55  def imm(self):
56  return self.value.imm
57 
58  @property
59  def dimm(self):
60  return self.value.dimm
61 
62  @property
63  def simm(self):
64  return self.value.simm
65 
66  @property
67  def reg(self):
68  return self.value.reg
69 
70  @property
71  def mem(self):
72  return self.memmem
73 
74  @property
75  def register_bits(self):
76  return self.register_bitsregister_bits
77 
78 class M68KOpSize(ctypes.Structure):
79  _fields_ = (
80  ('type', ctypes.c_uint),
81  ('size', ctypes.c_uint),
82  )
83 
84  def get(a):
85  return copy_ctypes_list(type, size)
86 
87 class CsM68K(ctypes.Structure):
88  M68K_OPERAND_COUNT = 4
89  _fields_ = (
90  ('operands', M68KOp * M68K_OPERAND_COUNT),
91  ('op_size', M68KOpSize),
92  ('op_count', ctypes.c_uint8),
93  )
94 
96  return (copy_ctypes_list(a.operands[:a.op_count]), a.op_size)
def dimm(self)
Definition: m68k.py:59
def mem(self)
Definition: m68k.py:71
def imm(self)
Definition: m68k.py:55
def register_bits(self)
Definition: m68k.py:75
def reg(self)
Definition: m68k.py:67
def simm(self)
Definition: m68k.py:63
def get_arch_info(a)
Definition: m68k.py:95
def copy_ctypes_list(src)
Definition: __init__.py:326