Class InstructionSet

java.lang.Object
mars.mips.instructions.InstructionSet

public class InstructionSet extends Object
The list of Instruction objects, each of which represents a MIPS instruction. The instruction may either be basic (translates into binary machine code) or extended (translates into sequence of one or more basic instructions).
Author:
Pete Sanderson and Ken Vollmar, August 2003-5
  • Field Details

  • Constructor Details

    • InstructionSet

      public InstructionSet()
      Creates a new InstructionSet object.
  • Method Details

    • getAllInstructions

      public List<Instruction> getAllInstructions()
      Retrieve the current instruction set.
    • getBasicInstructions

      public List<BasicInstruction> getBasicInstructions()
    • getExtendedInstructions

      public List<ExtendedInstruction> getExtendedInstructions()
    • getAllMnemonics

      public Set<String> getAllMnemonics()
    • getDecoder

      public InstructionDecoder getDecoder()
    • addBasicInstruction

      public void addBasicInstruction(BasicInstruction instruction)
    • addExtendedInstruction

      public void addExtendedInstruction(ExtendedInstruction instruction)
    • populate

      public void populate()
      Adds all instructions to the set. A given extended instruction may have more than one Instruction object, depending on how many formats it can have.
    • loadBasicInstructions

      public void loadBasicInstructions()
    • loadExtendedInstructions

      public void loadExtendedInstructions()
    • matchBasicMnemonic

      public List<BasicInstruction> matchBasicMnemonic(String mnemonic)
      Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.
      Parameters:
      mnemonic - operator mnemonic (e.g. addi, sw)
      Returns:
      list of corresponding Instruction object(s), empty if none match.
    • matchExtendedMnemonic

      public List<ExtendedInstruction> matchExtendedMnemonic(String mnemonic)
      Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.
      Parameters:
      mnemonic - operator mnemonic (e.g. addi, sw)
      Returns:
      list of corresponding Instruction object(s), empty if none match.
    • matchMnemonic

      public List<Instruction> matchMnemonic(String mnemonic)
      Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.
      Parameters:
      mnemonic - operator mnemonic (e.g. addi, sw)
      Returns:
      list of corresponding Instruction object(s), empty if none match.
    • matchMnemonicPrefix

      public List<Instruction> matchMnemonicPrefix(String mnemonicPrefix)
      Given a string, will return the Instruction object(s) from the instruction set whose operator mnemonic prefix matches it. Case-insensitive. For example "s" will match "sw", "sh", "sb", etc.
      Parameters:
      mnemonicPrefix - a string
      Returns:
      list of matching Instruction object(s), empty if none match.
    • matchInstruction

      public static <T extends Instruction> T matchInstruction(List<T> mnemonicMatches, List<OperandType> givenTypes)
    • matchInstructionLoosely

      public static <T extends Instruction> T matchInstructionLoosely(List<T> mnemonicMatches, List<OperandType> givenTypes)