Class Processor

java.lang.Object
mars.mips.hardware.Processor

public class Processor extends Object
Represents the collection of MIPS registers.
Author:
Jason Bumgarner & Jason Shrewsbury, June 2003
  • Field Details

  • Constructor Details

    • Processor

      public Processor()
  • Method Details

    • setValue

      public static int setValue(int number, int value)
      Update the register value whose number is given, unless it is $zero. Also handles the internal pc, lo, and hi registers.
      Parameters:
      number - Register to set the value of.
      value - The desired value for the register.
      Returns:
      The previous value of the register.
    • getValue

      public static int getValue(int number)
      Returns the value of the register whose number is given.
      Parameters:
      number - The register number.
      Returns:
      The value of the given register.
    • getRegisters

      public static Register[] getRegisters()
      Get the set of accessible registers, including pc, hi, and lo.
      Returns:
      The set of registers.
    • getRegister

      public static Register getRegister(String name)
      Get the register object corresponding to a given name.
      Parameters:
      name - The register name, either in $0 or $zero format.
      Returns:
      The register object, or null if not found.
    • getPairValue

      public static long getPairValue(int number) throws InvalidRegisterAccessException
      Gets a long representing the value stored in the given register as well as the next register. The register must be even-numbered.
      Parameters:
      number - Register to get the value of. Must be even number of even/odd pair.
      Throws:
      InvalidRegisterAccessException - Thrown if register ID is invalid or odd-numbered.
    • setPairValue

      public static void setPairValue(int number, long value) throws InvalidRegisterAccessException
      Sets the value of the register pair given to the long value containing 64 bit pattern given. The register must be even-numbered, and the low order 32 bits from the long are placed in it. The high order 32 bits from the long are placed in the (odd numbered) register that follows it.
      Parameters:
      number - Register to set the value of. Must be even register of even/odd pair.
      value - The desired long value for the register.
      Throws:
      InvalidRegisterAccessException - Thrown if register ID is invalid or odd-numbered.
    • getHighOrder

      public static int getHighOrder()
    • setHighOrder

      public static int setHighOrder(int value)
    • getHighOrderRegister

      public static Register getHighOrderRegister()
    • getLowOrder

      public static int getLowOrder()
    • setLowOrder

      public static int setLowOrder(int value)
    • getLowOrderRegister

      public static Register getLowOrderRegister()
    • initializeProgramCounter

      public static void initializeProgramCounter(int value)
      Initialize the Program Counter. Do not use this to implement jumps and branches, as it will NOT record a backstep entry with the restore value. If you need backstepping capability, use setProgramCounter(int) instead.
      Parameters:
      value - The value to set the Program Counter to.
    • initializeProgramCounter

      public static void initializeProgramCounter(boolean startAtMain)
      Will initialize the Program Counter to either the default reset value, or the address associated with source program global label "main", if it exists as a text segment label and the global setting is set.
      Parameters:
      startAtMain - If true, will set program counter to address of statement labeled 'main' (or other defined start label) if defined. If not defined, or if parameter false, will set program counter to default reset value.
    • getProgramCounter

      public static int getProgramCounter()
      Get the current program counter value.
      Returns:
      The program counter value as an int.
    • setProgramCounter

      public static int setProgramCounter(int value)
      Set the value of the program counter.
      Parameters:
      value - The value to set the Program Counter to.
      Returns:
      The previous program counter value.
    • getExecuteProgramCounter

      public static int getExecuteProgramCounter()
    • setExecuteProgramCounter

      public static int setExecuteProgramCounter(int value)
    • setDefaultProgramCounter

      public static void setDefaultProgramCounter(int value)
    • incrementProgramCounter

      public static void incrementProgramCounter(int fetchPC)
    • getFetchPCRegister

      public static Register getFetchPCRegister()
      Get the Register object for program counter. Use with caution.
      Returns:
      The program counter register.
    • getExecutePCRegister

      public static Register getExecutePCRegister()
      Get the Register object for program counter. Use with caution.
      Returns:
      The program counter register.
    • reset

      public static void reset()
      Reset the values of all registers to their default values.