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.sh4.arch.instruction_sh4 Class Reference
+ Inheritance diagram for miasm2.arch.sh4.arch.instruction_sh4:
+ Collaboration diagram for miasm2.arch.sh4.arch.instruction_sh4:

Public Member Functions

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

Static Public Member Functions

def arg2str
 

Public Attributes

 name
 
 mode
 
 args
 
 additional_info
 

Static Public Attributes

int delayslot = 0
 

Detailed Description

Definition at line 388 of file arch.py.

Constructor & Destructor Documentation

def miasm2.arch.sh4.arch.instruction_sh4.__init__ (   self,
  args,
  kargs 
)

Definition at line 391 of file arch.py.

392  def __init__(self, *args, **kargs):
393  super(instruction_sh4, self).__init__(*args, **kargs)

Member Function Documentation

def miasm2.core.cpu.instruction.__str__ (   self)
inherited

Definition at line 924 of file cpu.py.

925  def __str__(self):
926  o = "%-10s " % self.name
927  args = []
928  for i, arg in enumerate(self.args):
929  if not isinstance(arg, m2_expr.Expr):
930  raise ValueError('zarb arg type')
931  x = self.arg2str(arg, pos = i)
932  args.append(x)
933  o += self.gen_args(args)
934  return o

+ Here is the call graph for this function:

def miasm2.arch.sh4.arch.instruction_sh4.arg2str (   e,
  pos = None 
)
static

Definition at line 398 of file arch.py.

399  def arg2str(e, pos = None):
400  if isinstance(e, ExprId) or isinstance(e, ExprInt):
401  return str(e)
402  assert(isinstance(e, ExprMem))
403  e = e.arg
404 
405  if isinstance(e, ExprOp):
406  if e.op == "predec":
407  s = '-%s' % e.args[0]
408  elif e.op == "postinc":
409  s = '%s+' % e.args[0]
410  else:
411  s = ','.join([str(x).replace('(', '').replace(')', '')
412  for x in e.args])
413  s = "(%s)"%s
414  s = "@%s" % s
415  elif isinstance(e, ExprId):
416  s = "@%s" % e
417  else:
418  raise NotImplementedError('zarb arg2str')
419  return s
420 

+ Here is the caller graph for this function:

def miasm2.arch.sh4.arch.instruction_sh4.breakflow (   self)

Definition at line 435 of file arch.py.

436  def breakflow(self):
437  if self.name.startswith('J'):
438  return True
439  return False
def miasm2.arch.sh4.arch.instruction_sh4.dstflow (   self)

Definition at line 394 of file arch.py.

395  def dstflow(self):
396  return self.name.startswith('J')
def miasm2.arch.sh4.arch.instruction_sh4.fixDstOffset (   self)

Definition at line 452 of file arch.py.

453  def fixDstOffset(self):
454  e = self.args[0]
455  if self.offset is None:
456  raise ValueError('symbol not resolved %s' % l)
457  if not isinstance(e, ExprInt):
458  log.debug('dyn dst %r', e)
459  return
460  off = e.arg - (self.offset + 4 + self.l)
461  print hex(off)
462  if int(off % 4):
463  raise ValueError('strange offset! %r' % off)
464  self.args[0] = ExprInt32(off)
465  print 'final', self.args[0]

+ Here is the call graph for this function:

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.sh4.arch.instruction_sh4.get_args_expr (   self)

Definition at line 466 of file arch.py.

467  def get_args_expr(self):
468  args = [a for a in self.args]
469  return args
470 
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.core.cpu.instruction.get_info (   self,
  c 
)
inherited

Definition at line 975 of file cpu.py.

976  def get_info(self, c):
977  return
978 
def miasm2.arch.sh4.arch.instruction_sh4.get_symbol_size (   self,
  symbol,
  symbol_pool 
)

Definition at line 449 of file arch.py.

450  def get_symbol_size(self, symbol, symbol_pool):
451  return 32

+ Here is the caller graph for this function:

def miasm2.arch.sh4.arch.instruction_sh4.getdstflow (   self,
  symbol_pool 
)

Definition at line 443 of file arch.py.

444  def getdstflow(self, symbol_pool):
445  return [self.args[0]]

+ Here is the caller graph for this function:

def miasm2.arch.sh4.arch.instruction_sh4.is_subcall (   self)

Definition at line 440 of file arch.py.

441  def is_subcall(self):
442  return self.name == 'JSR'
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.sh4.arch.instruction_sh4.splitflow (   self)

Definition at line 446 of file arch.py.

447  def splitflow(self):
448  return self.name == 'JSR'

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.sh4.arch.instruction_sh4.delayslot = 0
static

Definition at line 389 of file arch.py.

miasm2.core.cpu.instruction.mode
inherited

Definition at line 916 of file cpu.py.

miasm2.arch.sh4.arch.instruction_sh4.name

Definition at line 441 of file arch.py.


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