Esempio n. 1
0
        public void ADC_Can_Add_Negative_One_Plus_Negative_2()
        {
            var test = new TestSpec
            {
                C          = false,
                A          = 0xff,     // -1
                OpCode     = OpCodeId.ADC_I,
                FinalValue = 0xfe,     // -2
                ExpectedA  = 0xfd,     // -3
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 2
0
        public void DEC_ZP_Sets_Negative_Flag_If_Result_Is_Negative()
        {
            var test = new TestSpec()
            {
                InsEffect      = InstrEffect.Mem,
                OpCode         = OpCodeId.DEC_ZP,
                FinalValue     = 0x00,
                ExpectedMemVal = 0xff,
                ExpectedN      = true,
            };

            test.Execute_And_Verify(AddrMode.ZP);
        }
Esempio n. 3
0
        public void LDX_ZP_Y_Works()
        {
            var test = new TestSpec()
            {
                X              = 0x00,
                OpCode         = OpCodeId.LDX_ZP_Y,
                FinalValue     = 0x12,
                ExpectedX      = 0x12,
                ExpectedCycles = 4
            };

            test.Execute_And_Verify(AddrMode.ZP_Y);
        }
Esempio n. 4
0
        public void SBC_I_Two_Small_Signed_Numbers_With_Different_Signs()
        {
            var test = new TestSpec
            {
                C          = true,
                A          = 0x02,
                OpCode     = OpCodeId.SBC_I,
                FinalValue = 0xff,     // -1
                ExpectedA  = 0x03,
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 5
0
        public void DEC_ABS_X_Works()
        {
            var test = new TestSpec()
            {
                InsEffect      = InstrEffect.Mem,
                OpCode         = OpCodeId.DEC_ABS_X,
                FinalValue     = 0x02,
                ExpectedMemVal = 0x01,
                ExpectedCycles = 7,
            };

            test.Execute_And_Verify(AddrMode.ABS_X);
        }
Esempio n. 6
0
        public void SBC_I_Result_Is_Greater_Than_Zero_Will_Get_Zero_Flag_Clear()
        {
            var test = new TestSpec
            {
                C          = true,
                A          = 0x00,
                OpCode     = OpCodeId.SBC_I,
                FinalValue = 0xff,     // -1
                ExpectedZ  = false,
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 7
0
        public void SBC_I_With_Two_Positive_Signed_Values_Resulting_In_A_Positive_Value_Will_Clear_Overflow_Flag()
        {
            var test = new TestSpec
            {
                C          = true,
                A          = 0x02,     // 2
                OpCode     = OpCodeId.SBC_I,
                FinalValue = 0x01,     // 1
                ExpectedV  = false,
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 8
0
        public void BNE_I_Jumps_To_Correct_Location_When_Offset_Is_Positive()
        {
            var test = new TestSpec()
            {
                PC         = 0x2000,
                Z          = false,     // BNE branches if Zero flag is clear.
                OpCode     = OpCodeId.BNE,
                FinalValue = 0x20,
                ExpectedPC = 0x2000 + 0x02 + 0x20,      // The relative branch location should be where the PC is after the branching instruction has updated the PC (reading instruction + operand)
            };

            test.Execute_And_Verify(AddrMode.Relative);
        }
Esempio n. 9
0
        public void BNE_I_Takes_2_Cycles_If_Branch_Fails()
        {
            var test = new TestSpec()
            {
                PC             = 0x2000,
                Z              = true, // BNE does not branch if Zero flag is set.
                OpCode         = OpCodeId.BNE,
                FinalValue     = 0x20,
                ExpectedCycles = 2
            };

            test.Execute_And_Verify(AddrMode.Relative);
        }
Esempio n. 10
0
        public void BNE_I_Takes_4_Cycles_If_Page_Boundary_Is_Crossed()
        {
            var test = new TestSpec()
            {
                PC             = 0x20f0,
                Z              = false, // BNE branches if Zero flag is clear.
                OpCode         = OpCodeId.BNE,
                FinalValue     = 0x20,
                ExpectedCycles = 4,
            };

            test.Execute_And_Verify(AddrMode.Relative);
        }
Esempio n. 11
0
        public void BNE_I_Does_Not_Jump_To_New_Location_If_Branch_Fails()
        {
            var test = new TestSpec()
            {
                PC         = 0x2000,
                Z          = true,     // BNE does not branch if Zero flag is set.
                OpCode     = OpCodeId.BNE,
                FinalValue = 0x20,
                ExpectedPC = 0x2000 + 0x02     // When branhing fails, the PC should remain unchanged and point to next instruction after this one
            };

            test.Execute_And_Verify(AddrMode.Relative);
        }
Esempio n. 12
0
        public void BNE_I_Takes_3_Cycles_Within_Same_Page()
        {
            var test = new TestSpec()
            {
                PC             = 0x2000,
                Z              = false, // BNE branches if Zero flag is clear.
                OpCode         = OpCodeId.BNE,
                FinalValue     = 0x20,
                ExpectedCycles = 3
            };

            test.Execute_And_Verify(AddrMode.Relative);
        }
Esempio n. 13
0
        public void TXS_Does_Not_Affect_Status_Flags()
        {
            var test = new TestSpec()
            {
                PS         = 0xff,
                X          = 0x34,
                SP         = 0x80,
                OpCode     = OpCodeId.TXS,
                ExpectedPS = 0xff
            };

            test.Execute_And_Verify(AddrMode.Implied);
        }
Esempio n. 14
0
        public void ADC_Sets_Zero_Flag_If_Result_Is_Zero()
        {
            var test = new TestSpec
            {
                C          = false,
                A          = 0x00,
                OpCode     = OpCodeId.ADC_I,
                FinalValue = 0x00,
                ExpectedZ  = true,
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 15
0
        public void TXA_Clears_Negative_Flag_If_Result_Is_Positive()
        {
            var test = new TestSpec()
            {
                X         = 0x01,
                A         = 0x34,
                OpCode    = OpCodeId.TXA,
                ExpectedN = false,
                ExpectedA = 0x01,
            };

            test.Execute_And_Verify(AddrMode.Implied);
        }
Esempio n. 16
0
        public void BNE_I_Jumps_To_Correct_Location_When_Offset_Is_Negative()
        {
            var test = new TestSpec()
            {
                PC         = 0x2010,
                Z          = false,    // BNE branches if Zero flag is clear.
                OpCode     = OpCodeId.BNE,
                FinalValue = 0xf0,     // - 10
                ExpectedPC = 0x2010 + 0x02 - 0x10,
            };

            test.Execute_And_Verify(AddrMode.Relative);
        }
Esempio n. 17
0
        public void SBC_I_Two_Small_Signed_Negative_Numbers()
        {
            var test = new TestSpec
            {
                C          = true,
                A          = 0xff,     // -1
                OpCode     = OpCodeId.SBC_I,
                FinalValue = 0xfe,     // -2
                ExpectedA  = 0x01,
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 18
0
        public void BNE_I_Jumps_To_Correct_Location_When_Offset_Crosses_Page_Boundary()
        {
            var test = new TestSpec()
            {
                PC         = 0x20f0,
                Z          = false,    // BNE branches if Zero flag is clear.
                OpCode     = OpCodeId.BNE,
                FinalValue = 0x20,     // + 20
                ExpectedPC = 0x20f0 + 0x02 + 0x20,
            };

            test.Execute_And_Verify(AddrMode.Relative);
        }
Esempio n. 19
0
        public void SBC_I_Result_Is_Has_Bit_7_Set_Will_Get_Negative_Flag_Set()
        {
            var test = new TestSpec
            {
                C          = true,
                A          = 0x00,
                OpCode     = OpCodeId.SBC_I,
                FinalValue = 0x01,
                ExpectedN  = true,
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 20
0
        public void TAY_ZP_Sets_Zero_Flag_If_Result_Is_Zero()
        {
            var test = new TestSpec()
            {
                A         = 0x00,
                Y         = 0x01,
                OpCode    = OpCodeId.TAY,
                ExpectedZ = true,
                ExpectedY = 0x00,
            };

            test.Execute_And_Verify(AddrMode.Implied);
        }
Esempio n. 21
0
        public void SBC_I_Two_Small_Unsigned_Numbers()
        {
            var test = new TestSpec
            {
                C          = true,      // Carry must be set before SBC to perform a subtraction without borrow.
                A          = 0x03,
                OpCode     = OpCodeId.SBC_I,
                FinalValue = 0x01,
                ExpectedA  = 0x02,
            };

            test.Execute_And_Verify(AddrMode.I);
        }
Esempio n. 22
0
        public void TAY_ZP_Clears_Zero_Flag_If_Result_Is_Not_Zero()
        {
            var test = new TestSpec()
            {
                A         = 0x34,
                Y         = 0x01,
                OpCode    = OpCodeId.TAY,
                ExpectedZ = false,
                ExpectedY = 0x34,
            };

            test.Execute_And_Verify(AddrMode.Implied);
        }
Esempio n. 23
0
        public void DEC_ZP_X_Where_ZeroPage_Address_Plus_X_Wraps_Over_Byte_Size_Works()
        {
            var test = new TestSpec()
            {
                InsEffect      = InstrEffect.Mem,
                OpCode         = OpCodeId.DEC_ZP_X,
                FinalValue     = 0x02,
                ExpectedMemVal = 0x01,
                ExpectedCycles = 6,
            };

            test.Execute_And_Verify(AddrMode.ZP_X, ZP_X_Should_Wrap_Over_Byte: true);
        }
Esempio n. 24
0
        public void TAY_ZP_Sets_Negative_Flag_If_Result_Is_Negative()
        {
            var test = new TestSpec()
            {
                A         = 0xfe,
                Y         = 0x00,
                OpCode    = OpCodeId.TAY,
                ExpectedN = true,
                ExpectedY = 0xfe,
            };

            test.Execute_And_Verify(AddrMode.Implied);
        }
Esempio n. 25
0
        public void DEC_ZP_Decreases_Value_At_Memory_Location()
        {
            var test = new TestSpec()
            {
                InsEffect  = InstrEffect.Mem,
                OpCode     = OpCodeId.DEC_ZP,
                FinalValue = 0x02,      // Will get written to the memory location being changed before instruction runs. Default address is used if not specified in ZeroPageAddress
                //ZeroPageAddress = 0x20  // Optional. Will use a default ZeroPage address for test if not set
                ExpectedMemVal = 0x01,
            };

            test.Execute_And_Verify(AddrMode.ZP);
        }
Esempio n. 26
0
        public void TXA_Sets_Zero_Flag_If_Result_Is_Zero()
        {
            var test = new TestSpec()
            {
                X         = 0x00,
                A         = 0x34,
                OpCode    = OpCodeId.TXA,
                ExpectedZ = true,
                ExpectedA = 0x00,
            };

            test.Execute_And_Verify(AddrMode.Implied);
        }
Esempio n. 27
0
        public void DEC_ZP_Clears_Negative_Flag_If_Result_Is_Positive()
        {
            var test = new TestSpec()
            {
                InsEffect      = InstrEffect.Mem,
                OpCode         = OpCodeId.DEC_ZP,
                FinalValue     = 0x02,
                ExpectedMemVal = 0x01,
                ExpectedN      = false,
            };

            test.Execute_And_Verify(AddrMode.ZP);
        }
Esempio n. 28
0
        public void TXA_Sets_Negative_Flag_If_Result_Is_Negative()
        {
            var test = new TestSpec()
            {
                X         = 0xfe,
                A         = 0x34,
                OpCode    = OpCodeId.TXA,
                ExpectedN = true,
                ExpectedA = 0xfe,
            };

            test.Execute_And_Verify(AddrMode.Implied);
        }
Esempio n. 29
0
        public void LDX_ZP_Y_Where_ZeroPage_Address_Plus_Y_Wraps_Over_Byte_Size_Works()
        {
            var test = new TestSpec()
            {
                X              = 0x00,
                OpCode         = OpCodeId.LDX_ZP_Y,
                FinalValue     = 0x12,
                ExpectedX      = 0x12,
                ExpectedCycles = 4
            };

            test.Execute_And_Verify(AddrMode.ZP_Y, ZP_Y_Should_Wrap_Over_Byte: true);
        }
Esempio n. 30
0
        public void ADC_Can_Add_2_Plus_Negative_1()
        {
            var test = new TestSpec
            {
                C          = false,
                A          = 0x02,
                OpCode     = OpCodeId.ADC_I,
                FinalValue = 0xff,
                ExpectedA  = 0x01,
            };

            test.Execute_And_Verify(AddrMode.I);
        }