Ejemplo n.º 1
0
        public void WriteToMemory_OutsideValidMemoryRange_ThrowsException(ushort initialI)
        {
            var cpu = new Cpu {
                I = initialI
            };
            var decodedInstruction = new DecodedInstruction(0xFA33);

            var instruction = new Instruction_Fx33(decodedInstruction);

            Assert.Throws <InvalidOperationException>(() => instruction.Execute(cpu, MockedDisplay, MockedKeyboard));
        }
Ejemplo n.º 2
0
        public void Executing_Instruction_Fx33_WorksAsExpected(byte vx, ushort initialIValue, byte expectedHundreds, byte expectedTens, byte expectedOnes)
        {
            var cpu = new Cpu {
                I = initialIValue
            };
            var decodedInstruction = new DecodedInstruction(0xFA33);

            cpu.V[decodedInstruction.x] = vx;

            var instruction = new Instruction_Fx33(decodedInstruction);

            instruction.Execute(cpu, MockedDisplay, MockedKeyboard);

            Assert.That(cpu.Memory[initialIValue], Is.EqualTo(expectedHundreds));
            Assert.That(cpu.Memory[initialIValue + 1], Is.EqualTo(expectedTens));
            Assert.That(cpu.Memory[initialIValue + 2], Is.EqualTo(expectedOnes));
            Assert.That(cpu.I, Is.EqualTo(initialIValue + 2));
            Assert.That(instruction.Mnemonic, Is.EqualTo($"LD B, V{decodedInstruction.x:X}"));
        }