Package mars.mips.instructions
Class InstructionSet
java.lang.Object
mars.mips.instructions.InstructionSet
The list of Instruction objects, each of which represents a MIPS instruction.
The instruction may either be basic (translates into binary machine code) or
extended (translates into sequence of one or more basic instructions).
- Author:
- Pete Sanderson and Ken Vollmar, August 2003-5
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBasicInstruction
(BasicInstruction instruction) void
addExtendedInstruction
(ExtendedInstruction instruction) Retrieve the current instruction set.void
void
matchBasicMnemonic
(String mnemonic) Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.matchExtendedMnemonic
(String mnemonic) Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.static <T extends Instruction>
TmatchInstruction
(List<T> mnemonicMatches, List<OperandType> givenTypes) static <T extends Instruction>
TmatchInstructionLoosely
(List<T> mnemonicMatches, List<OperandType> givenTypes) matchMnemonic
(String mnemonic) Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.matchMnemonicPrefix
(String mnemonicPrefix) Given a string, will return the Instruction object(s) from the instruction set whose operator mnemonic prefix matches it.void
populate()
Adds all instructions to the set.
-
Field Details
-
EXTENDED_INSTRUCTIONS_PATH
- See Also:
-
-
Constructor Details
-
InstructionSet
public InstructionSet()Creates a new InstructionSet object.
-
-
Method Details
-
getAllInstructions
Retrieve the current instruction set. -
getBasicInstructions
-
getExtendedInstructions
-
getAllMnemonics
-
getDecoder
-
addBasicInstruction
-
addExtendedInstruction
-
populate
public void populate()Adds all instructions to the set. A given extended instruction may have more than one Instruction object, depending on how many formats it can have. -
loadBasicInstructions
public void loadBasicInstructions() -
loadExtendedInstructions
public void loadExtendedInstructions() -
matchBasicMnemonic
Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.- Parameters:
mnemonic
- operator mnemonic (e.g. addi, sw)- Returns:
- list of corresponding Instruction object(s), empty if none match.
-
matchExtendedMnemonic
Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.- Parameters:
mnemonic
- operator mnemonic (e.g. addi, sw)- Returns:
- list of corresponding Instruction object(s), empty if none match.
-
matchMnemonic
Given an operator mnemonic, will return the corresponding Instruction object(s) from the instruction set.- Parameters:
mnemonic
- operator mnemonic (e.g. addi, sw)- Returns:
- list of corresponding Instruction object(s), empty if none match.
-
matchMnemonicPrefix
Given a string, will return the Instruction object(s) from the instruction set whose operator mnemonic prefix matches it. Case-insensitive. For example "s" will match "sw", "sh", "sb", etc.- Parameters:
mnemonicPrefix
- a string- Returns:
- list of matching Instruction object(s), empty if none match.
-
matchInstruction
public static <T extends Instruction> T matchInstruction(List<T> mnemonicMatches, List<OperandType> givenTypes) -
matchInstructionLoosely
public static <T extends Instruction> T matchInstructionLoosely(List<T> mnemonicMatches, List<OperandType> givenTypes)
-