Beispiel #1
0
 private void Register_3_Button_Click(object sender, EventArgs e)
 {
     using (InputValuePrompt dlg = new InputValuePrompt())
     {
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             machine.registers[2].SetValue(new Hex(dlg.value));
             UpdateUi();
         }
     }
 }
Beispiel #2
0
        public Emulator()
        {
            InitializeComponent();
            machine = new Machine();

            machine.GetInput = () => {
                using (InputValuePrompt dlg = new InputValuePrompt())
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        machine.InputBuffer = new Hex(dlg.value);
                    }
                }
            };

            machine.RecieveOutput = (hex) => {
                Output_Button.Text = Util.ConvertDataToSelectedBase(hex, (int)displayBase_ComboBox.SelectedItem);
            };

            machine.EndOfProgram = () => {
                isRan = true;
                using (Prompt dlg = new Prompt("End of program!", "Okay"))
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                    }
                }
            };

            memoryGrid_DataGridView.RowHeadersVisible  = false;
            memoryGrid_DataGridView.RowTemplate.Height = 20;

            memoryGrid_DataGridView.ColumnHeadersVisible = false;
            memoryGrid_DataGridView.Columns.Add("Index", "");
            memoryGrid_DataGridView.Columns.Add("Value", "");

            memoryGrid_DataGridView.Columns["Index"].Width        = 40;
            memoryGrid_DataGridView.Columns["Index"].ReadOnly     = true;
            memoryGrid_DataGridView.Columns["Value"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;



            displayBase_ComboBox.DataSource    = new int[] { 16, 10, 2, };
            displayBase_ComboBox.SelectedIndex = 1;

            machine.memory.AddressValueChanged += Memory_AddressValueChanged;
            Memory_AddressValueChanged(null, 0);
        }