예제 #1
0
 public OpCodeComputer Run(Action <long> output = null)
 {
     idle.Reset();
     while (pc >= 0 && pc < Program.Length)
     {
         var cancel = new CancelEventArgs(false);
         PreExecute?.Invoke(pc, cancel);
         OpWord op = PCReadOpWord();
         if (cancel.Cancel)
         {
             break;
         }
         if (op.OpCode == OpCode.nop)
         {
             //nop
         }
         else if (op.OpCode == OpCode.acc)
         {
             Accumulator += op.Arg;
         }
         else if (op.OpCode == OpCode.jmp)
         {
             pc += op.Arg - 1;
         }
         else
         {
             throw new Exception("Opcode error");
         }
     }
     return(this);
 }
예제 #2
0
 public Cap4(PreExecute pre, PosExecute pos)
 {
     this.pres = pre;
     this.poss = pos;
 }