Beispiel #1
0
        public void ExecuteTestAddBxSiAl()
        {
            var memory = new byte[] { 0x00, 0x00, 0x4 };
            var cpu    = new InterpretCpu(memory);

            cpu.SetRegister(Reg8.al, 8);
            cpu.SetRegister(Reg16.si, 1);
            cpu.SetRegister(Reg16.bx, 1);
            cpu.Execute(0, 2);
            Assert.AreEqual(12, memory[2]);
        }
Beispiel #2
0
        private InterpretCpu RunAsmTest(string filename, Action <InterpretCpu> setup = null)
        {
            var filePath = TestContext.CurrentContext.TestDirectory + $"/TestAsm/{filename}";

            if (!File.Exists($"{filePath}.o"))
            {
                var compile = Process.Start("nasm", $"{filePath}.asm -o {filePath}.o");
                compile.WaitForExit();
            }

            var file   = File.ReadAllBytes($"{filePath}.o");
            var memory = new byte[65536];

            file.CopyTo(memory, 0);

            var cpu = new InterpretCpu(memory);

            cpu.SetRegister(Reg16.sp, 0xffff);

            if (setup != null)
            {
                setup.Invoke(cpu);
            }

            cpu.Execute(0, file.Length);
            return(cpu);
        }
Beispiel #3
0
        public void ExecuteTestPushEs()
        {
            var memory = new byte[] { 0xB8, 0x2A, 0x00, 0x8E, 0xC0, 0x06, 0x1F, 0x00, 0x00 };
            var cpu    = new InterpretCpu(memory);

            cpu.SetRegister(Reg16.sp, 9);
            cpu.Execute(0, 7);
            Assert.AreEqual(42, cpu.GetRegister(Segments.ds));
        }