Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## mars.mips.hardware
Class RegisterFile

    java.lang.Object
      mars.mips.hardware.RegisterFile

    public class RegisterFile

extends Object

Represents the collection of MIPS registers.

Author:
  Jason Bumgarner, Jason Shrewsbury

Field Summary
`static int` | `GLOBAL_POINTER_REGISTER`
`static int` | `STACK_POINTER_REGISTER`

Constructor Summary
`RegisterFile()`

Method Summary
`static void` | `addRegistersObserver(Observer observer)` Each individual register is a separate object and Observable.
`static void` | `deleteRegistersObserver(Observer observer)` Each individual register is a separate object and Observable.
`static int` | `getInitialProgramCounter()` For returning the program counter's initial (reset) value.
`static int` | `getNumber(String n)` For getting the number representation of the register.
`static int` | `getProgramCounter()` For returning the program counters value.
`static Register` | `getProgramCounterRegister()` Returns Register object for program counter.
`static Register[]` | `getRegisters()` For returning the set of registers.
`static Register` | `getUserRegister(String Rname)` Get register object corresponding to given name.
`static int` | `getValue(int num)` Returns the value of the register who's number is num.
`static void` | `incrementPC()` Method to increment the Program counter in the general case (not a jump or branch).
`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)` For initializing the Program Counter.
`static void` | `resetRegisters()` Method to reinitialize the values of the registers.
`static int` | `setProgramCounter(int value)` For setting the Program Counter.
`static void` | `showRegisters()` Method for displaying the register values for debugging.
`static int` | `updateRegister(int num, int val)` This method updates the register value who's number is num.
`static void` | `updateRegister(String reg, int val)` Sets the value of the register given to the value given.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### GLOBAL_POINTER_REGISTER

    public static final int GLOBAL_POINTER_REGISTER

See Also:
  Constant Field Values

### STACK_POINTER_REGISTER

    public static final int STACK_POINTER_REGISTER

See Also:
  Constant Field Values

Constructor Detail

### RegisterFile

    public RegisterFile()

Method Detail

### showRegisters

    public static void showRegisters()

  Method for displaying the register values for debugging.

### updateRegister

    public static int updateRegister(int num,
                                     int val)

  This method updates the register value who's number is num. Also handles the lo and hi registers

  Parameters:
    `num` - Register to set the value of.
    `val` - The desired value for the register.

### updateRegister

    public static void updateRegister(String reg,
                                      int val)

  Sets the value of the register given to the value given.

  Parameters:
    `reg` - Name of register to set the value of.
    `val` - The desired value for the register.

### getValue

    public static int getValue(int num)

  Returns the value of the register who's number is num.

  Parameters:
    `num` - The register number.
  Returns:
    The value of the given register.

### 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 or -1 if no match.

### getRegisters

    public static Register[] getRegisters()

  For returning the set of registers.

  Returns:
    The set of registers.

### getUserRegister

    public static Register getUserRegister(String Rname)

  Get register object corresponding to given name. If no match, return null.

  Parameters:
    `Rname` - The register name, either in $0 or $zero format.
  Returns:
    The register object,or null if not found.

### initializeProgramCounter

    public static void initializeProgramCounter(int value)

  For initializing 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 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.

### setProgramCounter

    public static int setProgramCounter(int value)

  For setting the Program Counter. Note that ordinary PC update should be done using incrementPC() method. Use this only when processing jumps and branches.

  Parameters:
    `value` - The value to set the Program Counter to.
  Returns:
    previous PC value

### getProgramCounter

    public static int getProgramCounter()

  For returning the program counters value.

  Returns:
    The program counters value as an int.

### getProgramCounterRegister

    public static Register getProgramCounterRegister()

  Returns Register object for program counter. Use with caution.

  Returns:
    program counter's Register object.

### getInitialProgramCounter

    public static int getInitialProgramCounter()

  For returning the program counter's initial (reset) value.

  Returns:
    The program counter's initial value

### resetRegisters

    public static void resetRegisters()

  Method to reinitialize the values of the registers. NOTE: Should not be called from command-mode MARS because this this method uses global settings from the registry. Command-mode must operate using only the command switches, not registry settings. It can be called from tools running stand-alone, and this is done in `AbstractMarsToolAndApplication`.

### incrementPC

    public static void incrementPC()

  Method to increment the Program counter in the general case (not a jump or branch).

### 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. Currently does not apply to Program Counter.

### 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. Currently does not apply to Program Counter.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD