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

Public Member Functions

def fromstring
 
def flen
 
def getmaxlen
 
def encode
 
def decode
 
def clone
 
def __hash__
 

Public Attributes

 expr
 
 l
 
 value
 
 flen
 
 parent
 
 strbits
 
 cls
 
 fname
 
 order
 
 lmask
 
 fbits
 
 fmask
 
 kargs
 

Static Public Attributes

 parser = int_or_expr
 
int max_size = 32
 
int ll = 2
 

Detailed Description

Definition at line 2558 of file arch.py.

Member Function Documentation

def miasm2.core.cpu.bsi.__hash__ (   self)
inherited

Definition at line 493 of file cpu.py.

494  def __hash__(self):
495  kargs = []
496  for k, v in self.kargs.items():
497  if isinstance(v, list):
498  v = tuple(v)
499  kargs.append((k, v))
500  l = [self.strbits, self.l, self.cls,
501  self.fname, self.order, self.lmask, self.fbits,
502  self.fmask, self.value] # + kargs
503 
504  return hash(tuple(l))
505 
def miasm2.core.cpu.bsi.clone (   self)
inherited

Definition at line 483 of file cpu.py.

484  def clone(self):
485  s = self.__class__(self.parent,
486  self.strbits, self.l, self.cls,
487  self.fname, self.order, self.lmask, self.fbits,
488  self.fmask, self.value, self.flen, **self.kargs)
489  s.__dict__.update(self.kargs)
490  if hasattr(self, 'expr'):
491  s.expr = self.expr
492  return s
def miasm2.arch.x86.arch.bs_cond_imm.decode (   self,
  v 
)

Definition at line 2656 of file arch.py.

2657  def decode(self, v):
2658  opmode = self.parent.v_opmode()
2659  v = swap_uint(self.l, v)
2660  self.value = v
2661  l_out = opmode
2662  if hasattr(self.parent, 'w8') and self.parent.w8.value == 0:
2663  l_out = 8
2664  v = sign_ext(v, self.l, l_out)
2665  self.expr = ExprInt(v, l_out)
2666  return True
2667 
def swap_uint
Definition: cpu.py:1578
def sign_ext
Definition: cpu.py:1602

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.bs_cond_imm.encode (   self)

Definition at line 2600 of file arch.py.

2601  def encode(self):
2602  if not isinstance(self.expr, ExprInt):
2603  raise StopIteration
2604  arg0_expr = self.parent.args[0].expr
2605  self.parent.rex_w.value = 0
2606  # special case for push
2607  if len(self.parent.args) == 1:
2608  v = int(self.expr.arg)
2609  l = self.parent.v_opmode()
2610  l = min(l, self.max_size)
2612  self.l = l
2613  mask = ((1 << self.l) - 1)
2614  if v != sign_ext(v & mask, self.l, l):
2615  raise StopIteration
2616  self.value = swap_uint(self.l, v & ((1 << self.l) - 1))
2617  yield True
2618  raise StopIteration
2619 
2620  # assume 2 args; use first arg to guess op size
2621  if arg0_expr.size == 64:
2622  self.parent.rex_w.value = 1
2623 
2624  l = self.parent.v_opmode()
2625  v = int(self.expr.arg)
2626  if arg0_expr.size == 8:
2627  if not hasattr(self.parent, 'w8'):
2628  raise StopIteration
2629  self.parent.w8.value = 0
2630  l = 8
2631  if hasattr(self.parent, 'se'):
2632  self.parent.se.value = 0
2633  elif hasattr(self.parent, 'se'):
2634  if hasattr(self.parent, 'w8'):
2635  self.parent.w8.value = 1
2636  # try to generate signed extended version
2637  if v == sign_ext(v & 0xFF, 8, arg0_expr.size):
2638  self.parent.se.value = 1
2639  self.l = 8
2640  self.value = v & 0xFF
2641  yield True
2642  self.parent.se.value = 0
2643  else:
2644  if hasattr(self.parent, 'w8'):
2645  self.parent.w8.value = 1
2646  if l == 64:
2647  self.l = self.getmaxlen()
2648  else:
2649  self.l = l
2650 
2651  mask = ((1 << self.l) - 1)
2652  if v != sign_ext(v & mask, self.l, l):
2653  raise StopIteration
2654  self.value = swap_uint(self.l, v & ((1 << self.l) - 1))
2655  yield True
def swap_uint
Definition: cpu.py:1578
def sign_ext
Definition: cpu.py:1602
def miasm2.arch.x86.arch.bs_cond_imm.flen (   cls,
  mode,
  v 
)

