Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 8
0
        public void StaIndirectY()
        {
            Cpu cpu = new Cpu();
            cpu.A = 0xF0;
            cpu.Y = 0x1;
            cpu.Ram.WriteByte(cpu.ProgramCounter, Mnemonic.StaIndirectY);
            cpu.Ram.WriteByte((Int16)(cpu.ProgramCounter + 1), 0x10);
            cpu.Ram.WriteByte(0x10, 0x20);
            cpu.Ram.WriteByte(0x11, 0x30);

            // Act
            cpu.Execute();

            // Assert
            Assert.AreEqual(0xF0, cpu.Ram.ReadByte(0x3021));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }