Пример #1
0
        private static void Main(string[] args)
        {
            var input  = File.OpenRead(path: args[0]);
            var reader = new ExtBinaryReader(input);

            var moduleLayout = new BinaryModuleLayout();

            moduleLayout.Read(reader);

            input.Close();

            var storage = new InterpreterStorage()
            {
                instructions = new List <IInstruction>
                {
                    new NopInstruction(),
                    new PrintInstruction(),
                    new MovInstruction(),
                    new AddInstruction(),
                    new JumpLessInstruction(),
                    new HaltInstruction(),
                    new InputInstruction(),
                    new JumpGreaterInstruction(),
                    new JumpEqualsInstruction(),
                    new JumpInstruction(),
                    new PushInstruction(),
                    new PopInstruction(),
                },
                stack     = new Stack <int>(),
                module    = new BinaryModule(moduleLayout),
                cursor    = 0,
                registers = new int[4]
            };

            var interpreter = new Interpreter(storage);

            interpreter.Run();
        }
Пример #2
0
 public Section(SectionLayout sectionLayout, BinaryModuleLayout moduleLayout)
 {
     Name = moduleLayout.strings[sectionLayout.bankNameIndex].str;
     Blob = moduleLayout.blobs[sectionLayout.blobIndex].data;
 }