|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.hu.cs.titokone.Interpreter
fi.hu.cs.titokone.SymbolicInterpreter
This class contains the bulk data needed to translate commands to opcodes etc. The main purpose for this class is to provide methods to convert symbolic commands to binary form.
Field Summary | |
private java.util.HashMap |
addressModes
This hashtable contains integer values for given addressingmodes. |
private java.util.HashMap |
opcodes
This hashtable contains the opcode values keyed to the symbolic commands. |
private java.util.HashMap |
registers
This hashtable |
Fields inherited from class fi.hu.cs.titokone.Interpreter |
ADDR, ADDR_LESS_FETCHES, addressFieldLength, addressingData, addressModeLength, commandData, FULL, FULL_LESS_FETCHES, NONE, opcodeLength, REG, REG_DEVICE, registerData, registerFieldLength, SP_ONLY, SP_REG, SVC |
Constructor Summary | |
SymbolicInterpreter()
This constructor sets up a SymbolicInterpreter instance. |
Method Summary | |
int |
binaryToInt(java.lang.String binaryValue,
boolean signIncluded)
This method converts String that contains a binary to int. |
private void |
dataSetup()
This method sets up the HashTables. |
int |
getAddressingMode(java.lang.String identifier)
This method transforms an addressing mode (=, @ or nothing) to a number identifying it. |
int |
getOpcode(java.lang.String command)
This method checks if a command is a valid opCode. |
int |
getRegisterId(java.lang.String registerName)
This method returns the binary form of a given register as an integer. |
java.lang.String |
intToBinary(long value,
int bits)
This method converts int values to binary-string. |
int |
stringToBinary(java.lang.String opcode,
java.lang.String firstRegister,
java.lang.String addressingMode,
java.lang.String address,
java.lang.String otherRegister)
This method coverts a complete command in a symbolic form to a binary form. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.util.HashMap opcodes
private java.util.HashMap addressModes
private java.util.HashMap registers
Constructor Detail |
public SymbolicInterpreter()
Method Detail |
private void dataSetup()
public int getOpcode(java.lang.String command)
command
- String form of a possible opCode.public int getAddressingMode(java.lang.String identifier)
identifier
- String form of an addressing mode.
public int getRegisterId(java.lang.String registerName)
registerName
- String form of a register (R0-R7, SP or FP).
public int stringToBinary(java.lang.String opcode, java.lang.String firstRegister, java.lang.String addressingMode, java.lang.String address, java.lang.String otherRegister)
opcode
- String form of an operation code. (STORE)firstRegister
- String form of a first register. (R0-R7, SP or FP)addressingMode
- = or @ or an empty string that representes the memory addressing
mode.address
- String form of an address, must be a valid int.otherRegister
- String form of an other register. (R0-R7, SP or FP)
public java.lang.String intToBinary(long value, int bits)
value
- Int value to be converted.bits
- How many bits can be used .
public int binaryToInt(java.lang.String binaryValue, boolean signIncluded)
binaryValue
- String representing the binary, if other than {0,1} then null.signIncluded
- Boolean value telling whether 11 is -1 or 3 i.e. will the leading
one be interpreted as sign-bit.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |