Class Reg5

java.lang.Object
  extended by Reg5

public final class Reg5
extends java.lang.Object

Implementation of an unsigned 5-bit integer type. Simulates a 5-bit register with operations modulo 32. The class follows Joshua Bloch's advice in his Item 15: minimize mutability. Joshua suggesets that one always make small value objects immutable. So, this class is immutable.

The EXG instruction has a field that is 5 bits wide.


Constructor Summary
Reg5(int x)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 int getint()
           
 int hashCode()
           
 boolean iszero()
           
 java.lang.String toHexString()
          Prints out the value of this object in hexadecimal.
 java.lang.String toString()
          Prints out the value of this object in hexadecimal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Reg5

public Reg5(int x)
Method Detail

iszero

public boolean iszero()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getint

public int getint()

toHexString

public java.lang.String toHexString()
Prints out the value of this object in hexadecimal. This member function was created since it is more descriptive than "toString" by explaining the base (hexadecimal) that is used in the representation.


toString

public java.lang.String toString()
Prints out the value of this object in hexadecimal. This member function simply invokes toHexString().

Overrides:
toString in class java.lang.Object