Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of the assembly service.
 /// </summary>
 /// <param name="options">The parsed options.</param>
 public AssemblyServices(Options options)
 {
     PassNeeded             = true;
     CurrentPass            = -1;
     IsReserved             = new List <Func <StringView, bool> >();
     InstructionLookupRules = new List <Func <StringView, bool> > {
         sv => sv[0] == '.'
     };
     Options      = options;
     OutputFormat = Options.Format;
     CPU          = Options.CPU;
     Encoding     = new AsmEncoding(Options.CaseSensitive);
     Evaluator    = new Evaluator(Options.CaseSensitive)
     {
         SymbolEvaluator = EvaluateSymbol
     };
     SymbolManager = new SymbolManager(options.CaseSensitive, Evaluator);
     SymbolManager.AddValidSymbolNameCriterion(s => !Evaluator.IsReserved(s));
     Log    = new ErrorLog(Options.WarningsAsErrors);
     Output = new BinaryOutput(true, Options.CaseSensitive, Options.LongAddressing);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the <see cref="Assembler"/> class for use. Repeated calls will reset symbol labels and variables,
        /// assembling pass and listing printing states, the binary output, and the error log.
        /// </summary>
        /// <param name="args">The command line arguments passed by the user.</param>
        public static void Initialize(string[] args)
        {
            PassChanged            = null;
            PrintOff               = false;
            PassNeeded             = true;
            _pass                  = -1;
            LineIterator           = null;
            Options                = new CommandLineOptions();
            IsReserved             = new List <Func <string, bool> >();
            InstructionLookupRules = new List <Func <string, bool> >();
            if (args != null)
            {
                Options.ParseArgs(args);
            }


            Encoding      = new AsmEncoding(Options.CaseSensitive);
            SymbolManager = new SymbolManager(Options.CaseSensitive);
            Evaluator.Initialize();
            Evaluator.AddFunctionEvaluator(SymbolManager);
            Log    = new ErrorLog();
            Output = new BinaryOutput();
        }