Пример #1
0
        public void Immediate()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.LdxImmediate);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 41);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(41, cpu.X);
        }
Пример #2
0
        public void NegativeFlagNotSet()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.LdxImmediate);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 127);

            // Act
            cpu.Execute();

            // Assert
            Assert.IsFalse(cpu.NegativeFlag);
        }
Пример #3
0
        public void StyZeroPage()
        {
            Cpu cpu = new Cpu();
            cpu.Y = 0x10;
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.StyZeroPage);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0xF);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0x10, cpu.Ram.ReadByte(0xF));
        }
Пример #4
0
        public void StyAbsolute()
        {
            Cpu cpu = new Cpu();
            cpu.Y = 0xF0;
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.StyAbsolute);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0x20);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 2), 0x30);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0xF0, cpu.Ram.ReadByte(0x3020));
        }
Пример #5
0
        public void ZeroPage()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(0xF, 0x40);
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.IncZeroPage);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0xF);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0x41, cpu.Ram.ReadByte(0xF));
        }
Пример #6
0
        public void Absolute()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(0x2310, 0x5);
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.LdxAbsolute);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0x10);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 2), 0x23);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0x5, cpu.X);
        }
Пример #7
0
        public void Absolute()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(0x2030, 0x40);
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.IncAbsolute);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0x30);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 2), 0x20);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0x41, cpu.Ram.ReadByte(0x2030));
        }
Пример #8
0
        public void StaIndirectX()
        {
            Cpu cpu = new Cpu();
            cpu.A = 0xF0;
            cpu.X = 0x1;
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.StaIndirectX);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0x10);
            cpu.Ram.WriteByte(0x11, 0x20);
            cpu.Ram.WriteByte(0x12, 0x30);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0xF0, cpu.Ram.ReadByte(0x3020));
        }
Пример #9
0
        public void ZeroPageY()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(0x1F, 0x5);
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.LdxZeroPageY);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0x1E);
            cpu.Y = 0x1;

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0x5, cpu.X);
        }
Пример #10
0
        public void ZeroFlagSet()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.LdxImmediate);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0);

            // Act
            cpu.Execute();

            // Assert
            Assert.IsTrue(cpu.ZeroFlag);
        }
Пример #11
0
        public void IndirectX()
        {
            // Arrange
            Cpu cpu = new Cpu();
            cpu.Ram.WriteByte(0x1C, 0x10);
            cpu.Ram.WriteByte(0x1D, 0x23);
            cpu.Ram.WriteByte(0x1E, 0x45);
            cpu.Ram.WriteByte(0x4523, 0x78);
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.LdaIndirectX);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0x1C);
            cpu.X = 0x1;

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0x78, cpu.A);
        }