Пример #1
0
        static void Branch()
        {
            int    target;
            string name;
            Label  lab;

            if (la.kind == brn_Sym)
            {
                Get();
            }
            else if (la.kind == bze_Sym)
            {
                Get();
            }
            else
            {
                SynErr(67);
            }
            string mnemonic = token.val;

            IO.Write(token.val);
            IO.Write("", 5);

            if (la.kind == number_Sym)
            {
                Number(out target);
                CodeGen.TwoWord(mnemonic, target);
            }
            else if (la.kind == identifier_Sym)
            {
                Ident(out name);
                LabelEntry entry = LabelTable.Find(name);
                if (entry == null)
                {
                    lab = new Label(!known);
                    int lineNumber = token.line;
                    LabelTable.Insert(new LabelEntry(name, lab, lineNumber));
                }
                else
                {
                    lab = entry.label;
                    entry.AddReference(token.line);
                }
                IO.Write(name);
                IO.Write("", 10 - name.Length);
                CodeGen.Branch(mnemonic, lab);
            }
            else
            {
                SynErr(68);
            }
        }
Пример #2
0
        static void TwoWord()
        {
            int value;

            if (la.kind == dsp_Sym)
            {
                Get();
            }
            else if (la.kind == ldc_Sym)
            {
                Get();
            }
            else if (la.kind == lda_Sym)
            {
                Get();
            }
            else if (la.kind == ldl_Sym)
            {
                Get();
            }
            else if (la.kind == stl_Sym)
            {
                Get();
            }
            else
            {
                SynErr(65);
            }
            string mnemonic = token.val;

            IO.Write(token.val);
            IO.Write("", 8 - token.val.Length);
            if (la.kind == number_Sym)
            {
                Number(out value);
                CodeGen.TwoWord(mnemonic, value);
            }
            else if (la.kind == identifier_Sym)
            {
                Variable(out value);
                CodeGen.TwoWord(mnemonic, value);
            }
            else
            {
                SynErr(66);
            }
        }