Esempio n. 1
0
 public static void loadRegs(string line, IOrganismo o)
 {
     if (line == null)
     {
         return;
     }
     if (line.StartsWith("#REGS: "))
     {
         string[] pars = line.Split(' ');
         for (int i = 0; i < pars.Length; i++)
         {
             string par = pars[i].Trim();
             if (par.Contains("["))
             {
                 par = par.Substring(0, par.IndexOf("[")).Trim();
             }
             if (par.Contains("X:"))
             {
                 string letter = par.Substring(0, 1);
                 string val    = par.Substring(par.IndexOf(":") + 1);
                 o.setReg(ALifeConsts.getLetterNumber(letter.ToCharArray()[0]), int.Parse(val));
             }
             if (par.Contains("SP:"))
             {
                 string val = par.Substring(par.IndexOf(":") + 1);
                 o.setStartPoint(int.Parse(val));
             }
             if (par.Contains("IP:"))
             {
                 string val = par.Substring(par.IndexOf(":") + 1);
                 o.ip = int.Parse(val) + 1;
             }
         }
     }
 }
Esempio n. 2
0
 private static int loadParams(Instruction instruction, string parms, IOrganismo o, int pos)
 {
     string[] pars = parms.Split(',');
     for (int i = 0; i < pars.Length; i++)
     {
         string par = pars[i].Trim();
         if (par.Length > 0)
         {
             char p = par.ToCharArray()[0];
             if (p >= 'A' && p <= 'Z')
             {
                 o.setMemory(o.sp() + pos + i, ALifeConsts.getLetterNumber(p));
             }
             else
             {
                 o.setMemory(o.sp() + pos + i, int.Parse(par));
             }
         }
         else
         {
             pos--;
         }
     }
     return(pos + pars.Length);
 }
Esempio n. 3
0
        public String debugInfo()
        {
            String s = "Stack: ";

            for (int i = 0; i < pos; i++)
            {
                s += ALifeConsts.numberFormat(stack[i]) + " | ";
            }
            return(s);
        }
Esempio n. 4
0
        public string hash()
        {
            string saida = getMemorySize() + "_";

            while (saida.Length < 4)
            {
                saida = "0" + saida;
            }
            int soma = somaInstructions() * getMemorySize();

            saida = saida + ALifeConsts.toHexString(soma);

            return(saida);
        }
Esempio n. 5
0
        public string debugInfo(string prefix)
        {
            string saida = prefix + " = ";

            for (int i = 0; i < ALifeConsts.REGISTRADORES; i++)
            {
                saida += ALifeConsts.getLetter(i) + "X:"
                         + ALifeConsts.numberFormat(getReg(i)) + " ";
            }
            saida += "SP:" + ALifeConsts.numberFormat(sp()) + " IP:"
                     + ALifeConsts.numberFormat(ip) + " E:" + ((int)_error)
                     + " ID:" + id;
            if (_child != null)
            {
                saida += " (Child:" + _child.id + " size:"
                         + ALifeConsts.numberFormat(_child.getMemorySize()) + " )";
            }

            saida += Environment.NewLine + "#" + stacks.debugInfo();
            return(saida);
        }