Exemplo n.º 1
0
 public NUnitTestDisassembler()
 {
     Controller = new TestController
     {
         Disassembler = new Disassembler()
     };
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:DotNetAsm.ScopeBlockHandler"/> class.
 /// </summary>
 /// <param name="controller">The <see cref="T:DotNetAsm.IAssemblyController"/> of the handler.</param>
 public ScopeBlockHandler(IAssemblyController controller)
     : base(controller)
 {
     Reserved.DefineType("Scoped", ConstStrings.OPEN_SCOPE, ConstStrings.CLOSE_SCOPE);
     _scope          = new Stack <string>();
     _processedLines = new List <SourceLine>();
     _anon           = 0;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructs a Preprocessor object.
 /// </summary>
 /// <param name="controller">The assembly controller.</param>
 /// <param name="checkSymbol">A function to check for symbols such as labels or variables.</param>
 public Preprocessor(IAssemblyController controller,
                     Func <string, bool> checkSymbol)
     : base(controller)
 {
     FileRegistry    = new HashSet <string>();
     _symbolNameFunc = checkSymbol;
     Reserved.DefineType("Directives", ".binclude", ".include", ".comment", ".endcomment");
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructs a DotNetAsm.MiscAssembler class.
 /// </summary>
 /// <param name="controller">The DotNetAsm.IAssemblyController to associate</param>
 public MiscAssembler(IAssemblyController controller) :
     base(controller)
 {
     Reserved.DefineType("Directives",
                         "assert", ".eor", ".echo", ".target",
                         ".error", ".errorif",
                         ".warnif", ".warn"
                         );
 }
        /// <summary>
        /// Constructs an instance of a <see cref="T:DotNetAsm.RepetitionHandler"/> object.
        /// </summary>
        /// <param name="controller">The <see cref="T:DotNetAsm.IAssemblyController"/> for this
        /// handler.</param>
        public RepetitionHandler(IAssemblyController controller) :
            base(controller)
        {
            Reserved.DefineType("Directives", ".repeat", ".endrepeat");

            _currBlock      =
                _rootBlock  = new RepetitionBlock();
            _levels         = 0;
            _processedLines = new List <SourceLine>();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:DotNetAsm.MacroHandler"/> class.
 /// </summary>
 /// <param name="controller">A <see cref="T:DotNetAsm.IAssemblyController"/>.</param>
 /// <param name="instructionFcn">The lookup function to validate whether the name is an instruction or directive.</param>
 public MacroHandler(IAssemblyController controller, Func <string, bool> instructionFcn)
     : base(controller)
 {
     Reserved.DefineType("Directives", ".macro", ".endmacro", ".segment", ".endsegment");
     _macros           = new Dictionary <string, Macro>(controller.Options.StringComparar);
     _expandedSource   = new List <SourceLine>();
     _macroDefinitions = new Stack <List <SourceLine> >();
     _instructionFcn   = instructionFcn;
     _definitions      = new Stack <SourceLine>();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Constructs an instance of the <see cref="T:DotNetAsm.Disassembler"/> class.
 /// </summary>
 /// <param name="controller">The assembly controller.</param>
 public Disassembler(IAssemblyController controller)
     : base(controller)
 {
     PrintingOn = true;
     Reserved.DefineType("Blocks", ConstStrings.OPEN_SCOPE, ConstStrings.CLOSE_SCOPE);
     Reserved.DefineType("Directives",
                         ".cpu", ".elif", ".else", ".endif", ".eor", ".error", ".errorif", ".if", ".ifdef",
                         ".warnif", ".relocate", ".pseudopc", ".realpc", ".endrelocate", ".warn",
                         ".m16", ".m8", ".x16", ".x8", ".mx16", ".mx8"
                         );
 }
Exemplo n.º 8
0
        /// <summary>
        /// Constructs an instance of the class implementing the base class.
        /// </summary>
        /// <param name="controller">The <see cref="T:DotNetAsm.IAssemblyController"/>.</param>
        protected AssemblerBase(IAssemblyController controller)
        {
            Controller = controller;

            if (controller == null)
            {
                Reserved = new ReservedWords();
            }
            else
            {
                Reserved = new ReservedWords(Controller.Options.StringComparar);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Constructs an instance of a <see cref="T:DotNetAsm.PseudoAssembler"/> line assembler.
        /// </summary>
        /// <param name="controller">The assembly controller</param>
        /// <param name="reservedSymbolFunc">A function callback to determine if the given token
        /// is a symbol name.</param>
        public PseudoAssembler(IAssemblyController controller, Func <string, bool> reservedSymbolFunc) :
            base(controller)
        {
            _includedBinaries = new HashSet <BinaryFile>();

            Reserved.DefineType("PseudoOps",
                                ".addr", ".align", ".binary", ".byte", ".sbyte",
                                ".dint", ".dword", ".fill", ".lint", ".long",
                                ".sint", ".typedef", ".word"
                                );
            _typeDefs       = new Dictionary <string, string>();
            _reservedSymbol = reservedSymbolFunc;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DotNetAsm.SymbolManager"/> class.
        /// </summary>
        /// <param name="controller">The <see cref="DotNetAsm.IAssemblyController"/> for
        /// this symbol manager.</param>
        public SymbolManager(IAssemblyController controller)
        {
            _controller = controller;

            Variables = new VariableCollection(controller.Options.StringComparar, controller.Evaluator);

            Labels = new LabelCollection(controller.Options.StringComparar);

            Labels.AddCrossCheck(Variables);
            Variables.AddCrossCheck(Labels);

            _anonLines = new Dictionary <int, SourceLine>();
        }
 /// <summary>
 /// Constructs an instance of the <see cref="T:DotNetAsm.ForNextHandler"/>.
 /// </summary>
 /// <param name="controller">The <see cref="T:DotNetAsm.IAssemblyController"/> for this
 /// handler.</param>
 public ForNextHandler(IAssemblyController controller)
     : base(controller)
 {
     Reserved.DefineType("Directives",
                         ".for", ".next", ".break",
                         "@@ for @@", "@@ next @@", "@@ break @@"
                         );
     _currBlock      =
         _rootBlock  = new ForNextBlock();
     _breakBlock     = null;
     _levels         = 0;
     _processedLines = new List <SourceLine>();
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initialize a new instance of a <see cref="T:DotNetAsm.ConditionHandler"/> class.
 /// </summary>
 /// <param name="controller">The <see cref="T:DotNetAsm.IAssemblyController"/> associated to this
 /// class.</param>
 public ConditionHandler(IAssemblyController controller)
     : base(controller)
 {
     Reserved.DefineType("Conditions",
                         ".if", ".ifdef", ".ifndef",
                         ".elif", ".elifdef", ".elifndef",
                         ".else", ".endif"
                         );
     _condLevel      = 0;
     _condStack      = new Stack <string>();
     _resultStack    = new Stack <bool>();
     _processedLines = new List <SourceLine>();
     _doNotAsm       = false;
 }
        /// <summary>
        /// Constructs a <see cref="T:DotNetAsm.StringAssemblerBase"/> class.
        /// </summary>
        /// <param name="controller">The <see cref="T:DotNetAsm.IAssemblyController"/> to associate</param>
        public StringAssemblerBase(IAssemblyController controller) :
            base(controller)
        {
            Reserved.DefineType("Directives",
                                ".cstring", ".lsstring", ".nstring", ".pstring", ".string"
                                );

            Reserved.DefineType("Encoding", ".encoding", ".map", ".unmap");

            _regStrFunc = new Regex(@"str(\(.+\))",
                                    Controller.Options.RegexOption | RegexOptions.Compiled);

            _regFmtFunc = new Regex(@"format(\(.+\))",
                                    Controller.Options.RegexOption | RegexOptions.Compiled);

            _regEncName = new Regex("^" + Patterns.SymbolBasic + "$",
                                    Controller.Options.RegexOption | RegexOptions.Compiled);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructs an instance of a 6502 line assembler. This assembler will output valid
        /// 6502 assembly to instructions.
        /// </summary>
        /// <param name="controller">The assembly controller.</param>
        public Asm6502(IAssemblyController controller) :
            base(controller)
        {
            Reserved.DefineType("Branches",
                                "bcc", "bcs", "beq", "bmi", "bne", "bpl", "bra", "bvc",
                                "bvs", "bra"
                                );

            Reserved.DefineType("Branches16",
                                "brl", "per"
                                );

            Reserved.DefineType("ImpliedAccumulator",
                                "asl", "lsr", "rol", "ror"
                                );

            Reserved.DefineType("Mnemonics",
                                "adc", "anc", "and", "ane", "arr", "asl", "asr", "bit",
                                "brk", "clc", "cld", "cli", "clv", "cmp", "cop", "cpx",
                                "cpy", "dcp", "dex", "dey", "dop", "eor", "inx", "iny",
                                "isb", "jam", "jml", "jmp", "jsl", "jsr", "las", "lax",
                                "lda", "ldx", "ldy", "lsr", "nop", "ora", "pea", "pei",
                                "pha", "phb", "phd", "phk", "php", "phx", "phy", "pla",
                                "plb", "pld", "plp", "plx", "ply", "rep", "rla", "rol",
                                "ror", "rra", "rti", "rtl", "rts", "sbc", "sax", "sec",
                                "sed", "sei", "sep", "shx", "shy", "slo", "sre", "sha",
                                "sta", "stp", "stx", "sty", "stz", "tas", "tax", "tay",
                                "tcd", "tcs", "tdc", "top", "trb", "tsb", "tsc", "tsx",
                                "txa", "txs", "txy", "tya", "tyx", "xba", "xce", "wai"
                                );

            Reserved.DefineType("ImpliedAC02",
                                "dec", "inc"
                                );

            Reserved.DefineType("MoveMemory",
                                "mvn", "mvp"
                                );

            Reserved.DefineType("ReturnAddress",
                                ".rta"
                                );

            Reserved.DefineType("LongShort",
                                ".m16", ".m8", ".x16", ".x8", ".mx16", ".mx8"
                                );

            Controller.AddSymbol("a");
            Controller.CpuChanged += SetCpu;

            // set architecture specific encodings
            Controller.Encoding.SelectEncoding("petscii");
            Controller.Encoding.Map("az", 'A');
            Controller.Encoding.Map("AZ", 0xc1);
            Controller.Encoding.Map('£', '\\');
            Controller.Encoding.Map('↑', '^');
            Controller.Encoding.Map('←', '_');
            Controller.Encoding.Map('▌', 0xa1);
            Controller.Encoding.Map('▄', 0xa2);
            Controller.Encoding.Map('▔', 0xa3);
            Controller.Encoding.Map('▁', 0xa4);
            Controller.Encoding.Map('▏', 0xa5);
            Controller.Encoding.Map('▒', 0xa6);
            Controller.Encoding.Map('▕', 0xa7);
            Controller.Encoding.Map('◤', 0xa9);
            Controller.Encoding.Map('├', 0xab);
            Controller.Encoding.Map('└', 0xad);
            Controller.Encoding.Map('┐', 0xae);
            Controller.Encoding.Map('▂', 0xaf);
            Controller.Encoding.Map('┌', 0xb0);
            Controller.Encoding.Map('┴', 0xb1);
            Controller.Encoding.Map('┬', 0xb2);
            Controller.Encoding.Map('┤', 0xb3);
            Controller.Encoding.Map('▎', 0xb4);
            Controller.Encoding.Map('▍', 0xb5);
            Controller.Encoding.Map('▃', 0xb9);
            Controller.Encoding.Map('✓', 0xba);
            Controller.Encoding.Map('┘', 0xbd);
            Controller.Encoding.Map('━', 0xc0);
            Controller.Encoding.Map('♠', 0xc1);
            Controller.Encoding.Map('│', 0xc2);
            Controller.Encoding.Map('╮', 0xc9);
            Controller.Encoding.Map('╰', 0xca);
            Controller.Encoding.Map('╯', 0xcb);
            Controller.Encoding.Map('╲', 0xcd);
            Controller.Encoding.Map('╱', 0xce);
            Controller.Encoding.Map('●', 0xd1);
            Controller.Encoding.Map('♥', 0xd3);
            Controller.Encoding.Map('╭', 0xd5);
            Controller.Encoding.Map('╳', 0xd6);
            Controller.Encoding.Map('○', 0xd7);
            Controller.Encoding.Map('♣', 0xd8);
            Controller.Encoding.Map('♦', 0xda);
            Controller.Encoding.Map('┼', 0xdb);
            Controller.Encoding.Map('π', 0xde);
            Controller.Encoding.Map('◥', 0xdf);

            Controller.Encoding.SelectEncoding("cbmscreen");
            Controller.Encoding.Map("@Z", '\0');
            Controller.Encoding.Map("az", 'A');
            Controller.Encoding.Map('£', '\\');
            Controller.Encoding.Map('π', '^'); // π is $5e in unshifted
            Controller.Encoding.Map('↑', '^'); // ↑ is $5e in shifted
            Controller.Encoding.Map('←', '_');
            Controller.Encoding.Map('▌', '`');
            Controller.Encoding.Map('▄', 'a');
            Controller.Encoding.Map('▔', 'b');
            Controller.Encoding.Map('▁', 'c');
            Controller.Encoding.Map('▏', 'd');
            Controller.Encoding.Map('▒', 'e');
            Controller.Encoding.Map('▕', 'f');
            Controller.Encoding.Map('◤', 'i');
            Controller.Encoding.Map('├', 'k');
            Controller.Encoding.Map('└', 'm');
            Controller.Encoding.Map('┐', 'n');
            Controller.Encoding.Map('▂', 'o');
            Controller.Encoding.Map('┌', 'p');
            Controller.Encoding.Map('┴', 'q');
            Controller.Encoding.Map('┬', 'r');
            Controller.Encoding.Map('┤', 's');
            Controller.Encoding.Map('▎', 't');
            Controller.Encoding.Map('▍', 'u');
            Controller.Encoding.Map('▃', 'y');
            Controller.Encoding.Map('✓', 'z');
            Controller.Encoding.Map('┘', '}');
            Controller.Encoding.Map('━', '@');
            Controller.Encoding.Map('♠', 'A');
            Controller.Encoding.Map('│', 'B');
            Controller.Encoding.Map('╮', 'I');
            Controller.Encoding.Map('╰', 'J');
            Controller.Encoding.Map('╯', 'K');
            Controller.Encoding.Map('╲', 'M');
            Controller.Encoding.Map('╱', 'N');
            Controller.Encoding.Map('●', 'Q');
            Controller.Encoding.Map('♥', 'S');
            Controller.Encoding.Map('╭', 'U');
            Controller.Encoding.Map('╳', 'V');
            Controller.Encoding.Map('○', 'W');
            Controller.Encoding.Map('♣', 'X');
            Controller.Encoding.Map('♦', 'Z');
            Controller.Encoding.Map('┼', '[');
            Controller.Encoding.Map('◥', '_');

            Controller.Encoding.SelectEncoding("atascreen");
            Controller.Encoding.Map(" _", '\0');

            Controller.Encoding.SelectDefaultEncoding();

            ConstructOpcodeTable();

            _filteredOpcodes = _opcodes.Where(o => o.Value.CPU.Equals("6502")).ToDictionary(k => k.Key, k => k.Value, Controller.Options.StringComparar);
        }
Exemplo n.º 15
0
 protected NUnitTestAsm6502Base()
 {
     Controller    = new TestDotNetAsm.TestController();
     LineAssembler = new Asm6502.Net.Asm6502(Controller);
 }
Exemplo n.º 16
0
 public NUnitTestAsm6502Illegal()
 {
     Controller    = new TestDotNetAsm.TestController();
     LineAssembler = new Asm6502.Net.Asm6502(Controller);
 }