Interface IInsnEmulator<T extends IInstructionOperand>

Type Parameters:
T - operand type
All Known Implementing Classes:
InsnEmulator

public interface IInsnEmulator<T extends IInstructionOperand>
High Level design for an instruction emulator: it indicates if the PC is updated (meaning a jump will be done, see getBranchType() for jump type) and is able to compute the result of the operation. Please note that the compute(byte[], long, int, IInstructionOperand[], IMachineContext) implementation is not guaranteed, plus it can depends on context (register values, memory access).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Branch categories reported by an emulator.
  • Method Summary

    Modifier and Type
    Method
    Description
    compute(byte[] code, long instructionAddress, int mode, T[] armOperands, IMachineContext context)
    Compute the result of the instruction (ADD, SUB...).
    Return BranchType (JUMP or LINK).
    boolean
    Indicate if the instruction can update the PC (by another address than the following one).
  • Method Details

    • isPCUpdated

      boolean isPCUpdated()
      Indicate if the instruction can update the PC (by another address than the following one).
      Returns:
      true if the instruction may update the program counter
    • compute

      Long compute(byte[] code, long instructionAddress, int mode, T[] armOperands, IMachineContext context) throws ProcessorException
      Compute the result of the instruction (ADD, SUB...). When the context is not provided or has missing entries, this method will return null as result or raise a ProcessorException. If this operation is not implemented, an UnsupportedOperationException will be raised.
      Parameters:
      code - instruction bytes
      instructionAddress - instruction address
      mode - processor mode
      armOperands - instruction operands
      context - optional machine context
      Returns:
      computed result, or null if it cannot be computed
      Throws:
      ProcessorException - if the result cannot be computed
    • getBranchType

      IInsnEmulator.BranchType getBranchType()
      Return BranchType (JUMP or LINK). See later if more is needed.
      Returns:
      branch type, or null if the instruction does not branch