Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
miasm2.arch.msp430.arch.instruction_msp430 Class Reference
+ Inheritance diagram for miasm2.arch.msp430.arch.instruction_msp430:
+ Collaboration diagram for miasm2.arch.msp430.arch.instruction_msp430:

Public Member Functions

def dstflow
 
def dstflow2label
 
def breakflow
 
def splitflow
 
def setdstflow
 
def is_subcall
 
def getdstflow
 
def get_symbol_size
 
def fixDstOffset
 
def get_info
 
def __str__
 
def get_args_expr
 
def gen_args
 
def get_asm_offset
 
def resolve_args_with_symbols
 

Static Public Member Functions

def arg2str
 

Public Attributes

 name
 
 mode
 
 args
 
 additional_info
 

Static Public Attributes

int delayslot = 0
 

Detailed Description

Definition at line 109 of file arch.py.

Member Function Documentation

def miasm2.arch.msp430.arch.instruction_msp430.__str__ (   self)

Definition at line 200 of file arch.py.

201  def __str__(self):
202  o = super(instruction_msp430, self).__str__()
203  return o
def miasm2.arch.msp430.arch.instruction_msp430.arg2str (   e,
  pos = None 
)
static

Definition at line 118 of file arch.py.

119  def arg2str(e, pos = None):
120  if isinstance(e, ExprId):
121  o = str(e)
122  elif isinstance(e, ExprInt):
123  o = str(e)
124  elif isinstance(e, ExprOp) and e.op == "autoinc":
125  o = "@%s+" % str(e.args[0])
126  elif isinstance(e, ExprMem):
127  if isinstance(e.arg, ExprId):
128  if pos == 0:
129  o = "@%s" % e.arg
130  else:
131  o = "0x0(%s)" % e.arg
132  elif isinstance(e.arg, ExprInt):
133  o = "@%s" % e.arg
134  elif isinstance(e.arg, ExprOp):
135  o = "%s(%s)" % (e.arg.args[1], e.arg.args[0])
136  else:
137  raise NotImplementedError('unknown instance e = %s' % type(e))
138  return o
139 

+ Here is the caller graph for this function:

def miasm2.arch.msp430.arch.instruction_msp430.breakflow (   self)

Definition at line 153 of file arch.py.

154  def breakflow(self):
155  if self.name in conditional_branch + unconditional_branch:
156  return True
157  if self.name.startswith('ret'):
158  return True
159  if self.name.startswith('int'):
160  return True
161  if self.name.startswith('mov') and self.args[1] == PC:
162  return True
163  return self.name in ['call']
def miasm2.arch.msp430.arch.instruction_msp430.dstflow (   self)

Definition at line 112 of file arch.py.

113  def dstflow(self):
114  if self.name.startswith('j'):
115  return True
116  return self.name in ['call']
def miasm2.arch.msp430.arch.instruction_msp430.dstflow2label (   self,
  symbol_pool 
)

Definition at line 140 of file arch.py.

141  def dstflow2label(self, symbol_pool):
142  e = self.args[0]
143  if not isinstance(e, ExprInt):
144  return
145  if self.name == "call":
146  ad = e.arg
147  else:
148  ad = e.arg + int(self.offset)
149 
150  l = symbol_pool.getby_offset_create(ad)
151  s = ExprId(l, e.size)
152  self.args[0] = s
def miasm2.arch.msp430.arch.instruction_msp430.fixDstOffset (   self)

Definition at line 183 of file arch.py.

184  def fixDstOffset(self):
185  e = self.args[0]
186  if self.offset is None:
187  raise ValueError('symbol not resolved %s' % l)
188  if not isinstance(e, ExprInt):
189  # raise ValueError('dst must be int or label')
190  log.warning('dynamic dst %r', e)
191  return
192 
193  # Call argument is an absolute offset
194  # Other offsets are relative to instruction offset
195  if self.name != "call":
196  self.args[0] = ExprInt(int(e.arg) - self.offset, 16)
def miasm2.core.cpu.instruction.gen_args (   self,
  args 
)
inherited

