mars.mips.hardware
Class Register

java.lang.Object
  extended by java.util.Observable
      extended by mars.mips.hardware.Register

public class Register
extends Observable

Abstraction to represent a register of a MIPS Assembler.

Author:
Jason Bumgarner, Jason Shrewsbury, Ben Sherman

Constructor Summary
Register(String n, int num, int val)
          Creates a new register with specified name, number, and value.
 
Method Summary
 void changeResetValue(int reset)
          Change the register's reset value; the value to which it will be set when resetValue() is called.
 String getName()
          Returns the name of the Register.
 int getNumber()
          Returns the number of the Register.
 int getResetValue()
          Returns the reset value of the Register.
 int getValue()
          Returns the value of the Register.
 int getValueNoNotify()
          Returns the value of the Register.
 void resetValue()
          Resets the value of the register to the value it was constructed with.
 int setValue(int val)
          Sets the value of the register to the val passed to it.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Register

public Register(String n,
                int num,
                int val)
Creates a new register with specified name, number, and value.

Parameters:
n - The name of the register.
num - The number of the register.
val - The inital (and reset) value of the register.
Method Detail

getName

public String getName()
Returns the name of the Register.

Returns:
name The name of the Register.

getValue

public int getValue()
Returns the value of the Register. Observers are notified of the READ operation.

Returns:
value The value of the Register.

getValueNoNotify

public int getValueNoNotify()
Returns the value of the Register. Observers are not notified. Added for release 3.8.

Returns:
value The value of the Register.

getResetValue

public int getResetValue()
Returns the reset value of the Register.

Returns:
The reset (initial) value of the Register.

getNumber

public int getNumber()
Returns the number of the Register.

Returns:
number The number of the Register.

setValue

public int setValue(int val)
Sets the value of the register to the val passed to it. Observers are notified of the WRITE operation.

Parameters:
val - Value to set the Register to.
Returns:
previous value of register

resetValue

public void resetValue()
Resets the value of the register to the value it was constructed with. Observers are not notified.


changeResetValue

public void changeResetValue(int reset)
Change the register's reset value; the value to which it will be set when resetValue() is called.