Class Datum

java.lang.Object
  extended by Asm
      extended by Datum

public class Datum
extends Asm

Datum represents a generic piece of data (a word or ascii directive).


Field Summary
static int ASCIIZ
          Constant for an ascii datum
static int SPACE
          Constant for an space datum
static int WORD
          Constant for a word datum
 
Fields inherited from class Asm
addr, lineNumber
 
Constructor Summary
Datum(int datumType, java.lang.String value, int lineNumber)
          Datum constructor.
 
Method Summary
 java.lang.String getAsciizString()
          Get the asciiz string (only applicable for ascii datum).
 int getSpaceSize()
          Gets space size as an integer for the datum (note: space size is only applicable for space directives) See the ISA description for a list of operations and their respective operands.
 boolean getWordFlag()
          Gets flag indicating whether word value is an immediate or label -- ultimately it needs to be converted to an int.
 java.lang.String getWordLabel()
          Gets word label (string) for the datum (note: word label is only applicable for word directives) See the ISA description for a list of operations and their respective operands.
 int getWordValue()
          Gets word value as an integer for the datum (note: word value is only applicable for word directives) See the ISA description for a list of operations and their respective operands.
static boolean isAscii(java.lang.String directive)
          Checks if directive is an ascii datum
 boolean isAsciiz()
          Returns whether datum is an asciiz datum
 boolean isSpace()
          Returns whether datum is a space datum
static boolean isSpace(java.lang.String directive)
          Checks if directive is a space datum
 boolean isWord()
          Returns whether datum is a word datum
static boolean isWord(java.lang.String directive)
          Checks if directive is a word datum
 void setWordValue(int wordValue)
          Sets the word value.
 
Methods inherited from class Asm
getAddr, getLineNumber, setAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORD

public static final int WORD
Constant for a word datum

See Also:
Constant Field Values

ASCIIZ

public static final int ASCIIZ
Constant for an ascii datum

See Also:
Constant Field Values

SPACE

public static final int SPACE
Constant for an space datum

See Also:
Constant Field Values
Constructor Detail

Datum

public Datum(int datumType,
             java.lang.String value,
             int lineNumber)
Datum constructor.

Parameters:
datumType - type of datum (0 for word, 1 for asciiz, 2 for space).
value - value of datum (as a string).
lineNumber - line number of datum.
Method Detail

getWordFlag

public boolean getWordFlag()
Gets flag indicating whether word value is an immediate or label -- ultimately it needs to be converted to an int. (note: word value is only applicable for word directives) See the ISA description for a list of operations and their respective operands.

Returns:
flag indicating whether word value is represented as immediate (true) of label (false)

getWordValue

public int getWordValue()
Gets word value as an integer for the datum (note: word value is only applicable for word directives) See the ISA description for a list of operations and their respective operands.

Returns:
word value as an integer

getWordLabel

public java.lang.String getWordLabel()
Gets word label (string) for the datum (note: word label is only applicable for word directives) See the ISA description for a list of operations and their respective operands.

Returns:
word label

setWordValue

public void setWordValue(int wordValue)
Sets the word value. Note: this has to be done for all word directives that use labels

Parameters:
wordValue - word value as an integer

getAsciizString

public java.lang.String getAsciizString()
Get the asciiz string (only applicable for ascii datum).

Returns:
asciiz string

getSpaceSize

public int getSpaceSize()
Gets space size as an integer for the datum (note: space size is only applicable for space directives) See the ISA description for a list of operations and their respective operands.

Returns:
space size as an integer

isWord

public static boolean isWord(java.lang.String directive)
Checks if directive is a word datum

Parameters:
directive - string to check
Returns:
boolean indicating whether directive is a word datum

isWord

public boolean isWord()
Returns whether datum is a word datum

Returns:
boolean indicating whether directive is a word datum

isAscii

public static boolean isAscii(java.lang.String directive)
Checks if directive is an ascii datum

Parameters:
directive - string to check
Returns:
boolean indicating whether directive is an ascii datum

isAsciiz

public boolean isAsciiz()
Returns whether datum is an asciiz datum

Returns:
boolean indicating whether directive is an asciiz datum

isSpace

public static boolean isSpace(java.lang.String directive)
Checks if directive is a space datum

Parameters:
directive - string to check
Returns:
boolean indicating whether directive is a spring datum

isSpace

public boolean isSpace()
Returns whether datum is a space datum

Returns:
boolean indicating whether directive is a space datum