avrora.util
Class Arithmetic

java.lang.Object
  extended byavrora.util.Arithmetic

public class Arithmetic
extends java.lang.Object

The Arithmetic class implements a set of useful methods that are used by the simulator and assembler for converting java types to various data types used by the machine.


Constructor Summary
Arithmetic()
           
 
Method Summary
static int bitCount(byte value)
           
static byte clearBit(byte val, int bit)
           
static boolean getBit(byte val, int bit)
           
static boolean getBit(int val, int bit)
           
static boolean getBit(long val, int bit)
           
static int getBitField(int value, int[] permutation)
          The getBitField() method reads a bit field from a value where the bits of the field are not consecutive or in order.
static int getBitField(int value, int lowbit, int length)
           
static int getBitRangeMask(int low, int high)
           
static int getInverseBitRangeMask(int low, int high)
           
static int getSingleBitMask(int bit)
           
static int getSingleInverseBitMask(int bit)
           
static byte high(int val)
           
static byte high(short val)
           
static void inc(long[] vals, int[] denom, int pos)
           
static byte low(int val)
           
static byte low(short val)
           
static int lowestBit(long value)
           
static long[] modulus(long val, int[] denom)
           
static long mult(long[] vals, int[] denom)
           
static byte reverseBits(byte value)
           
static byte setBit(byte val, int bit)
           
static byte setBit(byte val, int bit, boolean on)
           
static int setBit(int val, int bit, boolean on)
           
static long setBit(long val, int bit, boolean on)
           
static int signExtend(int value, int signbit)
           
static char ubyte(byte b1)
           
static char uhigh(char val)
           
static char uhigh(short val)
           
static char ulow(char val)
           
static char ulow(short val)
           
static char uword(byte b1, byte b2)
           
static short word(byte b1, byte b2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Arithmetic

public Arithmetic()
Method Detail

word

public static short word(byte b1,
                         byte b2)

uword

public static char uword(byte b1,
                         byte b2)

signExtend

public static int signExtend(int value,
                             int signbit)

ubyte

public static char ubyte(byte b1)

low

public static byte low(short val)

high

public static byte high(short val)

low

public static byte low(int val)

high

public static byte high(int val)

ulow

public static char ulow(char val)

uhigh

public static char uhigh(char val)

ulow

public static char ulow(short val)

uhigh

public static char uhigh(short val)

getBit

public static boolean getBit(byte val,
                             int bit)

getBit

public static boolean getBit(long val,
                             int bit)

getBit

public static boolean getBit(int val,
                             int bit)

setBit

public static byte setBit(byte val,
                          int bit)

setBit

public static byte setBit(byte val,
                          int bit,
                          boolean on)

setBit

public static int setBit(int val,
                         int bit,
                         boolean on)

setBit

public static long setBit(long val,
                          int bit,
                          boolean on)

clearBit

public static byte clearBit(byte val,
                            int bit)

lowestBit

public static int lowestBit(long value)

getBitField

public static int getBitField(int value,
                              int[] permutation)
The getBitField() method reads a bit field from a value where the bits of the field are not consecutive or in order. This method accepts an array of integers that denotes the permutation of the bit field within the given value from highest order bits to lowest order bits

Parameters:
value - the integer value to extract the bit field from
permutation - the permutation of the bits for which to extract the bit field from highest order bit to lowest order bit
Returns:
the integer value resulting from concatentating the bits: value[permutation[0]], value[permutation[1]], etc into a single integer value

getBitField

public static int getBitField(int value,
                              int lowbit,
                              int length)

reverseBits

public static byte reverseBits(byte value)

bitCount

public static int bitCount(byte value)

getSingleBitMask

public static int getSingleBitMask(int bit)

getSingleInverseBitMask

public static int getSingleInverseBitMask(int bit)

getBitRangeMask

public static int getBitRangeMask(int low,
                                  int high)

getInverseBitRangeMask

public static int getInverseBitRangeMask(int low,
                                         int high)

modulus

public static long[] modulus(long val,
                             int[] denom)

mult

public static long mult(long[] vals,
                        int[] denom)

inc

public static void inc(long[] vals,
                       int[] denom,
                       int pos)