Definition at line 2587 of file arch.py.

2588  def flen(cls, mode, v):
2589  if 'w8' not in v or v['w8'] == 1:
2590  if 'se' in v and v['se'] == 1:
2591  return 8
2592  else:
2593  osize = v_opmode_info(mode, v['opmode'], v['rex_w'], 0)
2594  osize = min(osize, cls.max_size)
2595  return osize
2596  return 8

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.bs_cond_imm.fromstring (   self,
  s,
  parser_result = None 
)

Definition at line 2562 of file arch.py.

2563  def fromstring(self, s, parser_result=None):
2564  if parser_result:
2565  expr, start, stop = parser_result[self.parser]
2566  else:
2567  try:
2568  expr, start, stop = self.parser.scanString(s).next()
2569  except StopIteration:
2570  expr = None
2571  self.expr = expr
2572 
2573  if len(self.parent.args) > 1:
2574  l = self.parent.args[0].expr.size
2575  else:
2576  l = self.parent.v_opmode()
2577  if isinstance(self.expr, ExprInt):
2578  v = int(self.expr.arg)
2579  mask = ((1 << l) - 1)
2580  self.expr = ExprInt(v & mask, l)
2581 
2582  if self.expr is None:
2583  log.debug('cannot fromstring int %r', s)
2584  return None, None
2585  return start, stop
def miasm2.arch.x86.arch.bs_cond_imm.getmaxlen (   self)

Definition at line 2597 of file arch.py.

2598  def getmaxlen(self):
2599  return 32

Member Data Documentation

miasm2.core.cpu.bsi.cls
inherited

Definition at line 465 of file cpu.py.

miasm2.arch.x86.arch.bs_cond_imm.expr

Definition at line 2570 of file arch.py.

miasm2.core.cpu.bsi.fbits
inherited

Definition at line 469 of file cpu.py.

miasm2.core.cpu.bsi.flen
inherited

Definition at line 471 of file cpu.py.

miasm2.core.cpu.bsi.fmask
inherited

Definition at line 470 of file cpu.py.

miasm2.core.cpu.bsi.fname
inherited

Definition at line 466 of file cpu.py.

miasm2.core.cpu.bsi.kargs
inherited

Definition at line 473 of file cpu.py.

miasm2.arch.x86.arch.bs_cond_imm.l

Definition at line 2611 of file arch.py.

int miasm2.arch.x86.arch.bs_cond_scale.ll = 2
staticinherited

Definition at line 2475 of file arch.py.

miasm2.core.cpu.bsi.lmask
inherited

Definition at line 468 of file cpu.py.

int miasm2.arch.x86.arch.bs_cond_imm.max_size = 32
static

Definition at line 2560 of file arch.py.

miasm2.core.cpu.bsi.order
inherited

Definition at line 467 of file cpu.py.

miasm2.core.cpu.bsi.parent
inherited

Definition at line 462 of file cpu.py.

miasm2.arch.x86.arch.bs_cond_imm.parser = int_or_expr
static

Definition at line 2559 of file arch.py.

miasm2.core.cpu.bsi.strbits
inherited

Definition at line 463 of file cpu.py.

miasm2.arch.x86.arch.bs_cond_imm.value

Definition at line 2615 of file arch.py.


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