Пример #1
0
        public void Executing_Instruction_8xy4_WithVx_SetToVF_ThrowsException()
        {
            var cpu = new Cpu();
            var decodedInstruction = new DecodedInstruction(0x8FB4);

            var instruction = new Instruction_8xy4(decodedInstruction);

            Assert.Throws <InvalidOperationException>(() => instruction.Execute(cpu, MockedDisplay, MockedKeyboard));
        }
Пример #2
0
        public void Executing_Instruction_8xy4_WorksAsExpected(byte value1, byte value2, byte expectedSum, byte expectedCarry)
        {
            var cpu = new Cpu();
            var decodedInstruction = new DecodedInstruction(0x8AB4);

            cpu.V[decodedInstruction.x] = value1;
            cpu.V[decodedInstruction.y] = value2;

            var instruction = new Instruction_8xy4(decodedInstruction);

            instruction.Execute(cpu, MockedDisplay, MockedKeyboard);

            Assert.That(cpu.V[decodedInstruction.x], Is.EqualTo(expectedSum));
            Assert.That(cpu.V[0xF], Is.EqualTo(expectedCarry));
            Assert.That(instruction.Mnemonic, Is.EqualTo($"ADD V{decodedInstruction.x:X}, V{decodedInstruction.y:X}"));
        }