Package lab06

Class Program

java.lang.Object
lab06.Program

public class Program
extends java.lang.Object
Model a Pippin Program - a list of Pippin instructions.
Author:
cs140
  • Constructor Summary

    Constructors
    Constructor Description
    Program()
    Constructor - creates a new empty program (no instructions).
  • Method Summary

    Modifier and Type Method Description
    boolean add​(Instruction e)
    Adds a new instruction to the program.
    void clear()
    Remove all instructions from the program, leaving it empty.
    void load​(CPU cpu)
    Load the program into the CPU.
    int size()
    Get the size of the program.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Program

      public Program()
      Constructor - creates a new empty program (no instructions).
  • Method Details

    • add

      public boolean add​(Instruction e)
      Adds a new instruction to the program.
      Parameters:
      e - an instruction
      Returns:
      true if instruction was added, false otherwise
    • clear

      public void clear()
      Remove all instructions from the program, leaving it empty.
    • size

      public int size()
      Get the size of the program.
      Returns:
      number of instructions in the program
    • load

      public void load​(CPU cpu)
      Load the program into the CPU.
      • Store instructions into memory, starting at location 0
      • Set the CPU's instructionCounter to 0 (beginning of the program)
      • Set the CPU's dataMemoryBase to 1 after the last instruction loaded
      Parameters:
      cpu - CPU object in which to load this program