mars.mips.instructions
Class BasicInstruction

java.lang.Object
  extended by mars.mips.instructions.Instruction
      extended by mars.mips.instructions.BasicInstruction

public class BasicInstruction
extends Instruction

Class to represent a basic instruction in the MIPS instruction set. Basic instruction means it translates directly to a 32-bit binary machine instruction.

Author:
Pete Sanderson and Ken Vollmar

Field Summary
 
Fields inherited from class mars.mips.instructions.Instruction
description, exampleFormat, INSTRUCTION_LENGTH, INSTRUCTION_LENGTH_BITS, mnemonic, operandMask, tokenList
 
Constructor Summary
BasicInstruction(String example, BasicInstructionFormat instrFormat, String operMask, SimulationCode simCode)
           
BasicInstruction(String example, String description, BasicInstructionFormat instrFormat, String operMask, SimulationCode simCode)
          BasicInstruction constructor.
 
Method Summary
 BasicInstructionFormat getInstructionFormat()
          Gets the operand format of the instruction.
 int getOpcodeMask()
           
 int getOpcodeMatch()
           
 String getOperationMask()
          Gets the 32-character operation mask.
 SimulationCode getSimulationCode()
          Gets the SimulationCode object.
 
Methods inherited from class mars.mips.instructions.Instruction
createExampleTokenList, extractOperator, getDescription, getExampleFormat, getInstructionLength, getName, getTokenList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 remainding 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 Detail

getOperationMask

public String 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

public BasicInstructionFormat 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

public SimulationCode 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()