Package envi :: Class Opcode
[hide private]
[frames] | no frames]

Class Opcode

source code

A universal representation for an opcode

Instance Methods [hide private]
 
__init__(self, va, opcode, mnem, prefixes, size, operands, iflags=0)
constructor for the basic Envi Opcode object.
source code
 
__ne__(self, op) source code
 
__eq__(self, op) source code
 
__hash__(self) source code
 
__repr__(self)
Over-ride this if you want to make arch specific repr.
source code
 
__len__(self) source code
 
isCall(self) source code
 
isReturn(self) source code
 
getTargets(self, emu=None)
Determines the targets of call/branch instructions.
source code
 
getBranches(self, emu=None)
Return a list of tuples.
source code
 
render(self, mcanv)
Render this opcode to the memory canvas passed in.
source code
 
getPrefixName(self)
Get the name of the prefixes associated with the specified architecture specific prefix bitmask.
source code
 
getOperValue(self, idx, emu=None) source code
 
getOperands(self) source code
Class Variables [hide private]
  prefix_names = []
Method Details [hide private]

__init__(self, va, opcode, mnem, prefixes, size, operands, iflags=0)
(Constructor)

source code 

constructor for the basic Envi Opcode object.  Arguments as follows:

opcode   - An architecture specific numerical value for the opcode
mnem     - A humon readable mnemonic for the opcode
prefixes - a bitmask of architecture specific instruction prefixes
size     - The size of the opcode in bytes
operands - A list of Operand objects for this opcode
iflags   - A list of Envi (architecture independant) instruction flags (see IF_FOO)
va       - The virtual address the instruction lives at (used for PC relative immediates etc...)

NOTE: If you want to create an architecture spcific opcode, I'd *highly* recommend you
      just copy/paste in the following simple initial code rather than calling the parent
      constructor.  The extra

getTargets(self, emu=None)

source code 

Determines the targets of call/branch instructions. Fall throughs are not considered as targets. Deref branches are resolved.

Returns ((bva, bflags),...)

addr can be None in cases where the branch target cannot be computed. (for example, if BR_DEREF flag is set and cannot read the memory) Once resolved, the BR_DEREF flag is removed from branch flags.

getBranches(self, emu=None)

source code 

Return a list of tuples. Each tuple contains the target VA of the branch, and a possible set of flags showing what type of branch it is.

See the BR_FOO types for all the supported envi branch flags.... Example: for bva,bflags in op.getBranches():

render(self, mcanv)

source code 

Render this opcode to the memory canvas passed in. This is used for both simple printing AND more complex representations.