Class Instruction

java.lang.Object
mars.mips.instructions.Instruction
Direct Known Subclasses:
BasicInstruction, ExtendedInstruction

public abstract class Instruction extends Object
Base class to represent member of MIPS instruction set.
Version:
August 2003
Author:
Pete Sanderson and Ken Vollmar
  • Field Details

    • BYTES_PER_INSTRUCTION

      public static final int BYTES_PER_INSTRUCTION
      Length in bytes of a machine instruction.
      See Also:
    • INSTRUCTION_LENGTH_BITS

      public static final int INSTRUCTION_LENGTH_BITS
      See Also:
  • Constructor Details

  • Method Details

    • getMnemonic

      public String getMnemonic()
      Get operation mnemonic
      Returns:
      operation mnemonic (e.g. addi, sw)
    • getOperandTypes

      public List<OperandType> getOperandTypes()
    • getTitle

      public String getTitle()
    • getDescription

      public String getDescription()
      Get string describing the instruction. This is not used internally by MARS, but is for display to the user.
      Returns:
      String describing the instruction.
    • getExampleOperands

      public List<String> getExampleOperands()
    • getAlignedExampleSyntax

      public String getAlignedExampleSyntax()
    • getExampleSyntax

      public String getExampleSyntax()
    • getSizeBytes

      public abstract int getSizeBytes()
      Get length in bytes that this instruction requires in its binary form.
      Returns:
      int length in bytes of corresponding binary instruction(s).
    • acceptsOperands

      public boolean acceptsOperands(List<OperandType> givenTypes)
    • acceptsOperandsLoosely

      public boolean acceptsOperandsLoosely(List<OperandType> givenTypes)
    • formatSyntax

      public static String formatSyntax(String mnemonic, List<OperandType> operandTypes, List<String> operands, boolean align)
    • formatOperands

      public static String formatOperands(List<OperandType> operandTypes, List<String> operands)
    • generateExampleOperands

      public static List<String> generateExampleOperands(String mnemonic, List<OperandType> operandTypes)