Example #1
0
 /** jump */
 public void jump(JumpInstruction currentInstruction) {
   if (program.checkExistLabel(currentInstruction.getLabel()))
     setCurrentInstructionIndex(program.getLabelIndex(currentInstruction.getLabel()));
   else {
     halt();
     System.out.println(
         "Error. Line: "
             + (currentInstructionIndex + 1)
             + " Invalid label: "
             + currentInstruction.getName()
             + " "
             + currentInstruction.getLabel());
   }
 }
Example #2
0
 /** jgtz */
 public void jgtz(JumpInstruction currentInstruction) {
   if (memoryRegister.getAccumulator() > 0) {
     if (program.checkExistLabel(currentInstruction.getLabel()))
       setCurrentInstructionIndex(program.getLabelIndex(currentInstruction.getLabel()));
     else {
       halt();
       System.out.println(
           "Error. Line: "
               + (currentInstructionIndex + 1)
               + " Invalid label: "
               + currentInstruction.getName()
               + " "
               + currentInstruction.getLabel());
     }
   } else currentInstructionIndex++;
 }