Exemple #1
0
        private void btn_step_Click(object sender, EventArgs e)
        {
            if (_sic_machine.Tick() == 0)
            {
                btn_step.Enabled  = false;
                btn_run.Enabled   = false;
                btn_stop.Enabled  = false;
                btn_pause.Enabled = false;
                timerExec.Stop();
                MessageBox.Show("Error al ejecutar la instrucción, instrucción no valida!");
                return;
            }
            ActualizaRegistros();

            int modif = _sic_machine.GetModifiedAddresList.Count;

            if (modif != 0)
            {
                for (int i = 0; i < modif; i++)
                {
                    ushort addr = _sic_machine.GetModifiedAddresList[i];
                    byte   data = _sic_machine.Memory[addr];
                    hv.WriteLocation(addr, data);
                }
            }

            if (hv.Visible)
            {
                hv.SelectLocation(_sic_machine.PC, 3);
            }
        }
Exemple #2
0
        private int CargaArchivoObjeto(string filepath)
        {
            StreamReader file = new StreamReader(filepath);

            if (file == null)
            {
                return(0);
            }

            file.Close();
            lineas_obj     = File.ReadLines(filepath).ToList();
            _obj_file_path = filepath;
            CargadorSic cargador = new CargadorSic();

            if (cargador.CargaProgramaObjeto(lineas_obj, _sic_machine) == 1)
            {
                MessageBox.Show("Programa cargado correctamente");
                _sic_machine.Reset();
                textBox_PNAME.Text = _sic_machine.ProgName;
                textBox_PSIZE.Text = _sic_machine.ProgSize.ToString() + " bytes";
                ActualizaRegistros();
                toolStrip1.Enabled = true;
                programaObjetoToolStripMenuItem.Enabled = true;
                objv = new ObjViewer(lineas_obj);

                if (hv.Visible)
                {
                    hv.Close();
                }


                hv = new HexViewer(_sic_machine.Memory);
                hv.StartPosition = FormStartPosition.Manual;
                hv.Location      = new Point(this.Location.X + this.Size.Width, this.Location.Y);
                hv.Show();
                hv.SelectLocation(_sic_machine.PC, 3);
            }
            else
            {
                MessageBox.Show("No se pudo cargar el programa objeto, verifique el que arlchivo tenga un formato correcto.");
                return(0);
            }

            return(1);
        }