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

Public Member Functions

def decode
 
def encode
 
def fromstring
 

Public Attributes

 expr
 
 value
 

Static Public Attributes

 parser = deref
 

Detailed Description

Definition at line 1311 of file arch.py.

Member Function Documentation

def miasm2.arch.arm.arch.arm_immed.decode (   self,
  v 
)

Definition at line 1314 of file arch.py.

1315  def decode(self, v):
1316  if self.parent.immop.value == 1:
1317  imm = ExprInt32((self.parent.immedH.value << 4) | v)
1318  else:
1319  imm = gpregs.expr[v]
1320  if self.parent.updown.value == 0:
1321  imm = -imm
1322  if self.parent.ppi.value:
1323  e = ExprOp('preinc', self.parent.rn.expr, imm)
1324  else:
1325  e = ExprOp('postinc', self.parent.rn.expr, imm)
1326  if self.parent.wback.value == 1:
1327  e = ExprOp('wback', e)
1328  self.expr = ExprMem(e)
1329 
1330  return True

+ Here is the call graph for this function:

def miasm2.arch.arm.arch.arm_immed.encode (   self)

Definition at line 1331 of file arch.py.

1332  def encode(self):
1333  self.parent.immop.value = 1
1334  self.parent.updown.value = 1
1335  e = self.expr
1336  if not isinstance(e, ExprMem):
1337  return False
1338  e = e.arg
1339  if isinstance(e, ExprOp) and e.op == 'wback':
1340  self.parent.wback.value = 1
1341  e = e.args[0]
1342  else:
1343  self.parent.wback.value = 0
1344  if e.op == "postinc":
1345  self.parent.ppi.value = 0
1346  elif e.op == "preinc":
1347  self.parent.ppi.value = 1
1348  else:
1349  # XXX default
1350  self.parent.ppi.value = 1
1351  self.parent.rn.expr = e.args[0]
1352  if len(e.args) == 1:
1353  self.value = 0
1354  self.parent.immedH.value = 0
1355  return True
1356  e = e.args[1]
1357  if isinstance(e, ExprInt):
1358  v = int(e.arg)
1359  if v < 0 or v & (1 << 31):
1360  self.parent.updown.value = 0
1361  v = (-v) & 0xFFFFFFFF
1362  if v > 0xff:
1363  log.debug('cannot encode imm XXX')
1364  return False
1365  self.value = v & 0xF
1366  self.parent.immedH.value = v >> 4
1367  return True
1368 
1369  self.parent.immop.value = 0
1370  if isinstance(e, ExprOp) and len(e.args) == 1 and e.op == "-":
1371  self.parent.updown.value = 0
1372  e = e.args[0]
1373  if e in gpregs.expr:
1374  self.value = gpregs.expr.index(e)
1375  self.parent.immedH.value = 0x0
1376  return True
1377  else:
1378  raise ValueError('e should be int: %r' % e)
def miasm2.core.cpu.m_arg.fromstring (   self,
  s,
  parser_result = None 
)
inherited

Definition at line 604 of file cpu.py.

605  def fromstring(self, s, parser_result=None):
606  if parser_result:
607  e, start, stop = parser_result[self.parser]
608  self.expr = e
609  return start, stop
610  try:
611  v, start, stop = self.parser.scanString(s).next()
612  except StopIteration:
613  return None, None
614  self.expr = v[0]
615  return start, stop
616 

+ Here is the call graph for this function:

Member Data Documentation

miasm2.arch.arm.arch.arm_immed.expr

Definition at line 1327 of file arch.py.

miasm2.arch.arm.arch.arm_immed.parser = deref
static

Definition at line 1312 of file arch.py.

miasm2.arch.arm.arch.arm_immed.value

Definition at line 1352 of file arch.py.


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