mars.assembler
Class DataTypes

java.lang.Object
  extended by mars.assembler.DataTypes

public final class DataTypes
extends Object

Information about MIPS data types.

Author:
Pete Sanderson

Field Summary
static int BYTE_SIZE
          Number of bytes occupied by MIPS byte is 1.
static int CHAR_SIZE
          Number of bytes occupied by MIPS character is 1.
static int DOUBLE_SIZE
          Number of bytes occupied by MIPS double is 8.
static int FLOAT_SIZE
          Number of bytes occupied by MIPS float is 4.
static int HALF_SIZE
          Number of bytes occupied by MIPS halfword is 2.
static double LOW_DOUBLE_VALUE
          Largest magnitude negative value that can be stored in a MIPS double(negative of the max)
static double LOW_FLOAT_VALUE
          Largest magnitude negative value that can be stored in a MIPS float (negative of the max)
static int MAX_BYTE_VALUE
          Maximum value that can be stored in a MIPS byte is 27-1
static double MAX_DOUBLE_VALUE
          Maximum positive finite value that can be stored in a MIPS double is same as Java Double
static double MAX_FLOAT_VALUE
          Maximum positive finite value that can be stored in a MIPS float is same as Java Float
static int MAX_HALF_VALUE
          Maximum value that can be stored in a MIPS halfword is 215-1
static int MAX_UHALF_VALUE
          Maximum value that can be stored in an unsigned MIPS halfword is 216-1
static int MAX_WORD_VALUE
          Maximum value that can be stored in a MIPS word is 231-1
static int MIN_BYTE_VALUE
          Lowest value that can be stored in a MIPS byte is -27
static int MIN_HALF_VALUE
          Lowest value that can be stored in a MIPS halfword is -215
static int MIN_UHALF_VALUE
          Lowest value that can be stored in na unsigned MIPS halfword is 0
static int MIN_WORD_VALUE
          Lowest value that can be stored in a MIPS word is -231
static int WORD_SIZE
          Number of bytes occupied by MIPS word is 4.
 
Constructor Summary
DataTypes()
           
 
Method Summary
static int getLengthInBytes(Directives direct)
          Get length in bytes for numeric MIPS directives.
static boolean outOfRange(Directives direct, double value)
          Determines whether given floating point value falls within value range for given directive.
static boolean outOfRange(Directives direct, int value)
          Determines whether given integer value falls within value range for given directive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOUBLE_SIZE

public static final int DOUBLE_SIZE
Number of bytes occupied by MIPS double is 8.

See Also:
Constant Field Values

FLOAT_SIZE

public static final int FLOAT_SIZE
Number of bytes occupied by MIPS float is 4.

See Also:
Constant Field Values

WORD_SIZE

public static final int WORD_SIZE
Number of bytes occupied by MIPS word is 4.

See Also:
Constant Field Values

HALF_SIZE

public static final int HALF_SIZE
Number of bytes occupied by MIPS halfword is 2.

See Also:
Constant Field Values

BYTE_SIZE

public static final int BYTE_SIZE
Number of bytes occupied by MIPS byte is 1.

See Also:
Constant Field Values

CHAR_SIZE

public static final int CHAR_SIZE
Number of bytes occupied by MIPS character is 1.

See Also:
Constant Field Values

MAX_WORD_VALUE

public static final int MAX_WORD_VALUE
Maximum value that can be stored in a MIPS word is 231-1

See Also:
Constant Field Values

MIN_WORD_VALUE

public static final int MIN_WORD_VALUE
Lowest value that can be stored in a MIPS word is -231

See Also:
Constant Field Values

MAX_HALF_VALUE

public static final int MAX_HALF_VALUE
Maximum value that can be stored in a MIPS halfword is 215-1

See Also:
Constant Field Values

MIN_HALF_VALUE

public static final int MIN_HALF_VALUE
Lowest value that can be stored in a MIPS halfword is -215

See Also:
Constant Field Values

MAX_UHALF_VALUE

public static final int MAX_UHALF_VALUE
Maximum value that can be stored in an unsigned MIPS halfword is 216-1

See Also:
Constant Field Values

MIN_UHALF_VALUE

public static final int MIN_UHALF_VALUE
Lowest value that can be stored in na unsigned MIPS halfword is 0

See Also:
Constant Field Values

MAX_BYTE_VALUE

public static final int MAX_BYTE_VALUE
Maximum value that can be stored in a MIPS byte is 27-1

See Also:
Constant Field Values

MIN_BYTE_VALUE

public static final int MIN_BYTE_VALUE
Lowest value that can be stored in a MIPS byte is -27

See Also:
Constant Field Values

MAX_FLOAT_VALUE

public static final double MAX_FLOAT_VALUE
Maximum positive finite value that can be stored in a MIPS float is same as Java Float

See Also:
Constant Field Values

LOW_FLOAT_VALUE

public static final double LOW_FLOAT_VALUE
Largest magnitude negative value that can be stored in a MIPS float (negative of the max)

See Also:
Constant Field Values

MAX_DOUBLE_VALUE

public static final double MAX_DOUBLE_VALUE
Maximum positive finite value that can be stored in a MIPS double is same as Java Double

See Also:
Constant Field Values

LOW_DOUBLE_VALUE

public static final double LOW_DOUBLE_VALUE
Largest magnitude negative value that can be stored in a MIPS double(negative of the max)

See Also:
Constant Field Values
Constructor Detail

DataTypes

public DataTypes()
Method Detail

getLengthInBytes

public static int getLengthInBytes(Directives direct)
Get length in bytes for numeric MIPS directives.

Parameters:
direct - Directive to be measured.
Returns:
Returns length in bytes for values of that type. If type is not numeric (or not implemented yet), returns 0.

outOfRange

public static boolean outOfRange(Directives direct,
                                 int value)
Determines whether given integer value falls within value range for given directive.

Parameters:
direct - Directive that controls storage allocation for value.
value - The value to be stored.
Returns:
Returns true if value can be stored in the number of bytes allowed by the given directive (.word, .half, .byte), false otherwise.

outOfRange

public static boolean outOfRange(Directives direct,
                                 double value)
Determines whether given floating point value falls within value range for given directive. For float, this refers to range of the data type, not precision. Example: 1.23456789012345 be stored in a float with loss of precision. It's within the range. But 1.23e500 cannot be stored in a float because the exponent 500 is too large (float allows 8 bits for exponent).

Parameters:
direct - Directive that controls storage allocation for value.
value - The value to be stored.
Returns:
Returns true if value is within range of the given directive (.float, .double), false otherwise.