Package mars.mips.hardware
Class Coprocessor0
java.lang.Object
mars.mips.hardware.Coprocessor0
Represents Coprocessor 0. We will use only its interrupt/exception registers.
- Author:
- Pete Sanderson, August 2005
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Register[]
For returning the set of registers.static int
getValue
(int number) Returns the value of the register whose number is given.static void
reset()
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).
-
Field Details
-
BAD_V_ADDR
public static final int BAD_V_ADDR- See Also:
-
STATUS
public static final int STATUS- See Also:
-
CAUSE
public static final int CAUSE- See Also:
-
EPC
public static final int EPC- See Also:
-
EXL_BIT
public static final int EXL_BIT- See Also:
-
DEFAULT_STATUS_VALUE
public static final int DEFAULT_STATUS_VALUE- See Also:
-
-
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
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 (seeCoprocessor0
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 (seeCoprocessor0
for a list). In this case, should probably beExceptionCause.ADDRESS_FETCH
orExceptionCause.ADDRESS_STORE
.address
- The address that caused the exception.
-