Exemple #1
0
        static void Main(string[] args)
        {
            VirturalMachine vm = new VirturalMachine();

            var file = File.ReadAllText("/home/shr/codes/courses/Orga/final/mips_sim/code.mips");
            var a    = ASM.ASM.InstsToCoe(Parser.Parser.Parse(file).insts);

            File.WriteAllText("/home/shr/codes/courses/Orga/final/mips_sim/code.coe", a);
            vm.LoadInstructions(file);
            while (vm.Exec())
            {
                ;
            }
            Console.WriteLine("Hello World!");
        }
        void ApplyMergeCall(int[] input, int[] output, int dir, bool move, int score, bool win)
        {
            int baseAddr = 2048;

            for (int i = 0; i < 16; i++)
            {
                vm.SaveWord(baseAddr + i * 4, input[i]);
            }
            vm.SetReg("s0", dir);
            vm.ExecSingleInstruction("j apply_merge");
            while (vm.Exec())
            {
                ;
            }
            int[] o = new int[16];
            for (int i = 0; i < 16; i++)
            {
                o[i] = vm.LoadWord(baseAddr + i * 4);
            }
            Assert.Equal(String.Join(",", output), String.Join(",", o));
            Assert.Equal(win, vm.GetReg("s7") != 0);
            Assert.Equal(move, vm.GetReg("s6") != 0);
            Assert.Equal(score, vm.GetReg("s5"));
        }