Ejemplo n.º 1
0
        public void MCLoaderTests_ExecuteOneInstruction_Success()
        {
            string expected = "MCInstructionF3[InstructionAddressDecimal: (decimal)'0', opcode:'21', AddressParamHex:'06']";

            VirtualMemory vm = new VirtualMemory(new string[] { "A8 06" });

            MCLoader l = new MCLoader(vm, new MicroSimulator(vm));

            IMCInstruction i = l.NextInstruction();

            Console.WriteLine(i);

            Assert.AreEqual(expected, i.ToString());
        }
Ejemplo n.º 2
0
        private string GetPrettyInstruction(IMCInstruction instruction)
        {
            if (instruction == null)
            {
                return("");
            }

            string addressHex = UnitConverter.IntToHex(instruction.InstructionAddressDecimal, defaultWidth: 3);

            string contentHex = VirtualMemory.GetContentsInHex(instruction.InstructionAddressDecimal) +
                                VirtualMemory.GetContentsInHex(instruction.InstructionAddressDecimal + 1);

            return($"{addressHex}: {contentHex}: {instruction.ToString()}");
        }
Ejemplo n.º 3
0
        public void MCLoaderTests_LoadObjectFile_Success()
        {
            string[] lines = FileManager.Instance.ToReadFile(machineCodeFile);

            Assert.IsNotNull(lines);

            string[] expected =
            {
                "MCInstructionF3[InstructionAddressDecimal: (decimal)'0', opcode:'21', AddressParamHex:'06']",
                "MCInstructionF2[InstructionAddressDecimal: (decimal)'6', opcode:'0', Ra:'1', AddressParamHex:'02']",
                "MCInstructionF2[InstructionAddressDecimal: (decimal)'8', opcode:'0', Ra:'2', AddressParamHex:'03']",
                "MCInstructionF1[InstructionAddressDecimal: (decimal)'10', opcode:'25', Ra:'1', Rb:'2', Rc:'0']",
                "MCInstructionF3[InstructionAddressDecimal: (decimal)'12', opcode:'21', AddressParamHex:'12']",
                "MCInstructionF2[InstructionAddressDecimal: (decimal)'18', opcode:'3', Ra:'1', AddressParamHex:'04']",
                "MCInstructionF2[InstructionAddressDecimal: (decimal)'20', opcode:'1', Ra:'3', AddressParamHex:'08']",
                "MCInstructionF3[InstructionAddressDecimal: (decimal)'22', opcode:'21', AddressParamHex:'16']",
                "MCInstructionF3[InstructionAddressDecimal: (decimal)'22', opcode:'21', AddressParamHex:'16']",
                "MCInstructionF3[InstructionAddressDecimal: (decimal)'22', opcode:'21', AddressParamHex:'16']"
            };

            VirtualMemory vm = new VirtualMemory(lines);

            Console.WriteLine(vm);

            MicroSimulator micro = new MicroSimulator(vm);

            MCLoader l = new MCLoader(vm, micro);

            int i = 0;

            while (i < 10)
            {
                IMCInstruction instruction = l.NextInstruction();

                Console.WriteLine(instruction);

                Assert.AreEqual(expected[i], instruction.ToString());

                i++;
            }
        }