|
||||||||||
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.BinaryInterpreter
This class contains the information to translate a command in binary form to its symbolic string form. Naturally, if a command has been transformed from its symbolic form to binary, the transformation back will not restore used symbols as we cannot tell, even with the help of the symbol table, what symbol has been used where.
Field Summary | |
private java.util.HashMap |
commands
This hashmap contains the symbolic commands as strings, with Integer forms of their opcodes as keys. |
static java.lang.String |
GARBLE
|
private java.util.HashMap |
parameters
This hashmap contains parameters for each command with Integer forms of their opcodes as keys. |
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 | |
BinaryInterpreter()
This constructor sets up a binaryinterpreter and initializes the internal command information data structures. |
Method Summary | |
int |
binaryToInt(java.lang.String binaryValue,
boolean signIncluded)
This method converts String that contains a binary to int. |
java.lang.String |
binaryToString(int binaryCommand)
This function transforms a binary-form command to its symbolic representation. |
java.lang.String |
getAddressFromBinary(int binaryCommand)
If a given binary represents a valid command that has an address then this function returns it. |
java.lang.String |
getFirstRegisterFromBinary(int binaryCommand)
If a command has a first register value then this function returns it. |
java.lang.String |
getMemoryModeFromBinary(int binaryCommand)
Function returns possible memory address mode from a binary command given as a parameter. |
java.lang.String |
getOpCodeFromBinary(int binaryCommand)
This command returns the operation code from a binary |
java.lang.String |
getSecondRegisterFromBinary(int binaryCommand)
If a command has second register value, this function returns it "" or R0 to R7). |
java.lang.String |
intToBinary(long value,
int bits)
This method converts int values to binary-string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String GARBLE
private java.util.HashMap commands
private java.util.HashMap parameters
Constructor Detail |
public BinaryInterpreter()
Method Detail |
public java.lang.String binaryToString(int binaryCommand)
binaryCommand
- The command's binary-form representation.
public java.lang.String getOpCodeFromBinary(int binaryCommand)
binaryCommand
- The command's binary-form representation.
public java.lang.String getFirstRegisterFromBinary(int binaryCommand)
binaryCommand
- The command's binary-form representation.
public java.lang.String getMemoryModeFromBinary(int binaryCommand)
binaryCommand
- The command's binary-form representation.
public java.lang.String getSecondRegisterFromBinary(int binaryCommand)
binaryCommand
- The command's binary-form representation.
public java.lang.String getAddressFromBinary(int binaryCommand)
binaryCommand
- The command's binary-form representation.
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 |