Class Reg16

java.lang.Object
  extended by Reg16

public final class Reg16
extends java.lang.Object

Implementation of an unsigned 16-bit integer type. Simulates a 16-bit register with operations modulo 2^16. 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 Reg16 HEX8000
          The value 0x8000.
static Reg16 HEXFFFF
          The value 0xFFFF.
static Reg16 TWO
          The value two.
static Reg16 ZERO
          The value zero.
 
Constructor Summary
Reg16()
           
Reg16(byte high, byte low)
           
Reg16(int x)
           
Reg16(Reg16 u16)
           
Reg16(Reg8 high, Reg8 low)
           
Reg16(java.lang.String strofhex)
           
 
Method Summary
 Reg16 add(Reg16 rhs)
           
 Reg16 and(Reg16 rhs)
           
 Reg16 decrement()
           
 boolean equals(java.lang.Object o)
           
 ByteArray exportbytes()
           
 Reg8 exportLSByte()
           
 Reg8 exportMSByte()
           
 int exportsigned()
           
static Reg16 factoryimportsigned(int x)
           
 boolean getbit(int offset)
           
 int getint()
           
 Reg2 getreg2(int offset)
           
 Reg3 getreg3(int offset)
           
 Reg4 getreg4(int offset)
           
 Reg5 getreg5(int offset)
           
 Reg8 getreg8(int offset)
           
 int hashCode()
           
 Reg16 increment()
           
 boolean iszero()
           
 boolean lessthan(Reg16 u16)
           
 Reg16 lshift1()
           
 boolean msb()
           
 Reg16 not()
           
 int numsigbits()
           
 Reg16 or(Reg16 rhs)
           
 Reg16 rshift1()
           
 Reg16 setbit(int offset, boolean v)
           
 Reg32 signextend()
           
 Reg16 subtract(Reg16 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.
 Reg16 xor(Reg16 rhs)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

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


TWO

public static final Reg16 TWO
The value two. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.


HEX8000

public static final Reg16 HEX8000
The value 0x8000. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.


HEXFFFF

public static final Reg16 HEXFFFF
The value 0xFFFF. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.

Constructor Detail

Reg16

public Reg16()

Reg16

public Reg16(java.lang.String strofhex)

Reg16

public Reg16(int x)

Reg16

public Reg16(Reg16 u16)

Reg16

public Reg16(Reg8 high,
             Reg8 low)

Reg16

public Reg16(byte high,
             byte low)
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

lessthan

public boolean lessthan(Reg16 u16)

msb

public boolean msb()

factoryimportsigned

public static Reg16 factoryimportsigned(int x)

exportsigned

public int exportsigned()

exportbytes

public ByteArray exportbytes()

exportMSByte

public Reg8 exportMSByte()

exportLSByte

public Reg8 exportLSByte()

xor

public Reg16 xor(Reg16 rhs)

and

public Reg16 and(Reg16 rhs)

rshift1

public Reg16 rshift1()

lshift1

public Reg16 lshift1()

or

public Reg16 or(Reg16 rhs)

not

public Reg16 not()

add

public Reg16 add(Reg16 rhs)

increment

public Reg16 increment()

decrement

public Reg16 decrement()

subtract

public Reg16 subtract(Reg16 rhs)

getbit

public boolean getbit(int offset)

setbit

public Reg16 setbit(int offset,
                    boolean v)

getreg2

public Reg2 getreg2(int offset)

getreg3

public Reg3 getreg3(int offset)

getreg4

public Reg4 getreg4(int offset)

getreg5

public Reg5 getreg5(int offset)

getreg8

public Reg8 getreg8(int offset)

getint

public int getint()

signextend

public Reg32 signextend()

numsigbits

public int numsigbits()

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