Class AbstractInstruction<T extends IInstructionOperand>

java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.processor.AbstractInstruction<T>
All Implemented Interfaces:
IInstruction

@Ser public abstract class AbstractInstruction<T extends IInstructionOperand> extends Object implements IInstruction
A skeleton implementation for instructions.
  • Field Details

    • operands

      protected T extends IInstructionOperand[] operands
    • processorMode

      protected int processorMode
  • Constructor Details

    • AbstractInstruction

      public AbstractInstruction(BytesBlock code, String mnemonic, T[] operands, int processorMode)
  • Method Details

    • getSize

      public int getSize()
      Description copied from interface: IInstruction
      Get the instruction size in bytes.
      Specified by:
      getSize in interface IInstruction
      Returns:
      the instruction size
    • getCodeBlock

      public BytesBlock getCodeBlock()
    • getCode

      public byte[] getCode()
      Description copied from interface: IInstruction
      Get the binary code that makes up this instruction.
      Specified by:
      getCode in interface IInstruction
      Returns:
      an array of bytes, or null if the instruction is abstract
    • getCode

      public byte[] getCode(ByteOrder byteOrder)
    • getPrefix

      public String getPrefix()
      Description copied from interface: IInstruction
      Get the instruction's optional prefix(es).
      Specified by:
      getPrefix in interface IInstruction
      Returns:
      the prefix (or prefix string list), null if none
    • getMnemonic

      public String getMnemonic()
      Description copied from interface: IInstruction
      The instruction mnemonic.
      Specified by:
      getMnemonic in interface IInstruction
      Returns:
    • getOperands

      public T[] getOperands()
      Description copied from interface: IInstruction
      Get the list of operands for this instruction.
      Specified by:
      getOperands in interface IInstruction
      Returns:
      a list (possibly empty) of operands, or null if operands are not applicable to the instruction set
    • getOperand

      public T getOperand(int index)
      Description copied from interface: IInstruction
      Get an operand by index.
      Specified by:
      getOperand in interface IInstruction
      Returns:
    • getCountOfOperands

      public int getCountOfOperands()
      Specified by:
      getCountOfOperands in interface IInstruction
    • getProcessorMode

      public int getProcessorMode()
      Description copied from interface: IInstruction
      Get the mode the processor was in when it parsed and created this instruction. Refer to IProcessor MODE_xxx.
      Specified by:
      getProcessorMode in interface IInstruction
      Returns:
      the mode, 0 for none/default
    • buildNextEntryPoint

      protected CodePointer buildNextEntryPoint(long instructionAddress)
    • isBreakingFlow

      protected boolean isBreakingFlow(IInsnEmulator<T> emulator)
    • isRoutineCall

      protected boolean isRoutineCall(IInsnEmulator<T> emulator)
    • isJump

      protected boolean isJump(IInsnEmulator<T> emulator)
    • getInstructionFlags

      public Set<InstructionFlags> getInstructionFlags()
      Specified by:
      getInstructionFlags in interface IInstruction
      Returns:
      instruction flags, never null
    • format

      public String format(Object context)
      Description copied from interface: IInstruction
      Format the instruction for printing
      Specified by:
      format in interface IInstruction
      Parameters:
      context - optional context, used to provide a better representation of the instruction (for instance, resolving strings or method names.) The implementor should do its best to return a decent result even if context is null.
      Returns:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object