コード例 #1
0
        /// <summary>
        /// Returns a TDIL directive that represents the given action <paramref name="instruction"/> string based on the given
        /// associated <paramref name="translationInstruction"/>.
        /// </summary>
        /// <param name="instruction">Instruction string to convert</param>
        /// <param name="translationInstruction">Translation instruction to convert the instruction</param>
        /// <returns>TDIL directive</returns>
        /// <exception cref="ArgumentNullException">If any argument is NULL</exception>
        public string ToDirective(string instruction, IBuddyTranslationInstruction translationInstruction)
        {
            if (string.IsNullOrEmpty(instruction))
            {
                throw new ArgumentNullException(nameof(instruction));
            }
            if (translationInstruction == null)
            {
                throw new ArgumentNullException(nameof(translationInstruction));
            }

            using (ParameterAdjustmentTable pat = ParameterAdjustmentTable.Create()) {
                string processedInstruction = pat.Process(instruction);

                Dictionary <string, IPatternParameter> paramCache = new Dictionary <string, IPatternParameter>();
                IInstructionEvaluationResult           evaRslt    = _instructionEvaluator.Evaluate(processedInstruction, _instructionTable[translationInstruction], paramCache);
                if (evaRslt.IsError)
                {
                    // TODO
                }

                string result = _instructionFormatter.ToString(translationInstruction, paramCache);
                return(result);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Tokenizer            t     = new Tokenizer();
            InstructionTree      i     = new InstructionTree();
            InstructionEvaluator ieval = new InstructionEvaluator();

            string[] lines = ReadFile("..\\..\\practical_z80.txt");

            AsmVars.LineNo++;
            foreach (string line in lines)
            {
                if (!t.Tokenize(line))
                {
                    break;
                }
                if (!i.Derive(t.tokens.ToArray()))
                {
                    break;
                }

                //DebugTree(i, 0);

                if (!ieval.Evaluate(i))
                {
                    break;
                }

                foreach (byte b in ieval.code)
                {
                    Console.Write(String.Format("{0,0:X2} ", b));
                }

                AsmVars.LineNo++;
            }

            Console.ReadKey();
        }