Пример #1
0
        public void IOManagerTests_WriteToIODevice_Success()
        {
            IOManager io = new IOManager(100);

            Device d1 = new Device()
            {
                Id = 1
            };
            Device d2 = new Device()
            {
                Id = 2
            };

            io.AddIODevice(80, d1);
            io.AddIODevice(82, d2);

            MicroSimulator micro = new MicroSimulator(
                new VirtualMemory(new string[] { }),
                io
                );

            micro.WriteToMemory(80, "F3");
            micro.WriteToMemory(82, "08");

            Console.WriteLine(d1);
            Console.WriteLine(d2);

            Assert.AreEqual("Device[Id: 1, Data: 243]", d1.ToString());
            Assert.AreEqual("Device[Id: 2, Data: 8]", d2.ToString());

            Console.WriteLine(micro.ReadFromMemory(80));
            Console.WriteLine(micro.ReadFromMemory(82));
        }
Пример #2
0
        public void FlowControlOperationsTests_NOP_Success()
        {
            //init
            micro.StackPointer   = 100;
            micro.ProgramCounter = 12;

            string savedAddresInMemory = "FF";

            micro.WriteToMemory(100, savedAddresInMemory);
            MCInstructionF1 i1 = new MCInstructionF1(31, "11101", null);

            //execute
            InstructionSetExe.ExecuteInstruction(i1, micro);

            Assert.AreEqual(100, micro.StackPointer);
            Assert.AreEqual(14, micro.ProgramCounter);
        }
Пример #3
0
        public void DataMovOperationsTests_LoadVMValueToRegister_Success()
        {
            micro.WriteToMemory(2, "05");
            micro.WriteToMemory(3, "07");

            // LOAD R2 02
            MCInstructionF2 i1 = new MCInstructionF2(3, "00000", "010", "00000010");

            // LOAD R2 03
            MCInstructionF2 i2 = new MCInstructionF2(3, "00000", "011", "00000011");

            InstructionSetExe.ExecuteInstruction(i1, micro);

            Console.WriteLine($"Registers after Execution #1 -> {micro.MicroRegisters}");

            Assert.AreEqual("05", micro.MicroRegisters.GetRegisterValue(2));

            InstructionSetExe.ExecuteInstruction(i2, micro);


            Assert.AreEqual("07", micro.MicroRegisters.GetRegisterValue(3));

            Console.WriteLine($"Registers after Execution #2 -> {micro.MicroRegisters}");
        }