Example #1
0
        public static void CreateInstructionList(List <byte[]> networks)
        {
            Memory.Program.InstructionList = new List <Instruction>();
            int counter = 0;

            for (int i = 0; i < networks.Count; i++)
            {
                for (int j = 0; j < networks[i].Length; j += 2)
                {
                    byte firstComponent  = networks[i][j];
                    byte secondComponent = networks[i][j + 1];
                    if (firstComponent == 0xba)
                    {
                        Operators operatorIL;
                        if (j == 0)
                        {
                            operatorIL = Operators.BLOCK;
                            if (counter == 0)
                            {
                                DiagnosticData.AddDataSpecial();
                            }
                            else
                            {
                                DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.special);
                            }
                        }
                        else
                        {
                            operatorIL = Operators.ANDFUNC;
                            DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.special);
                        }
                        Memory.Program.InstructionList.Add(new CommandRegister.Instruction(operatorIL));
                        IsLoad   = false;
                        IsLoaded = false;
                    }
                    else if (firstComponent == 0xbf)
                    {
                        Operators operatorIL = Operators.ENDBLOCK;
                        Memory.Program.InstructionList.Add(new Instruction(operatorIL));
                        DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.special);
                    }
                    else if (firstComponent == 0xfb)
                    {
                        Operators operatorIL = Operators.ORFUNC;
                        Memory.Program.InstructionList.Add(new Instruction(operatorIL));
                        DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.special);
                        IsLoad   = false;
                        IsLoaded = false;
                    }
                    else if (firstComponent == 0x41 && secondComponent >= 0x60 && secondComponent <= 0x6f)
                    {
                        Elements  operand    = new Elements();
                        Operators operatorIL = Operators.HELPERSET;
                        operand.symbol = Symbol.VAR;

                        operand.name = "Var" + (secondComponent - 0x60).ToString();
                        if (!Memory.Data.var.ContainsKey(operand.name))
                        {
                            Memory.Data.var.Add(operand.name, false);
                        }
                        else
                        {
                            Memory.Data.var[operand.name] = false;
                        }
                        //Operators operatorIL = Operators.HELPERSET;
                        DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.special);
                        Memory.Program.InstructionList.Add(new Instruction(operatorIL, operand));
                    }
                    else if (firstComponent == 0x00 && secondComponent >= 0x60 && secondComponent <= 0x6f)
                    {
                        //helper = Helper.get;
                        Elements  operand    = new Elements();
                        Operators operatorIL = Operators.HELPERGET;
                        operand.symbol = Symbol.VAR;
                        operand.name   = "Var" + (secondComponent - 0x60).ToString();
                        DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.standard);
                        Memory.Program.InstructionList.Add(new Instruction(operatorIL, operand));
                    }
                    else if (firstComponent == 0x00 && secondComponent == 0x14)
                    {
                    }
                    else if (firstComponent == 0x10 && secondComponent == 0x66)
                    {
                        Operators operatorIL = Operators.HELPERUP;
                        Memory.Program.InstructionList.Add(new Instruction(operatorIL));
                        DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.standard);
                    }
                    else if (firstComponent == 0x68 && secondComponent == 0x2d)
                    {
                        Operators operatorIL = Operators.NOT;
                        Memory.Program.InstructionList.Add(new Instruction(operatorIL));
                        DiagnosticData.AddData(counter, DiagnosticData.Operation.None, DiagnosticData.Symbol.standard);
                    }
                    else
                    {
                        Instruction instruction = CreateInstructionBasedOnElement(firstComponent, secondComponent, counter);
                        if (instruction != null)
                        {
                            Memory.Program.InstructionList.Add(instruction);
                        }
                    }
                    counter += 2;
                }
                IsLoad   = false;
                IsLoaded = false;
            }
        }