Class Reg8

java.lang.Object
  extended by Reg8

public final class Reg8
extends java.lang.Object

Implementation of an unsigned 8-bit integer type. Simulates a 8-bit register with operations modulo 256. 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.


Field Summary
static Reg8 HEX80
          The value 0x80.
static Reg8 HEXFF
          The value 0xFF.
static Reg8 ZERO
          The value zero.
 
Constructor Summary
Reg8()
           
Reg8(byte b)
           
Reg8(int x)
           
Reg8(Reg8 x)
           
Reg8(java.lang.String strofhex)
           
 
Method Summary
 Reg8 add(int x)
           
 Reg8 add(Reg8 rhs)
           
 Reg8 and(Reg8 rhs)
           
 Reg8 decrement()
           
 boolean equals(java.lang.Object o)
           
 ByteArray exportbytes()
           
 int exportsigned()
           
 boolean getbit(int offset)
           
 int getint()
           
 int hashCode()
           
 Reg8 increment()
           
 boolean iszero()
           
 Reg8 lshift1()
           
 boolean msb()
           
 Reg8 not()
           
 Reg8 or(Reg8 rhs)
           
 Reg8 rshift1()
           
 Reg8 setbit(int offset, boolean v)
           
 Reg32 signextend()
           
 Reg16 signextend16()
           
 Reg8 subtract(Reg8 rhs)
           
 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.
 Reg8 xor(Reg8 rhs)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Reg8 ZERO
The value zero. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.


HEX80

public static final Reg8 HEX80
The value 0x80. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.


HEXFF

public static final Reg8 HEXFF
The value 0xFF. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.

Constructor Detail

Reg8

public Reg8()

Reg8

public Reg8(java.lang.String strofhex)

Reg8

public Reg8(int x)

Reg8

public Reg8(byte b)

Reg8

public Reg8(Reg8 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

msb

public boolean msb()

exportsigned

public int exportsigned()

exportbytes

public ByteArray exportbytes()

xor

public Reg8 xor(Reg8 rhs)

and

public Reg8 and(Reg8 rhs)

rshift1

public Reg8 rshift1()

lshift1

public Reg8 lshift1()

or

public Reg8 or(Reg8 rhs)

not

public Reg8 not()

add

public Reg8 add(Reg8 rhs)

add

public Reg8 add(int x)

increment

public Reg8 increment()

decrement

public Reg8 decrement()

subtract

public Reg8 subtract(Reg8 rhs)

getbit

public boolean getbit(int offset)

setbit

public Reg8 setbit(int offset,
                   boolean v)

getint

public int getint()

signextend16

public Reg16 signextend16()

signextend

public Reg32 signextend()

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