Пример #1
0
        public void Dump()
        {
            switch (LineType)
            {
            case AsmLineType.AssignmentLine:
                Trace.Write($"{Label} {Directive} ${Address}");
                if (Type != "")
                {
                    Trace.Write(" " + Type);
                }
                if (Comment != "")
                {
                    Trace.Write(" " + Comment);
                }
                Trace.WriteLine("");
                break;

            case AsmLineType.DirectiveLine:
                DirectiveArgument arg = (DirectiveArgument)Argument;
                if (Directive == ".fill")
                {
                    //Trace.WriteLine( $"${this.Address4} .fill {arg.FillCount},{arg.FillValue}" );
                }
                break;
            }
        }
Пример #2
0
        private void MatchLine()
        {
            Empty = Line.Trim() == "";
            if (Empty)
            {
                Matched = false;
                return;
            }

            bool success = false;

            foreach (AsmLineTemplate template in _templates)
            {
                Match match = template.Regex.Match(Line);
                success = match.Success;
                if (success)
                {
                    // step 1: save information about line (up to opcode/directive)
                    LineType = template.LineType;
                    RegexHelpers.Transfer(this, match, template.Values);

                    // step 2: save argument of opcode/directive
                    string rest = Line.Substring(match.Length).Trim();
                    switch (LineType)
                    {
                    case AsmLineType.DirectiveLine:
                        Argument = new DirectiveArgument(Directive, ref rest);
                        Dump();
                        break;

                    case AsmLineType.OpcodeLine:
                        Argument = new OperandArgument(Opcode, ref rest);
                        break;
                    }

                    // We use "Comment" for both the complete comment line, as well as tailing ; comments
                    // must not overwrite the comment line w/ an (then empty/null) tailing comment
                    if (LineType != AsmLineType.CommentLine)
                    {
                        Comment = RegexHelpers.MatchValue(CommentRegex, rest, "Comment");
                    }
                    break;
                }
            }
            Matched = success;
        }