Next: SaM Reference Table
Up: Internal Simulator Classes
Previous: SaM Instructions
Contents
Index
- (CORE/SYMBOLTABLE.JAVA,
- CORE/SAMSYMBOLTABLE.JAVA)
A SaM program supports the use of labels, defined as a string ending
with ':', such as "ThisIsALabel:" Jump instructions
can then take the name of such a label, and jump to that address in
the program. The SaM Symbol Table is responsible for mapping labels
(symbols) to addresses, and vice versa. It is implemented by using
two hash tables, enabling a search using a symbol, or a search using
an address.
The SaM core package will support multiple labels per address. Unfortunately,
as of SaM 2.3, the GUI does not handle multiple stacked labels quite
properly, and simplifies them down to one. This is nontrivial to fix,
but will be corrected in a future release.
The symbol table provides the following methods:
- void add(String symbol, int address) - add a symbol with the specified
address
- String resolveSymbol(int address) - return the symbol for the given
address
- Collection<String> resolveSymbols(int address) -return all symbols
for the given address
- int resolveAddress(String label) - return the address for the given
symbol
- Collection<String> getSymbols() - return a collection of all symbols
- String toString() - return a string representation of this table
Next: SaM Reference Table
Up: Internal Simulator Classes
Previous: SaM Instructions
Contents
Index
David Levitan
2006-02-12