Package mars.assembler
Class Assembler
java.lang.Object
mars.assembler.Assembler
An Assembler is capable of assembling a MIPS program. It has only one public
method,
assemble()
, which implements a two-pass assembler. It
translates MIPS source code into binary machine code.- Version:
- August 2003
- Author:
- Pete Sanderson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassemble(ArrayList<MIPSprogram> tokenizedProgramFiles, boolean extendedAssemblerEnabled)
Parse and generate machine code for the given MIPS program.assemble(ArrayList<MIPSprogram> tokenizedProgramFiles, boolean extendedAssemblerEnabled, boolean warningsAreErrors)
Parse and generate machine code for the given MIPS program.assemble(MIPSprogram p, boolean extendedAssemblerEnabled)
Parse and generate machine code for the given MIPS program.assemble(MIPSprogram p, boolean extendedAssemblerEnabled, boolean warningsAreErrors)
Parse and generate machine code for the given MIPS program.Get list of assembler errors and warnings
-
Constructor Details
-
Assembler
public Assembler()
-
-
Method Details
-
assemble
public ArrayList<ProgramStatement> assemble(MIPSprogram p, boolean extendedAssemblerEnabled) throws ProcessingExceptionParse and generate machine code for the given MIPS program. It must have already been tokenized. Warnings are not considered errors.- Parameters:
p
- A MIPSprogram object representing the program source.extendedAssemblerEnabled
- A boolean value that if true permits use of extended (pseudo) instructions in the source code. If false, these are flagged as errors.- Returns:
- An ArrayList representing the assembled program. Each member of the list is a ProgramStatement object containing the source, intermediate, and machine binary representations of a program statement.
- Throws:
ProcessingException
- See Also:
ProgramStatement
-
assemble
public ArrayList<ProgramStatement> assemble(MIPSprogram p, boolean extendedAssemblerEnabled, boolean warningsAreErrors) throws ProcessingExceptionParse and generate machine code for the given MIPS program. It must have already been tokenized.- Parameters:
p
- A MIPSprogram object representing the program source.extendedAssemblerEnabled
- A boolean value that if true permits use of extended (pseudo) instructions in the source code. If false, these are flagged as errors.warningsAreErrors
- A boolean value - true means assembler warnings will be considered errors and terminate the assemble; false means the assembler will produce warning message but otherwise ignore warnings.- Returns:
- An ArrayList representing the assembled program. Each member of the list is a ProgramStatement object containing the source, intermediate, and machine binary representations of a program statement.
- Throws:
ProcessingException
- See Also:
ProgramStatement
-
getErrorList
Get list of assembler errors and warnings- Returns:
- ErrorList of any assembler errors and warnings.
-
assemble
public ArrayList<ProgramStatement> assemble(ArrayList<MIPSprogram> tokenizedProgramFiles, boolean extendedAssemblerEnabled) throws ProcessingExceptionParse and generate machine code for the given MIPS program. All source files must have already been tokenized. Warnings will not be considered errors.- Parameters:
tokenizedProgramFiles
- An ArrayList of MIPSprogram objects, each produced from a different source code file, representing the program source.extendedAssemblerEnabled
- A boolean value that if true permits use of extended (pseudo) instructions in the source code. If false, these are flagged as errors.- Returns:
- An ArrayList representing the assembled program. Each member of the list is a ProgramStatement object containing the source, intermediate, and machine binary representations of a program statement. Returns null if incoming array list is null or empty.
- Throws:
ProcessingException
- See Also:
ProgramStatement
-
assemble
public ArrayList<ProgramStatement> assemble(ArrayList<MIPSprogram> tokenizedProgramFiles, boolean extendedAssemblerEnabled, boolean warningsAreErrors) throws ProcessingExceptionParse and generate machine code for the given MIPS program. All source files must have already been tokenized.- Parameters:
tokenizedProgramFiles
- An ArrayList of MIPSprogram objects, each produced from a different source code file, representing the program source.extendedAssemblerEnabled
- A boolean value that if true permits use of extended (pseudo) instructions in the source code. If false, these are flagged as errors.warningsAreErrors
- A boolean value - true means assembler warnings will be considered errors and terminate the assemble; false means the assembler will produce warning message but otherwise ignore warnings.- Returns:
- An ArrayList representing the assembled program. Each member of the list is a ProgramStatement object containing the source, intermediate, and machine binary representations of a program statement. Returns null if incoming array list is null or empty.
- Throws:
ProcessingException
- See Also:
ProgramStatement
-