예제 #1
0
        public string ejecutaPaso()
        {
            string mensaje;

            mensaje = "";
            try
            {
                if (ejecutable)
                {
                    string codOp;
                    string m;
                    codOp = this.memoria.ObtenCodOp(ref this.cp);
                    m     = this.memoria.ObtenM(ref this.cp);
                    m     = this.indexaM(m);
                    if (this.cp < MetodosAuxiliares.FinalPrograma(this.memoria.Inicio, this.memoria.Tamaño))
                    {
                        if (MetodosAuxiliares.hexadecimalADecimal(m) <= MetodosAuxiliares.FinalPrograma(this.memoria.Inicio, this.memoria.Tamaño))
                        {
                            switch (codOp)
                            {
                            case "18":    //ADD
                                mensaje = this.ADD(m);
                                break;

                            case "40":    //AND
                                mensaje = this.AND(m);
                                break;

                            case "28":    //COMP
                                mensaje = this.COMP(m);
                                break;

                            case "24":    //DIV
                                mensaje = this.DIV(m);
                                break;

                            case "3C":    //J
                                mensaje = this.J(m);
                                break;

                            case "30":    //JEQ
                                mensaje = this.JEQ(m);
                                break;

                            case "34":    //JGT
                                mensaje = this.JGT(m);
                                break;

                            case "38":    //JLT
                                mensaje = this.JLT(m);
                                break;

                            case "48":    //JSUB
                                mensaje = this.JSUB(m);
                                break;

                            case "00":    //LDA
                                mensaje = this.LDA(m);
                                break;

                            case "50":    //LDCH
                                mensaje = this.LDCH(m);
                                break;

                            case "08":    //LDL
                                mensaje = this.LDL(m);
                                break;

                            case "04":    //LDX
                                mensaje = this.LDX(m);
                                break;

                            case "20":    //MUL
                                mensaje = this.MUL(m);
                                break;

                            case "44":    //OR
                                mensaje = this.OR(m);
                                break;

                            case "D8":    //RD
                                mensaje = this.RD(m);
                                break;

                            case "4C":    //RSUB
                                mensaje = this.RSUB();
                                break;

                            case "0C":    //STA
                                mensaje = this.STA(m);
                                break;

                            case "54":    //STCH
                                mensaje = this.STCH(m);
                                break;

                            case "14":    //STL
                                mensaje = this.STL(m);
                                break;

                            case "E8":    //STSW
                                mensaje = this.STSW(m);
                                break;

                            case "10":    //STX
                                mensaje = this.STX(m);
                                break;

                            case "1C":    //SUB
                                mensaje = this.SUB(m);
                                break;

                            case "E0":    //TD
                                //mensaje = this.TD(m);
                                break;

                            case "2C":    //TIX
                                mensaje = this.TIX(m);
                                break;

                            case "DC":    //WD
                                //mensaje = this.WD(m);
                                break;
                            }
                        }
                        else
                        {
                            throw new EndProgramException("Error se intento acceder a una localidad de memoria inexistente");
                        }
                    }
                    else
                    {
                        throw new EndProgramException("Se acabaron las intrucciones a ejecutar, por lo tanto el programa finalizo");
                    }
                }
            }
            catch (EndProgramException e)
            {
                this.ejecutable = false;
                MessageBox.Show(e.Message, "El programa ah finalizado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(mensaje);
        }