Ejemplo n.º 1
0
        public Processor(RealMemory realMemory, ChannelTool channelTool, VirtualMemory virtualMemory = null, Pager pager = null)
        {
            RealMemory           = realMemory;
            VirtualMemory        = virtualMemory;
            ChannelTool          = channelTool;
            Pager                = pager;
            FileManager          = new FileManager(RealMemory, this);
            CommandInterpretator = new CommandInterpretator(this, virtualMemory);
            Interruptor          = new Interruptor(this, virtualMemory, FileManager, RealMemory);

            // STOPS PROGRAM AFTER MAX STEP COUNT
            UseMaxStep = true;
            // CURRENT STEP
            CurrentStep = 0;

            registers = new Dictionary <string, Register>
            {
                { "R1", new Register(value: 0) },                                           // Word length general register
                { "R2", new Register(value: 0) },                                           // Word length general register
                { "IC", new HexRegister(2) },                                               // Current command adress in memory register
                { "PTR", new HexRegister(4) },                                              // Page table adress register
                { "SF", new StatusFlagRegister() },                                         // Aritmetic operation logic values
                { "MODE", new ChoiceRegister('N', 'S') },                                   // Processor mode "N" - user, "S" - supervisor
                { "PI", new ChoiceRegister(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) },     // Program interuptor
                { "SI", new ChoiceRegister(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) },     // Supervisor interuptor
                { "TI", new HexRegister(Utility.TIMER_VALUE, 1) }                           // Timer interuptor
            };
        }
Ejemplo n.º 2
0
        public bool Step()
        {
            char[] stepCommand   = VirtualMemory.GetValue(GetICRegisterValue());
            char[] nextCommand   = VirtualMemory.GetValue(GetICRegisterValue() + 1);
            string stringCommand = new string(stepCommand);
            string stringNext    = new string(nextCommand);

            Console.WriteLine("STEP: " + stringCommand + " (NEXT: " + stringNext + ")");
            bool commandResult = CommandInterpretator.ParseCommand(stepCommand);

            if (Test())
            {
                if (!Interrupt())
                {
                    FileManager.CloseAll(); return(false);
                }
            }

            if (ChangedIC)
            {
                ChangedIC = false;
            }
            else
            {
                IncICRegisterValue(1);
            }

            if (UseMaxStep && CurrentStep++ >= Utility.MAX_STEPS)
            {
                return(StopProgram());
            }

            return(commandResult);
        }
Ejemplo n.º 3
0
 public void SetVirtualMemory(VirtualMemory virtualMemory, Pager pager)
 {
     VirtualMemory = virtualMemory;
     Pager         = pager;
     SetPTRRegisterValue(pager.GetPTR());
     CommandInterpretator.SetVirtualMemory(virtualMemory);
     Interruptor.SetVirtualMemory(virtualMemory);
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            IRepository         repository         = new UnitRepository();
            IUnitFactory        unitFactory        = new UnitFactory();
            ICommandInterpreter commandInterpreter = new CommandInterpretator(repository, unitFactory);
            IRunnable           engine             = new Engine(commandInterpreter);

            engine.Run();
        }
Ejemplo n.º 5
0
        private static void Main()
        {
            var interpretator = new CommandInterpretator();

            var input = Console.ReadLine();

            while (input != "END")
            {
                interpretator.ParseCommand(input);
                input = Console.ReadLine();
            }
        }
Ejemplo n.º 6
0
        private string InterpredCommand(string[] data, string commandName)
        {
            var commandInterpretator = new CommandInterpretator(repository, unitFactory);

            return(commandInterpretator.InterpretCommand(data, commandName).Execute());
        }
Ejemplo n.º 7
0
 public Engine()
 {
     this._cmdInterpretator = new CommandInterpretator();
 }