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.
Author:
Pete Sanderson, August 2005
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Register[]
    For returning the set of registers.
    static int
    getValue(int number)
    Returns the value of the register whose number is given.
    static void
    Method to reinitialize the values of the registers.
    static int
    updateRegister(int number, int value)
    This method updates the register value whose number is given.
    static void
    updateRegisters(int cause)
    Given MIPS exception cause code, place that code into coprocessor 0 CAUSE register ($13), set the EPC register ($14) to "current" program counter, and set Exception Level bit in STATUS register ($12).
    static void
    updateRegisters(int cause, int address)
    Given MIPS exception cause code and bad address, place the bad address into VADDR register ($8), place the cause code into the CAUSE register ($13), set the EPC register ($14) to "current" program counter, and set Exception Level bit in STATUS register ($12).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Coprocessor0

      public Coprocessor0()
  • Method Details

    • updateRegister

      public static int updateRegister(int number, int value)
      This method updates the register value whose number is given.
      Parameters:
      number - Number of register to set the value of.
      value - The desired value for the register.
      Returns:
      old value in register prior to update
    • 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. 0 for non-implemented registers
    • getRegisters

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

      public static void reset()
      Method to reinitialize the values of the registers.
    • updateRegisters

      public static void updateRegisters(int cause)
      Given MIPS exception cause code, place that code into coprocessor 0 CAUSE register ($13), set the EPC register ($14) to "current" program counter, and set Exception Level bit in STATUS register ($12).
      Parameters:
      cause - The cause code (see Coprocessor0 for a list)
    • updateRegisters

      public static void updateRegisters(int cause, int address)
      Given MIPS exception cause code and bad address, place the bad address into VADDR register ($8), place the cause code into the CAUSE register ($13), set the EPC register ($14) to "current" program counter, and set Exception Level bit in STATUS register ($12).
      Parameters:
      cause - The cause code (see Coprocessor0 for a list). In this case, should probably be ExceptionCause.ADDRESS_FETCH or ExceptionCause.ADDRESS_STORE.
      address - The address that caused the exception.