Package ghidra.pcode.emu

# Class SleighInstructionDecoder

java.lang.Object
ghidra.pcode.emu.SleighInstructionDecoder

All Implemented Interfaces:
  `InstructionDecoder`

public class SleighInstructionDecoder extends Object implements InstructionDecoder
The default instruction decoder, based on Sleigh

This simply uses a `Disassembler` on the machine's memory state.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final AddressFactory`
  `addrFactory`
  `protected InstructionBlock`
  `block`
  `protected final Disassembler`
  `disassembler`
  `protected final Language`
  `language`
  `protected String`
  `lastMsg`
  `protected int`
  `lengthWithDelays`
  `protected final PcodeExecutorState<?>`
  `state`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SleighInstructionDecoder(Language language, PcodeExecutorState<?> state)`
  Construct a Sleigh instruction decoder

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `branched(Address address)`
  Inform the decoder that the emulator thread just branched
  `protected int`
  `computeLength()`
  Compute the "length" of an instruction, including any delay-slotted instructions that follow
  `Instruction`
  `decodeInstruction(Address address, RegisterValue context)`
  Decode the instruction starting at the given address using the given context
  `Instruction`
  `getLastInstruction()`
  Get the last instruction decoded
  `int`
  `getLastLengthWithDelays()`
  Get the length of the last decoded instruction, including delay slots

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### language

    protected final Language language

  - ### state

    protected final PcodeExecutorState<?> state

  - ### addrFactory

    protected final AddressFactory addrFactory

  - ### disassembler

    protected final Disassembler disassembler

  - ### lastMsg

    protected String lastMsg

  - ### block

    protected InstructionBlock block

  - ### lengthWithDelays

    protected int lengthWithDelays

- ## Constructor Details

  - ### SleighInstructionDecoder

    public SleighInstructionDecoder(Language language, PcodeExecutorState<?> state)
    Construct a Sleigh instruction decoder
    Parameters:
      `language` - the language to decoder
      `state` - the state containing the target program, probably the shared state of the p-code machine. It must be possible to obtain concrete buffers on this state.

- ## Method Details

  - ### decodeInstruction

    public Instruction decodeInstruction(Address address, RegisterValue context)
    Description copied from interface: `InstructionDecoder`
    Decode the instruction starting at the given address using the given context

    This method cannot return null. If a decode error occurs, it must throw an exception.

    Specified by:
      `decodeInstruction` in interface `InstructionDecoder`
    Parameters:
      `address` - the address to start decoding
      `context` - the disassembler/decode context
    Returns:
      the instruction

  - ### branched

    public void branched(Address address)
    Description copied from interface: `InstructionDecoder`
    Inform the decoder that the emulator thread just branched
    Specified by:
      `branched` in interface `InstructionDecoder`

  - ### computeLength

    protected int computeLength()
    Compute the "length" of an instruction, including any delay-slotted instructions that follow
    Returns:
      the length

  - ### getLastLengthWithDelays

    public int getLastLengthWithDelays()
    Description copied from interface: `InstructionDecoder`
    Get the length of the last decoded instruction, including delay slots
    Specified by:
      `getLastLengthWithDelays` in interface `InstructionDecoder`
    Returns:
      the length

  - ### getLastInstruction

    public Instruction getLastInstruction()
    Description copied from interface: `InstructionDecoder`
    Get the last instruction decoded
    Specified by:
      `getLastInstruction` in interface `InstructionDecoder`
    Returns:
      the instruction