Exemplo n.º 1
0
        /// <summary>
        /// Sets the currently used parts and starts the computer
        /// </summary>
        /// <param name="binaryPath">Path to the binary to execute</param>
        /// <param name="cpu">The selected cpu module</param>
        /// <param name="ram">The selected ram module</param>
        /// <param name="timing">The selected timer</param>
        /// <param name="hardware">The selected generic hardware</param>
        public void setParts(string binaryPath, ICpu cpu, IRam ram, ITimer timing, List<IHardware> hardware)
        {
            this.cpu = cpu;
            this.ram = ram;
            this.hardware = hardware;

            loadFile(binaryPath);
            //Start a new thread which prints the registers to the console.
            new Thread((ThreadStart)delegate
                                        {
                                            while (true)
                                            {
                                                //Convert the current cpu status to a string
                                                string s = cpu.getRegisterSnapshot().Aggregate("", (current, register) => current + (register + "; "));
                                                //Add the PC special register to the string
                                                s += cpu.getSpecialRegisters()[0] + "; ";
                                                AdvConsole.Debug(s);
                                            }
                                        }).Start();
            timing.start();
        }