Esempio n. 1
0
        public void LeerLinea(string linea, ref ushort posicion)
        {
            Instruccion instruccion = null;

            string[] instruccionArgumentos = UtilidadesInstruccion.ExtraerInstruccionArgumentos(linea);

            if (UtilidadesInstruccion.esInstruccion(instruccionArgumentos[0]))
            {
                instruccion = Instruccion.ConvertirEnInstruccion(instruccionArgumentos);
                lineas.Add(new string[] { string.Empty, linea });
                //--
                //lineas2.Add(new EtiquetaInstruccion(string.Empty, linea));
            }
            else
            {
                Main.ObtenerMemoria.Etiquetas.Add(new Etiqueta(posicion, instruccionArgumentos[0]));
                if (instruccionArgumentos.Length <= 0)
                {
                    throw new ArgumentException();
                }

                string[] _instruccionArgumentos = new string[instruccionArgumentos.Length - 1];
                for (int i = 0; i < _instruccionArgumentos.Length; i++)
                {
                    _instruccionArgumentos[i] = instruccionArgumentos[i + 1];
                }
                instruccion = Instruccion.ConvertirEnInstruccion(_instruccionArgumentos);
                lineas.Add(new string[] { instruccionArgumentos[0], linea.Substring(instruccionArgumentos[0].Length).TrimStart() });
                //lineas2.Add(new EtiquetaInstruccion(instruccionArgumentos[0], linea.Substring(instruccionArgumentos[0].Length).TrimStart()));
            }

            switch (instruccion.NumArgumentos)
            {
            case 0:
                posicion++;
                break;

            case 1:
                if (instruccion is IInstruccionSalto)
                {
                    posicion += 3;
                }
                else
                {
                    if (instruccion.ObtenerArgumento(0).TipoArgumento() == Argumento.Tipo.Literal)
                    {
                        posicion += 2;
                    }
                    else
                    {
                        posicion++;
                    }
                }
                break;

            case 2:
                if (instruccion.ObtenerArgumento(0).TipoArgumento() == Argumento.Tipo.Literal)
                {
                    posicion += 2;
                }
                else
                {
                    posicion += 3;
                }
                break;
            }
        }
Esempio n. 2
0
        public void ProbarInstruccionMemoria(Instruccion instruccion, ref ushort posicion)
        {
            byte prueba;

            memoria[posicion].Contenido = instruccion.Codigo;
            if (instruccion.NumArgumentos == 1 && instruccion.ObtenerArgumento(0).TipoArgumento() != Tipo.Registro)
            {
                if (instruccion.ObtenerArgumento(0).TipoArgumento() == Tipo.Memoria)
                {
                    ++posicion;
                    prueba = BitConverter.GetBytes((instruccion.ObtenerArgumento(0) as ArgMemoria).DireccionMemoria)[1];
                    ++posicion;
                    prueba = BitConverter.GetBytes((instruccion.ObtenerArgumento(0) as ArgMemoria).DireccionMemoria)[0];
                }
                else
                {
                    ++posicion;
                    prueba = (instruccion.ObtenerArgumento(0) as ArgLiteral).Valor;
                }
            }
            else if (instruccion.NumArgumentos == 2)
            {
                if (instruccion.ObtenerArgumento(0).TipoArgumento() == Tipo.Memoria || instruccion.ObtenerArgumento(1).TipoArgumento() == Tipo.Memoria)
                {
                    int n = instruccion.ObtenerArgumento(0).TipoArgumento() == Tipo.Memoria ? 0 : 1;
                    ++posicion;
                    prueba = BitConverter.GetBytes((instruccion.ObtenerArgumento(n) as ArgMemoria).DireccionMemoria)[1];
                    ++posicion;
                    prueba = BitConverter.GetBytes((instruccion.ObtenerArgumento(n) as ArgMemoria).DireccionMemoria)[0];
                }
                else
                {
                    int n = instruccion.ObtenerArgumento(0).TipoArgumento() == Tipo.Literal ? 0 : 1;
                    ++posicion;
                    prueba = (instruccion.ObtenerArgumento(n) as ArgLiteral).Valor;
                }
            }

            posicion++;
        }