public void Reset() { InstructionsRun.Clear(); Accumulator = 0; Pointer = 0; Instructions = ParseInstructions(_originalInstructions); }
public bool Boot() { while (!InstructionsRun.Contains(Pointer)) { if (Pointer < 0 || Pointer >= Instructions.Length) { return(false); } InstructionsRun.Add(Pointer); var instruction = Instructions[Pointer]; switch (instruction.Operation) { case "nop": Pointer++; break; case "acc": Pointer++; Accumulator += instruction.Argument; break; case "jmp": Pointer += instruction.Argument; break; default: break; } if (Pointer >= Instructions.Length) { return(true); } } return(false); }