Esempio n. 1
0
        public void FindAllLabels(Stream preprocessedFile, Part part)
        {
            StreamReader reader = new StreamReader(preprocessedFile);
            string       line;

            while ((line = reader.ReadLine()) != null)
            {
                if (line.Length > 0)
                {
                    if (line.Contains("."))
                    {
                        part.SetCurrentSection(new Section(line));
                    }
                    else if (line.Contains(":"))
                    {
                        string[] lines = line.Trim().Split(new char[] { ':', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        string   name  = lines[0].Trim('!', '&');

                        if (line.StartsWith("!"))
                        {
                            part.CurrentFunctionName = name;
                            part.AddFunction(new Function(line));
                        }
                        else if (line.StartsWith("!"))
                        {
                            part.CurrentFunctionName = name;
                        }
                        else
                        {
                            part.AddLabel(new Label(line, part));
                        }
                    }
                    else if (part.GetCurrentSection().Name == "code")
                    {
                        part.AddCode(new byte[instructionSet.ParseAndGetSize(line)]);
                    }
                }
            }
        }