public Task startComputation() { ProgramMemory = new BufferMemory16(BinaryCode); DataMemory = new BufferMemory16(65536); CPU = new SerialAbacus16Cpu(ProgramMemory, DataMemory); VirtualSystem = new Host(CPU); VirtualSystem.ExecutionCompleted += onExecutionCompleted; VirtualSystem.ClockCycleScheduled += onClockCycleScheduled; VirtualSystem.Start(); return(VirtualSystem.WorkerTask); }
public SpecialMemoryOperationUnit(SerialAbacus16Cpu cpu, IRegisterGroup registers) : base(registers) { Cpu = cpu; }
static void Main(string[] args) { string programMemoryFile = args[0]; string dataMemoryFile = (args.Length < 2 ? null : args[1]); bool showControlFlow = (args.Length < 3 ? false : args[2].Contains(ShowControlFlowFlag)); bool startPaused = (args.Length < 3 ? false : args[2].Contains(StartPausedFlag)); bool monitorProgramFlow = (args.Length < 3 ? false : args[2].Contains(MonitorProgramFlowFlag)); bool benchmark = (args.Length < 3 ? false : args[2].Contains(BenchmarkFlag)); programMemory = new BufferMemory16(System.IO.File.ReadAllBytes(programMemoryFile)); if (!string.IsNullOrEmpty(dataMemoryFile) && dataMemoryFile != "?") { dataMemory = new BufferMemory16(System.IO.File.ReadAllBytes(dataMemoryFile)); } else { dataMemory = new SparseMemory <Word>(SerialAbacus16Cpu.MaximumAddressableMemory); } cpu = new SerialAbacus16Cpu( programMemory, dataMemory); virtualSystem = new Host(cpu); virtualSystem.ExecutionCompleted += virtualSystem_ExecutionCompleted; if (showControlFlow) { cpu.InstructionPending += cpu_InstructionPending; //virtualSystem.ClockCycleScheduled += virtualSystem_ClockCycleScheduled; Console.WriteLine("Press ESC to cancel execution"); } if (monitorProgramFlow) { FlowMonitoringMapping = new Dictionary <int, FlowInfo>(); } if (!startPaused) { virtualSystem.Start(); } if (benchmark) { System.Threading.Thread.Sleep(1000); virtualSystem.SuspendAsync().Wait(); WriteDumps(); Console.ReadLine(); return; } while (true) { ConsoleKeyInfo input = Console.ReadKey(true); switch (input.Key) { case ConsoleKey.Escape: if (virtualSystem.IsRunning) { Console.WriteLine("Suspending Execution..."); virtualSystem.SuspendAsync().Wait(); WriteDumps(); Console.WriteLine("Execution suspended. Press ENTER to exit."); Console.ReadLine(); } return; case ConsoleKey.P: Console.WriteLine("Suspending execution..."); virtualSystem.SuspendAsync().Wait(); Console.WriteLine("Execution suspended. Press H for help."); break; case ConsoleKey.R: if (!virtualSystem.IsRunning) { virtualSystem.Start(); } else { Console.WriteLine("Already running."); } break; case ConsoleKey.S: if (!virtualSystem.IsRunning) { virtualSystem.Step(1); } else { Console.WriteLine("Already running."); } break; case ConsoleKey.F: WriteFlowDump(); break; case ConsoleKey.D: WriteDumps(); break; case ConsoleKey.H: Console.WriteLine("ESC: exit | P: pause | S: single step | R: run | D: dump | F: flow info | H: help"); break; } } }