Class Register

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

public class Register extends Observable
Abstraction to represent a register of a MIPS Assembler.
Version:
June 2003
Author:
Jason Bumgarner, Jason Shrewsbury, Ben Sherman
  • Constructor Details

    • 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 initial (and reset) value of the register.
  • Method Details

    • getName

      public String getName()
      Returns the name of the Register.
      Returns:
      The name of the Register.
    • getValue

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

      public int getValueNoNotify()
      Returns the value of the Register. Observers are not notified.
      Returns:
      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:
      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.