Package mars.mips.instructions
Class BasicInstruction
java.lang.Object
mars.mips.instructions.Instruction
mars.mips.instructions.BasicInstruction
Class to represent a basic instruction in the MIPS instruction set.
Basic instruction means it translates directly to a 32-bit binary machine
instruction.
- Version:
- August 2003
- Author:
- Pete Sanderson and Ken Vollmar
-
Field Summary
Fields inherited from class mars.mips.instructions.Instruction
INSTRUCTION_LENGTH, INSTRUCTION_LENGTH_BITS, operandMask
-
Constructor Summary
ConstructorsConstructorDescriptionBasicInstruction(String example, String description, BasicInstructionFormat instrFormat, String operMask, SimulationCode simCode)
BasicInstruction constructor.BasicInstruction(String example, BasicInstructionFormat instrFormat, String operMask, SimulationCode simCode)
-
Method Summary
Modifier and TypeMethodDescriptionGets the operand format of the instruction.int
int
Gets the 32-character operation mask.Gets the SimulationCode object.Methods inherited from class mars.mips.instructions.Instruction
getDescription, getExampleFormat, getInstructionLength, getName, getTokenList
-
Constructor Details
-
BasicInstruction
public BasicInstruction(String example, String description, BasicInstructionFormat instrFormat, String operMask, SimulationCode simCode)BasicInstruction constructor.- Parameters:
example
- An example usage of the instruction, as a String.instrFormat
- The format is R, I, I-branch or J.operMask
- The opcode mask is a 32 character string that contains the opcode in binary in the appropriate bit positions and codes for operand positions ('f', 's', 't') in the remaining positions.simCode
- The inline definition of an object and class which anonymously implements the SimulationCode interface.- See Also:
SimulationCode
-
BasicInstruction
public BasicInstruction(String example, BasicInstructionFormat instrFormat, String operMask, SimulationCode simCode)
-
-
Method Details
-
getOperationMask
Gets the 32-character operation mask. Each mask position represents a bit position in the 32-bit machine instruction. Operation codes and unused bits are represented in the mask by 1's and 0's. Operand codes are represented by 'f', 's', and 't' for bits occupied by first, secon and third operand, respectively.- Returns:
- The 32 bit mask, as a String
-
getInstructionFormat
Gets the operand format of the instruction. MIPS defines 3 of these R-format, I-format, and J-format. R-format is all registers. I-format is address formed from register base with immediate offset. J-format is for jump destination addresses. I have added one more: I-branch-format, for branch destination addresses. These are a variation of the I-format in that the computed value is address relative to the Program Counter. All four formats are represented by static objects.- Returns:
- The machine instruction format, R, I, J or I-branch.
-
getSimulationCode
Gets the SimulationCode object. It is really an object of an anonymous class that implements the SimulationCode interface. Such an object has but one method: Simulate().- Returns:
- the SimulationCode object for this instruction.
- See Also:
SimulationCode
-
getOpcodeMask
public int getOpcodeMask() -
getOpcodeMatch
public int getOpcodeMatch()
-