## mars.assembler
Class Assembler

    java.lang.Object
      mars.assembler.Assembler

    public class Assembler

extends Object

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.

Author:
  Pete Sanderson

Constructor Summary
`Assembler()`

Method Summary
`ArrayList` `assemble(ArrayList tokenizedProgramFiles, boolean extendedAssemblerEnabled)` Parse and generate machine code for the given MIPS program.
`ArrayList` `assemble(ArrayList tokenizedProgramFiles, boolean extendedAssemblerEnabled, boolean warningsAreErrors)` Parse and generate machine code for the given MIPS program.
`ArrayList` `assemble(MIPSprogram p, boolean extendedAssemblerEnabled)` Parse and generate machine code for the given MIPS program.
`ArrayList` `assemble(MIPSprogram p, boolean extendedAssemblerEnabled, boolean warningsAreErrors)` Parse and generate machine code for the given MIPS program.
`ErrorList` `getErrorList()` Get list of assembler errors and warnings

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Assembler

    public Assembler()

Method Detail

### assemble

    public ArrayList assemble(MIPSprogram p,
                              boolean extendedAssemblerEnabled)
                       throws ProcessingException

  Parse 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 assemble(MIPSprogram p,
                              boolean extendedAssemblerEnabled,
                              boolean warningsAreErrors)
                       throws ProcessingException

  Parse 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

    public ErrorList getErrorList()

  Get list of assembler errors and warnings

  Returns:
    ErrorList of any assembler errors and warnings.

### assemble

    public ArrayList assemble(ArrayList tokenizedProgramFiles,
                              boolean extendedAssemblerEnabled)
                       throws ProcessingException

  Parse 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 assemble(ArrayList tokenizedProgramFiles,
                              boolean extendedAssemblerEnabled,
                              boolean warningsAreErrors)
                       throws ProcessingException

  Parse 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`