コード例 #1
0
        static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                if (args.Length == 2)
                {
                    MipsSimulator.Cmd.cmdMode cmdMode = new Cmd.cmdMode();
                    cmdMode.start(args[0], args[1]);
                }
                else
                {
                    string message = "参数输入有误,只允许两个参数:outputPath,inputPath\r\n";
                    string path    = System.Environment.CurrentDirectory;
                    path = path + "\\report.txt";
                    MipsSimulator.Tools.FileControl.WriteFile(path, message);
                }
            }
            else
            {
                mode = 1;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                form1 = new Form1();
                Application.Run(form1);
            }
        }
コード例 #2
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.ColumnIndex;

            if (index != 3)
            {
                return;
            }
            string inputPath = System.Environment.CurrentDirectory;

            inputPath = inputPath + "\\source.txt";
            string outputPath = System.Environment.CurrentDirectory;

            outputPath = outputPath + "\\report.txt";
            if (File.Exists(inputPath))
            {
                File.Delete(inputPath);
            }
            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            string source = "";

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                source = this.dataGridView1.Rows[i].Cells[3].Value.ToString() + "\r\n";
                MipsSimulator.Tools.FileControl.WriteFile(inputPath, source);
            }
            MipsSimulator.Cmd.cmdMode cmdMode = new Cmd.cmdMode();
            if (!cmdMode.doAssembler(inputPath, outputPath, false))
            {
                string error = MipsSimulator.Tools.FileControl.ReadFile(outputPath);
                RunTimeCode.Clear();
                textBox2.Text += error;
                this.tabControl3.SelectedTab = this.tabPage5;
                return;
            }
            dataGridView1.Refresh();
            codeColor(indexFinal, colorFinal);
            for (int i = 0; i < breakpoints.Count; i++)
            {
                int point = breakpoints[i];
                dataGridView1.Rows[point].Cells[0].Value = true;
            }
            this.tabControl1.SelectedTab = this.tabPage2;
            return;
        }
コード例 #3
0
        //分析代码
        private void toolStripButton1_Click_1(object sender, EventArgs e)
        {
            textBox2.Text = "";
            if (this.txtContent.Text == null || this.txtContent.Text == "")
            {
                MessageBox.Show("代码不可以为空!");
                return;
            }
            string[] codes = this.txtContent.Text.Split(new string[1] {
                "\r\n"
            }, StringSplitOptions.RemoveEmptyEntries);
            if (codes == null || codes.Length <= 0)
            {
                MessageBox.Show("代码不可以为空!");
                return;
            }

            Reset();
            RunTimeCode.Clear();
            string inputPath = System.Environment.CurrentDirectory;

            inputPath = inputPath + "\\source.txt";
            string outputPath = System.Environment.CurrentDirectory;

            outputPath = outputPath + "\\report.txt";
            if (File.Exists(inputPath))
            {
                File.Delete(inputPath);
            }
            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }
            MipsSimulator.Tools.FileControl.WriteFile(inputPath, this.txtContent.Text);

            MipsSimulator.Cmd.cmdMode cmdMode = new Cmd.cmdMode();
            if (!cmdMode.doAssembler(inputPath, outputPath, true))
            {
                string error = MipsSimulator.Tools.FileControl.ReadFile(outputPath);
                RunTimeCode.Clear();
                textBox2.Text += error;
                this.tabControl3.SelectedTab = this.tabPage5;
                return;
            }
            dataGridView1.Refresh();
            this.tabControl1.SelectedTab = this.tabPage2;
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: ceie246/MIPS246_Software
        //分析代码
        private void toolStripButton1_Click_1(object sender, EventArgs e)
        {
            textBox2.Text = "";
            if (this.txtContent.Text == null || this.txtContent.Text == "")
            {
                MessageBox.Show("代码不可以为空!");
                return;
            }
            string[] codes = this.txtContent.Text.Split(new string[1] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (codes == null || codes.Length <= 0)
            {
                MessageBox.Show("代码不可以为空!");
                return;
            }

            Reset();
            RunTimeCode.Clear();
            string inputPath = System.Environment.CurrentDirectory;
            inputPath = inputPath + "\\source.txt";
            string outputPath = System.Environment.CurrentDirectory;
            outputPath = outputPath + "\\report.txt";
            if (File.Exists(inputPath))
            {
                File.Delete(inputPath);
            }
            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }
            MipsSimulator.Tools.FileControl.WriteFile(inputPath, this.txtContent.Text);

            MipsSimulator.Cmd.cmdMode cmdMode = new Cmd.cmdMode();
            if (!cmdMode.doAssembler(inputPath, outputPath,true))
            {
                string error = MipsSimulator.Tools.FileControl.ReadFile(outputPath);
                RunTimeCode.Clear();
                textBox2.Text += error;
                this.tabControl3.SelectedTab = this.tabPage5;
                return;
            }
            dataGridView1.DataSource = RunTimeCode.CodeT;
            this.dataGridView2.DataSource = Register.Res;
            this.dataGridView3.DataSource = Memory.Mem;
            this.tabControl1.SelectedTab = this.tabPage2;
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: ceie246/MIPS246_Software
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            int index = e.ColumnIndex;
            if (index != 3)
                return;
            string inputPath = System.Environment.CurrentDirectory;
            inputPath = inputPath + "\\source.txt";
            string outputPath = System.Environment.CurrentDirectory;
            outputPath = outputPath + "\\report.txt";
            if (File.Exists(inputPath))
            {
                File.Delete(inputPath);
            }
            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            string source = "";
            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                source = this.dataGridView1.Rows[i].Cells[3].Value.ToString()+"\r\n";
                MipsSimulator.Tools.FileControl.WriteFile(inputPath, source);
            }
            MipsSimulator.Cmd.cmdMode cmdMode = new Cmd.cmdMode();
            if (!cmdMode.doAssembler(inputPath, outputPath,false))
            {
                string error = MipsSimulator.Tools.FileControl.ReadFile(outputPath);
                RunTimeCode.Clear();
                textBox2.Text += error;
                this.tabControl3.SelectedTab = this.tabPage5;
                return;
            }
            dataGridView1.Refresh();
            codeColor(indexFinal, colorFinal);
            for (int i = 0; i < breakpoints.Count; i++)
            {
                int point = breakpoints[i];
                dataGridView1.Rows[point].Cells[0].Value = true;

            }
            this.tabControl1.SelectedTab = this.tabPage2;
            return;
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ceie246/MIPS246_Software
        static void Main(string[] args)
        {
            if (args.Length>=1)
            {
                if (args.Length == 4)
                {
                    MipsSimulator.Cmd.cmdMode cmdMode = new Cmd.cmdMode();
                    cmdMode.start(args[0], args[1]);
                    string source = args[1];
                    string output = args[2];
                    int count1 = File.ReadAllLines(source).Length;
                    int count2 = File.ReadAllLines(output).Length;
                    if (count2 > count1)
                    {
                        string[] output2 = File.ReadAllLines(output);

                        FileInfo fInfo = new FileInfo(output);
                        if (fInfo.Exists)
                        {
                            fInfo.Delete();
                        }
                        FileStream fs = fInfo.OpenWrite();
                        StreamWriter w = new StreamWriter(fs);
                        if (count1 > 0)
                        {
                            for (int i = 0; i < count1; i++)
                            {
                                w.WriteLine(output2[i]);
                            }
                        }

                        w.Flush();
                        w.Close();
                        w.Dispose();
                    }
                    if (count1 > count2)
                    {
                        string[] output1 = File.ReadAllLines(source);

                        FileInfo fInfo = new FileInfo(source);
                        if (fInfo.Exists)
                        {
                            fInfo.Delete();
                        }
                        FileStream fs = fInfo.OpenWrite();
                        StreamWriter w = new StreamWriter(fs);
                        if (count2 > 0)
                        {
                            for (int i = 0; i < count2; i++)
                            {
                                w.WriteLine(output1[i]);
                            }
                        }

                        w.Flush();
                        w.Close();
                        w.Dispose();
                    }
                    string result = ResultComparer.Compare(source, output);
                    string resultPath = args[3];
                    FileInfo fInfoR = new FileInfo(resultPath);
                    if (fInfoR.Exists)
                    {
                        fInfoR.Delete();
                    }
                    FileStream fsR = fInfoR.OpenWrite();
                    StreamWriter wR = new StreamWriter(fsR);
                    //w.BaseStream.Seek(0, SeekOrigin.Begin);
                    wR.Write(result);
                    wR.Flush();
                    wR.Close();
                    wR.Dispose();
                }
                else
                {
                    string message = "参数输入有误,只允许两个参数:outputPath,inputPath\r\n";
                    string path = System.Environment.CurrentDirectory;
                    path = path + "\\report.txt";
                    MipsSimulator.Tools.FileControl.WriteFile(path, message);
                }

            }
            else
            {
                mode = 1;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                form1 = new Form1();
                Application.Run(form1);
            }
        }