Package mars.mips.hardware
Class Processor
java.lang.Object
mars.mips.hardware.Processor
Represents the collection of MIPS registers.
- Author:
- Jason Bumgarner & Jason Shrewsbury, June 2003
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static 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
Get the Register object for program counter.static int
static Register
Get the Register object for program counter.static int
static Register
static int
static Register
static long
getPairValue
(int number) Gets a long representing the value stored in the given register as well as the next register.static int
Get the current program counter value.static Register
getRegister
(String name) Get the register object corresponding to a given name.static Register[]
Get the set of accessible registers, including pc, hi, and lo.static int
getValue
(int number) Returns the value of the register whose number is given.static void
incrementProgramCounter
(int fetchPC) 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.static void
initializeProgramCounter
(int value) Initialize the Program Counter.static void
reset()
Reset the values of all registers to their default values.static void
setDefaultProgramCounter
(int value) static int
setExecuteProgramCounter
(int value) static int
setHighOrder
(int value) static int
setLowOrder
(int value) static void
setPairValue
(int number, long value) Sets the value of the register pair given to the long value containing 64 bit pattern given.static int
setProgramCounter
(int value) Set the value of the program counter.static int
setValue
(int number, int value) Update the register value whose number is given, unless it is$zero
.
-
Field Details
-
ZERO_CONSTANT
public static final int ZERO_CONSTANT- See Also:
-
ASSEMBLER_TEMPORARY
public static final int ASSEMBLER_TEMPORARY- See Also:
-
VALUE_0
public static final int VALUE_0- See Also:
-
VALUE_1
public static final int VALUE_1- See Also:
-
ARGUMENT_0
public static final int ARGUMENT_0- See Also:
-
ARGUMENT_1
public static final int ARGUMENT_1- See Also:
-
ARGUMENT_2
public static final int ARGUMENT_2- See Also:
-
ARGUMENT_3
public static final int ARGUMENT_3- See Also:
-
TEMPORARY_0
public static final int TEMPORARY_0- See Also:
-
TEMPORARY_1
public static final int TEMPORARY_1- See Also:
-
TEMPORARY_2
public static final int TEMPORARY_2- See Also:
-
TEMPORARY_3
public static final int TEMPORARY_3- See Also:
-
TEMPORARY_4
public static final int TEMPORARY_4- See Also:
-
TEMPORARY_5
public static final int TEMPORARY_5- See Also:
-
TEMPORARY_6
public static final int TEMPORARY_6- See Also:
-
TEMPORARY_7
public static final int TEMPORARY_7- See Also:
-
SAVED_0
public static final int SAVED_0- See Also:
-
SAVED_1
public static final int SAVED_1- See Also:
-
SAVED_2
public static final int SAVED_2- See Also:
-
SAVED_3
public static final int SAVED_3- See Also:
-
SAVED_4
public static final int SAVED_4- See Also:
-
SAVED_5
public static final int SAVED_5- See Also:
-
SAVED_6
public static final int SAVED_6- See Also:
-
SAVED_7
public static final int SAVED_7- See Also:
-
TEMPORARY_8
public static final int TEMPORARY_8- See Also:
-
TEMPORARY_9
public static final int TEMPORARY_9- See Also:
-
KERNEL_0
public static final int KERNEL_0- See Also:
-
KERNEL_1
public static final int KERNEL_1- See Also:
-
GLOBAL_POINTER
public static final int GLOBAL_POINTER- See Also:
-
STACK_POINTER
public static final int STACK_POINTER- See Also:
-
FRAME_POINTER
public static final int FRAME_POINTER- See Also:
-
RETURN_ADDRESS
public static final int RETURN_ADDRESS- See Also:
-
HIGH_ORDER
public static final int HIGH_ORDER- See Also:
-
LOW_ORDER
public static final int LOW_ORDER- See Also:
-
PROGRAM_COUNTER
public static final int PROGRAM_COUNTER- See Also:
-
PROGRAM_COUNTER_EXECUTE
public static final int PROGRAM_COUNTER_EXECUTE- See Also:
-
-
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
Get the set of accessible registers, including pc, hi, and lo.- Returns:
- The set of registers.
-
getRegister
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
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
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
-
getLowOrder
public static int getLowOrder() -
setLowOrder
public static int setLowOrder(int value) -
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, usesetProgramCounter(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
Get the Register object for program counter. Use with caution.- Returns:
- The program counter 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.
-