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 intNumber of bytes occupied by MIPS byte is 1.static intNumber of bytes occupied by MIPS character is 1.static intNumber of bytes occupied by MIPS double is 8.static intNumber of bytes occupied by MIPS float is 4.static intNumber of bytes occupied by MIPS halfword is 2.static doubleLargest magnitude negative value that can be stored in a MIPS double(negative of the max)static doubleLargest magnitude negative value that can be stored in a MIPS float (negative of the max)static intMaximum value that can be stored in a MIPS byte is 27-1static doubleMaximum positive finite value that can be stored in a MIPS double is same as Java Doublestatic doubleMaximum positive finite value that can be stored in a MIPS float is same as Java Floatstatic intMaximum value that can be stored in a MIPS halfword is 215-1static intMaximum value that can be stored in an unsigned MIPS halfword is 216-1static intMaximum value that can be stored in a MIPS word is 231-1static intLowest value that can be stored in a MIPS byte is -27static intLowest value that can be stored in a MIPS halfword is -215static intLowest value that can be stored in na unsigned MIPS halfword is 0static intLowest value that can be stored in a MIPS word is -231static intNumber of bytes occupied by MIPS word is 4. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetLengthInBytes(Directives direct)Get length in bytes for numeric MIPS directives.static booleanoutOfRange(Directives direct, double value)Determines whether given floating point value falls within value range for given directive.static booleanoutOfRange(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
trueif value can be stored in the number of bytes allowed by the given directive (.word, .half, .byte),falseotherwise.
-
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
trueif value is within range of the given directive (.float, .double),falseotherwise.
-