Package mars.assembler
Class DataTypes
java.lang.Object
mars.assembler.DataTypes
Information about MIPS data types.
- Version:
- August 2003
- Author:
- Pete Sanderson
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
Number of bytes occupied by MIPS byte is 1.static int
Number of bytes occupied by MIPS character is 1.static int
Number of bytes occupied by MIPS double is 8.static int
Number of bytes occupied by MIPS float is 4.static int
Number of bytes occupied by MIPS halfword is 2.static double
Largest magnitude negative value that can be stored in a MIPS double(negative of the max)static double
Largest magnitude negative value that can be stored in a MIPS float (negative of the max)static int
Maximum value that can be stored in a MIPS byte is 27-1static double
Maximum positive finite value that can be stored in a MIPS double is same as Java Doublestatic double
Maximum positive finite value that can be stored in a MIPS float is same as Java Floatstatic int
Maximum value that can be stored in a MIPS halfword is 215-1static int
Maximum value that can be stored in an unsigned MIPS halfword is 216-1static int
Maximum value that can be stored in a MIPS word is 231-1static int
Lowest value that can be stored in a MIPS byte is -27static int
Lowest value that can be stored in a MIPS halfword is -215static int
Lowest value that can be stored in na unsigned MIPS halfword is 0static int
Lowest value that can be stored in a MIPS word is -231static int
Number of bytes occupied by MIPS word is 4. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Field Details
-
DOUBLE_SIZE
public static final int DOUBLE_SIZENumber of bytes occupied by MIPS double is 8.- See Also:
- Constant Field Values
-
FLOAT_SIZE
public static final int FLOAT_SIZENumber of bytes occupied by MIPS float is 4.- See Also:
- Constant Field Values
-
WORD_SIZE
public static final int WORD_SIZENumber of bytes occupied by MIPS word is 4.- See Also:
- Constant Field Values
-
HALF_SIZE
public static final int HALF_SIZENumber of bytes occupied by MIPS halfword is 2.- See Also:
- Constant Field Values
-
BYTE_SIZE
public static final int BYTE_SIZENumber of bytes occupied by MIPS byte is 1.- See Also:
- Constant Field Values
-
CHAR_SIZE
public static final int CHAR_SIZENumber of bytes occupied by MIPS character is 1.- See Also:
- Constant Field Values
-
MAX_WORD_VALUE
public static final int MAX_WORD_VALUEMaximum 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_VALUELowest 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_VALUEMaximum 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_VALUELowest 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_VALUEMaximum 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_VALUELowest 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_VALUEMaximum 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_VALUELowest 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_VALUEMaximum 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_VALUELargest 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_VALUEMaximum 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_VALUELargest magnitude negative value that can be stored in a MIPS double(negative of the max)- See Also:
- Constant Field Values
-
-
Constructor Details
-
DataTypes
public DataTypes()
-
-
Method Details
-
getLengthInBytes
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
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
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.
-