Definition at line 920 of file cpu.py.

921  def gen_args(self, args):
922  out = ', '.join([str(x) for x in args])
923  return out

+ Here is the caller graph for this function:

def miasm2.arch.msp430.arch.instruction_msp430.get_args_expr (   self)

Definition at line 204 of file arch.py.

205  def get_args_expr(self):
206  args = []
207  for a in self.args:
208  args.append(a)
209  return args
210 
def miasm2.core.cpu.instruction.get_asm_offset (   self,
  expr 
)
inherited

Definition at line 935 of file cpu.py.

936  def get_asm_offset(self, expr):
937  return m2_expr.ExprInt_from(expr, self.offset)

+ Here is the caller graph for this function:

def miasm2.arch.msp430.arch.instruction_msp430.get_info (   self,
  c 
)

Definition at line 197 of file arch.py.

198  def get_info(self, c):
199  pass
def miasm2.arch.msp430.arch.instruction_msp430.get_symbol_size (   self,
  symbol,
  symbol_pool 
)

Definition at line 180 of file arch.py.

181  def get_symbol_size(self, symbol, symbol_pool):
182  return 16

+ Here is the caller graph for this function:

def miasm2.arch.msp430.arch.instruction_msp430.getdstflow (   self,
  symbol_pool 
)

Definition at line 177 of file arch.py.

178  def getdstflow(self, symbol_pool):
179  return [self.args[0]]

+ Here is the caller graph for this function:

def miasm2.arch.msp430.arch.instruction_msp430.is_subcall (   self)

Definition at line 174 of file arch.py.

175  def is_subcall(self):
176  return self.name in ['call']
def miasm2.core.cpu.instruction.resolve_args_with_symbols (   self,
  symbols = None 
)
inherited

Definition at line 938 of file cpu.py.

939  def resolve_args_with_symbols(self, symbols=None):
940  if symbols is None:
941  symbols = {}
942  args_out = []
943  for a in self.args:
944  e = a
945  # try to resolve symbols using symbols (0 for default value)
946  ids = m2_expr.get_expr_ids(e)
947  fixed_ids = {}
948  for x in ids:
949  if isinstance(x.name, asmbloc.asm_label):
950  name = x.name.name
951  # special symbol $
952  if name == '$':
953  fixed_ids[x] = self.get_asm_offset(x)
954  continue
955  if not name in symbols:
956  raise ValueError('unresolved symbol! %r' % x)
957  else:
958  name = x.name
959  if not name in symbols:
960  continue
961  if symbols[name].offset is None:
962  raise ValueError('The offset of label "%s" cannot be '
963  'determined' % name)
964  else:
965  size = x.size
966  if size is None:
967  default_size = self.get_symbol_size(x, symbols)
968  size = default_size
969  value = m2_expr.ExprInt(symbols[name].offset, size)
970  fixed_ids[x] = value
971  e = e.replace_expr(fixed_ids)
972  e = expr_simp(e)
973  args_out.append(e)
974  return args_out

+ Here is the call graph for this function:

def miasm2.arch.msp430.arch.instruction_msp430.setdstflow (   self,
  a 
)

Definition at line 171 of file arch.py.

172  def setdstflow(self, a):
173  return
def miasm2.arch.msp430.arch.instruction_msp430.splitflow (   self)

Definition at line 164 of file arch.py.

165  def splitflow(self):
166  if self.name in conditional_branch:
167  return True
168  if self.name in unconditional_branch:
169  return False
170  return self.name in ['call']

Member Data Documentation

miasm2.core.cpu.instruction.additional_info
inherited

Definition at line 918 of file cpu.py.

miasm2.core.cpu.instruction.args
inherited

Definition at line 917 of file cpu.py.

int miasm2.arch.msp430.arch.instruction_msp430.delayslot = 0
static

Definition at line 110 of file arch.py.

miasm2.core.cpu.instruction.mode
inherited

Definition at line 916 of file cpu.py.

miasm2.arch.msp430.arch.instruction_msp430.name

Definition at line 144 of file arch.py.


The documentation for this class was generated from the following file: