//update the panels on the main window. <e> contains a status code that will help determine which message to show the user, based on how execution endec //i.e. clicking on stop, hitting breakpoints etc. private void EndRun(CompRunFinishedEventArgs e) { if (e.end == 4) { RunBtn.Enabled = true; MessageBox.Show("Error: Illegal step/run performed. The program has already executed. Please hit reset and try again."); return; } Loader.Log("Form1: Step/Execute cycle finished.", false, false); uint entry = comp.Registers.getPC(); setRegister(15, entry); SetProgMode(); int x1 = 0; int fi = 1; while (fi < 5) { uint flag = comp.Registers.cpsr; bool fl = Memory.TestBit(32 - fi, flag); if (fl == true) { flagView.Rows[0].Cells[fi - 1].Value = "1"; } else { flagView.Rows[0].Cells[fi - 1].Value = "0"; } fi++; } if (Memory.TestBit(7, comp.Registers.cpsr)) { flagView.Rows[0].Cells[4].Value = "1"; } else { flagView.Rows[0].Cells[4].Value = "0"; } while (x1 < 15) { uint val = comp.getReg(x1); setRegister(x1, val); x1++; } var x = disassemblyView.Rows; disassemblyView.ClearSelection(); bool selected = false; foreach (DataGridViewRow y in x) { if (y.Cells[0].Value == null) { continue; } string iii = (string)y.Cells[0].Value; var nupoint = UInt32.Parse(iii.Substring(2), System.Globalization.NumberStyles.HexNumber); if (nupoint == entry) { int rindex = y.Index; if (rindex > 2) { selected = true; if (rindex != disassemblyView.Rows[disassemblyView.Rows.Count - 1].Index) { disassemblyView.FirstDisplayedScrollingRowIndex = rindex - 2; } else { disassemblyView.FirstDisplayedScrollingRowIndex = disassemblyView.Rows.Count - 4; } } else { selected = true; } y.Selected = true; disassemblyView.Update(); break; } } if (!selected) { disassemblyView.FirstDisplayedScrollingRowIndex = disassemblyView.Rows.Count - 4; disassemblyView.Rows[disassemblyView.Rows.Count - 1].Selected = true; } if (e.end == 0) { MessageBox.Show("Execution complete"); opModePanel.Text = "Operating Mode: None"; comp.resetCounter(); } else if (e.end == 1) { MessageBox.Show("Breakpoint Reached"); opModePanel.Text = "Operating Mode: Breakpoint"; } else if (e.end == 2) { MessageBox.Show("Execution stopped by user"); opModePanel.Text = "Operating Mode: User Stop"; } else if (e.end == 3) { opModePanel.Text = "Operating Mode: None"; } else if (e.end == 4) { MessageBox.Show("Error: Illegal step/run performed. The program has already executed. Please hit reset and try again."); } else if (e.end == 5) { MessageBox.Show("Internal simulator error. Run aborted."); } addStack(); resetMemory(entry); RunBtn.Enabled = true; }