Beispiel #1
0
        public armsimGUI(string[] args)
        {
            InitializeComponent();

            comp                          = new Computer(this);
            runThread                     = new BackgroundWorker();
            runThread.DoWork             += new DoWorkEventHandler(runThread_DoWork);
            runThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(runThread_RunWorkerCompleted);

            stepThread                     = new BackgroundWorker();
            stepThread.DoWork             += new DoWorkEventHandler(stepThread_DoWork);
            stepThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(stepThread_RunWorkerCompleted);

            updateRegistersPanel();

            var options = new Options();

            if (CommandLineParser.Default.ParseArguments(args, options)) // if command line arguments are valid...
            {
                if (options.Test)
                {
                    testRAM.RunTests();
                    Computer.TestLoader();
                    CPU.TestCPU();
                    Trace.WriteLine("All tests passed!");
                    Trace.WriteLine("-----------------------------------"); // insert line for file readability
                }
                else if (options.TestFlags)
                {
                    //comp.TestFlags();
                    //disassemblyListView.Items.Add(new ListViewItem(
                    //updateFlagsPanel();
                    //updateRegistersPanel();
                    comp.TestPutChar();
                }

                if (options.ELFInputFile != "")
                {
                    if (options.Exec)
                    {
                        LoadAndRunFile(options.ELFInputFile);
                    }
                    else
                    {
                        LoadFile(options.ELFInputFile);
                        runToolBtn.Enabled   = true;
                        stepToolBtn.Enabled  = true;
                        resetToolBtn.Enabled = true;
                    }
                }
            }
            // If any command line arguments are invalid, the CommandLine library displays the message as commented in the Options class.
            // Additional error handling can be implemented by including an "else" statement here.
        }