Exemplo n.º 1
0
        public void TestJumpProcedure()
        {
            var cpu = new CPU();

            var instructionAdd = new JumpProcedure("jp 10", 0, 10);
            cpu.AddInstruction(instructionAdd);

            cpu.RunClock();
            Assert.AreEqual("jp 10", instructionAdd.GetFetch(), false);

            cpu.RunClock();
            Assert.AreEqual("JP: imm = 10", instructionAdd.GetDecode(), false);

            //Jump should have been taken
            Assert.AreEqual(10 << 2, cpu.GetPC());

            //Check stack contents
            Assert.AreEqual(1 << 2, cpu.StackPeek());
        }