Class SicStatement


public class SicStatement extends BaseStatement
The SicStatement class represents a SIC statement in an assembler. It extends the BaseStatement class and provides functionality for handling SIC-specific instructions and addressing modes.
  • Field Details

    • args

      protected String args
      args is the arguments of the given statement default value is "000"
    • xFlag

      protected boolean xFlag
      xFlag represents if an index is being used represented by ",X" at the end of args
  • Constructor Details

    • SicStatement

      public SicStatement()
      Constructs a new SicStatement object with default values. Initializes the arguments to "000", sets the format to 3, and updates the size based on the format.
    • SicStatement

      public SicStatement(HexNum location, HexNum opcode, String args)
      Constructs a SicStatement object with the specified location, opcode, and arguments.
      Parameters:
      location - the memory location of the statement as a HexNum object
      opcode - the operation code of the statement as a HexNum object
      args - the arguments for the statement as a String; if empty, defaults to "000"
  • Method Details

    • setArgs

      public void setArgs(String args)
      Sets the arguments for the SIC statement. If the provided arguments string are empty, the value of args will not change
      Parameters:
      args - the arguments to be set
    • assemble

      public String assemble()
      Assembles the SIC statement into its machine code representation. This method processes the arguments to determine the addressing mode and checks for the X flag. It then looks up the argument value in the symbol table or interprets it as a hexadecimal number. If the X flag is set, it adjusts the argument value to reflect indexed addressing.
      Specified by:
      assemble in class Statement
      Returns:
      A string representing the machine code of the SIC statement.
    • accept

      public void accept(VisitorInterface visitor)
      Accepts a visitor object that implements the VisitorInterface. This method allows the visitor to perform some operation on this SicStatement instance.
      Specified by:
      accept in class Statement
      Parameters:
      visitor - the visitor object that will visit this SicStatement instance