Exemplo n.º 1
0
 private static void FakeMemory(params int[] blockIds)
 {
     for (int i = 0; i < blockIds.Length; i++)
     {
         RealMachine.GetRealMemory().TakeMemoryBlock(blockIds[i]);
     }
 }
Exemplo n.º 2
0
        private static bool Execution(bool exit)
        {
            bool incorrect = false;

            do
            {
                PrintMenu();
                Console.Write("EXECUTION MODE: ");
                string executionMode = Console.ReadLine();
                Console.Write("\n");
                bool working = true;
                switch (executionMode)
                {
                case "1":
                    working = RealMachine.GetProcessor().Execute();
                    break;

                case "2":
                    working = RealMachine.GetProcessor().Step();
                    bool done = false;
                    while (!done)
                    {
                        PrintStepMenu();
                        Console.Write("ACTION: ");
                        string action = Console.ReadLine();
                        Console.Write("\n");
                        switch (action)
                        {
                        case "1":
                            working = RealMachine.GetProcessor().Step();
                            break;

                        case "2":
                            working = RealMachine.GetProcessor().Execute();
                            break;

                        case "3":
                            RealMachine.GetRealMemory().PrintUserMemory();
                            break;

                        case "4":
                            RealMachine.GetVirtualMemory().PrintVirtualMemory();
                            break;

                        case "5":
                            RealMachine.GetProcessor().PrintAllRegisters();
                            break;

                        case "0":
                            done = true;
                            break;

                        case "c":
                            Console.Clear();
                            break;

                        default:
                            Console.WriteLine("Incorrect action.");
                            break;
                        }
                        if (!working)
                        {
                            done = true;
                        }
                    }
                    break;

                case "0":
                    exit = true;
                    break;

                case "c":
                    Console.Clear();
                    break;

                default:
                    Console.WriteLine("Incorrect execution mode.");
                    incorrect = true;
                    break;
                }
                if (!working)
                {
                    break;
                }
            } while (incorrect);
            return(exit);
        }