Exemplo n.º 1
0
  /** Loads the given program file (HACK or ASM) into the ROM. */
  public synchronized void loadProgram(String fileName) throws ProgramException {
    short[] program = null;

    if (displayChanges) ((ROMGUI) gui).showMessage("Loading...");

    try {
      program =
          HackAssemblerTranslator.loadProgram(
              fileName, Definitions.ROM_SIZE, HackAssemblerTranslator.NOP);

      mem = program;

      if (displayChanges) {
        gui.setContents(mem);

        ((ROMGUI) gui).setProgram(fileName);

        ((ROMGUI) gui).hideMessage();
        gui.hideHighlight();
      }

      notifyProgramListeners(ProgramEvent.LOAD, fileName);

    } catch (AssemblerException ae) {
      if (displayChanges) ((ROMGUI) gui).hideMessage();
      throw new ProgramException(ae.getMessage());
    }
  }
Exemplo n.º 2
0
 /** Called when the contents of the memory are changed through the memory gui. */
 public void valueChanged(ComputerPartEvent event) {
   short newValue = event.getValue();
   int newAddress = event.getIndex();
   clearErrorListeners();
   try {
     HackAssemblerTranslator.getInstance().codeToText(newValue);
     setValueAt(newAddress, newValue, true);
   } catch (AssemblerException ae) {
     notifyErrorListeners("Illegal instruction");
     quietUpdateGUI(newAddress, mem[newAddress]);
   }
 }