Class Reg32

java.lang.Object
  extended by Reg32

public final class Reg32
extends java.lang.Object

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


Field Summary
static Reg32 HEX80000000
          The value 0x80000000L.
static Reg32 HEXFFFFFFFF
          The value 0xFFFFFFFFL.
static Reg32 ONE
          The value one.
static Reg32 ZERO
          The value zero.
 
Constructor Summary
Reg32()
           
Reg32(ByteArray in)
           
Reg32(long x)
           
Reg32(Reg16 high, Reg16 low)
           
Reg32(Reg32 x)
           
Reg32(java.lang.String strofhex)
           
 
Method Summary
 Reg32 add(long x)
           
 Reg32 add(Reg32 rhs)
           
 Reg32 add2()
           
 Reg32 add4()
           
 Reg32 and(Reg32 rhs)
           
 Reg32 decrement()
           
 boolean equals(java.lang.Object o)
           
 ByteArray exportbytes()
           
 Reg8 exportLSByte()
           
 Reg16 exportLSWord()
           
 Reg16 exportMSWord()
           
 long exportsigned()
           
static Reg32 factoryimportsigned(long x)
           
 boolean getbit(int offset)
           
 long getlong()
           
 int hashCode()
           
 Reg32 increment()
           
 boolean iseven()
           
 boolean isodd()
           
 boolean iszero()
           
 boolean lessthan(Reg32 u32)
           
 Reg32 lshift1()
           
 boolean msb()
           
 Reg32 not()
           
 int numsigbits()
           
 Reg32 or(Reg32 rhs)
           
 Reg32 rshift1()
           
 Reg32 setbit(int offset, boolean v)
           
 Reg32 setLSByte(Reg8 lsbyte)
           
 Reg32 setLSWord(Reg16 lsword)
           
 Reg32 sub2()
           
 Reg32 sub4()
           
 Reg32 subtract(long x)
           
 Reg32 subtract(Reg32 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.
 Reg32 xor(Reg32 rhs)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

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


ONE

public static final Reg32 ONE
The value one. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.


HEX80000000

public static final Reg32 HEX80000000
The value 0x80000000L. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.


HEXFFFFFFFF

public static final Reg32 HEXFFFFFFFF
The value 0xFFFFFFFFL. Joshua Bloch Item 15, p. 76 recommendation: public static final for immutable class constants.

Constructor Detail

Reg32

public Reg32()

Reg32

public Reg32(java.lang.String strofhex)

Reg32

public Reg32(long x)

Reg32

public Reg32(ByteArray in)

Reg32

public Reg32(Reg32 x)

Reg32

public Reg32(Reg16 high,
             Reg16 low)
Method Detail

setLSByte

public Reg32 setLSByte(Reg8 lsbyte)

setLSWord

public Reg32 setLSWord(Reg16 lsword)

isodd

public boolean isodd()

iseven

public boolean iseven()

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(Reg32 u32)

msb

public boolean msb()

exportLSByte

public Reg8 exportLSByte()

exportbytes

public ByteArray exportbytes()

exportMSWord

public Reg16 exportMSWord()

exportLSWord

public Reg16 exportLSWord()

factoryimportsigned

public static Reg32 factoryimportsigned(long x)

exportsigned

public long exportsigned()

xor

public Reg32 xor(Reg32 rhs)

and

public Reg32 and(Reg32 rhs)

lshift1

public Reg32 lshift1()

rshift1

public Reg32 rshift1()

or

public Reg32 or(Reg32 rhs)

not

public Reg32 not()

add

public Reg32 add(Reg32 rhs)

add

public Reg32 add(long x)

increment

public Reg32 increment()

add2

public Reg32 add2()

add4

public Reg32 add4()

decrement

public Reg32 decrement()

sub2

public Reg32 sub2()

sub4

public Reg32 sub4()

subtract

public Reg32 subtract(Reg32 rhs)

subtract

public Reg32 subtract(long x)

getbit

public boolean getbit(int offset)

setbit

public Reg32 setbit(int offset,
                    boolean v)

getlong

public long getlong()

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