Class Coprocessor0

java.lang.Object
mars.mips.hardware.Coprocessor0

public class Coprocessor0 extends Object
Represents Coprocessor 0. We will use only its interrupt/exception registers.
Version:
August 2005
Author:
Pete Sanderson
  • Field Details

  • Constructor Details

    • Coprocessor0

      public Coprocessor0()
  • Method Details

    • showRegisters

      public static void showRegisters()
      Display the register values for debugging.
    • updateRegister

      public static int updateRegister(String n, int val)
      Sets the value of the register given to the value given.
      Parameters:
      n - name of register to set the value of ($n, where n is reg number).
      val - The desired value for the register.
      Returns:
      old value in register prior to update
    • updateRegister

      public static int updateRegister(int num, int val)
      Updates the register value whose number is num.
      Parameters:
      num - Number of register to set the value of.
      val - The desired value for the register.
      Returns:
      old value in register prior to update
    • getValue

      public static int getValue(int num)
      Returns the value of the register whose number is num.
      Parameters:
      num - The register number.
      Returns:
      The value of the given register. 0 for non-implemented registers
    • getNumber

      public static int getNumber(String n)
      For getting the number representation of the register.
      Parameters:
      n - The string formatted register name to look for.
      Returns:
      The number of the register represented by the string. -1 if no match.
    • getRegisters

      public static Register[] getRegisters()
      For returning the set of registers.
      Returns:
      The set of registers.
    • getRegisterPosition

      public static int getRegisterPosition(Register r)
      Coprocessor0 implements only selected registers, so the register number (8, 12, 13, 14) does not correspond to its position in the list of registers (0, 1, 2, 3).
      Parameters:
      r - A coprocessor0 Register
      Returns:
      the list position of given register, -1 if not found.
    • getRegister

      public static Register getRegister(String rname)
      Get register object corresponding to given name. If no match, return null.
      Parameters:
      rname - The register name, in $0 format.
      Returns:
      The register object,or null if not found.
    • resetRegisters

      public static void resetRegisters()
      Method to reinitialize the values of the registers.
    • addRegistersObserver

      public static void addRegistersObserver(Observer observer)
      Each individual register is a separate object and Observable. This handy method will add the given Observer to each one.
    • deleteRegistersObserver

      public static void deleteRegistersObserver(Observer observer)
      Each individual register is a separate object and Observable. This handy method will delete the given Observer from each one.