コード例 #1
0
        public static void Check_MicroInstructions()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("START: INC A");
            testProgram.AppendLine("JR START");

            TestSystem testSystem = new TestSystem(false);

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState |
                CPUStateLogger.CPUStateElements.Registers |
                CPUStateLogger.CPUStateElements.Buses |
                CPUStateLogger.CPUStateElements.ControlPins |
                CPUStateLogger.CPUStateElements.MicroInstructions,
                new Z80CPU.LifecycleEventType[] {
                Z80CPU.LifecycleEventType.HalfTState,
                Z80CPU.LifecycleEventType.InstructionEnd,
                Z80CPU.LifecycleEventType.InstructionStart,
                Z80CPU.LifecycleEventType.MachineCycleEnd,
                Z80CPU.LifecycleEventType.MachineCycleStart
            });
            testSystem.ExecuteInstructionCount(3);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_MicroInstructions"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #2
0
        public static void Check_FetchOpcode(bool simulateSlowMemoryAndDevices)
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD A,B");
            testProgram.AppendLine("LD R,A");

            TestSystem testSystem = new TestSystem(simulateSlowMemoryAndDevices);
            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);
            logger.StartLogging(
               CPUStateLogger.CPUStateElements.InternalState |
               CPUStateLogger.CPUStateElements.Registers |
               CPUStateLogger.CPUStateElements.Buses |
               CPUStateLogger.CPUStateElements.ControlPins,
               new Z80CPU.LifecycleEventType[] {
                    Z80CPU.LifecycleEventType.HalfTState,
                    Z80CPU.LifecycleEventType.InstructionEnd,
                    Z80CPU.LifecycleEventType.InstructionStart,
                    Z80CPU.LifecycleEventType.MachineCycleEnd,
                    Z80CPU.LifecycleEventType.MachineCycleStart
                });
            testSystem.ExecuteInstructionCount(2);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_FetchOpcode" + GetSlowSuffix(simulateSlowMemoryAndDevices)))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #3
0
        public static void Check_Instruction_144_SRA_IndexedAddress_Register()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("LD IY,100");
            testProgram.AppendLine("LD (IY+1),10000001B");
            testProgram.AppendLine("SRA (IY+1),B");
            testProgram.AppendLine("LD A,(IY+1)");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(4);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/RotateAndShift/Logs/Check_Instruction_144_SRA_IndexedAddress_Register"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #4
0
        public static void Check_Instruction_156_XOR_IndexedAddress()
        {
            StringBuilder testProgram = new StringBuilder();

            // TStatesByMachineCycle = "7 (4,3)"
            testProgram.AppendLine("LD A,10101010B");
            // TStatesByMachineCycle = "14 (4, 4, 3, 3)"
            testProgram.AppendLine("LD IX,97");
            // TStatesByMachineCycle = "19 (4, 4, 3,5,3)"
            testProgram.AppendLine("LD (IX+3),10001001B");
            // TStatesByMachineCycle = "19 (4, 4, 3, 5, 3)"
            testProgram.AppendLine("XOR (IX+3)");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(4);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/Arithmetic_8bits/Logs/Check_Instruction_156_XOR_IndexedAddress"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #5
0
        public static void Check_Instruction_121_RRD()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("LD HL,100");
            testProgram.AppendLine("LD (HL),81H");
            testProgram.AppendLine("RRD");
            testProgram.AppendLine("LD B,(HL)");
            testProgram.AppendLine("RRD");
            testProgram.AppendLine("LD B,(HL)");
            testProgram.AppendLine("RRD");
            testProgram.AppendLine("LD B,(HL)");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(8);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/RotateAndShift/Logs/Check_Instruction_121_RRD"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #6
0
        public static void Check_Instruction_3_ADC_Register_Register16Address()
        {
            StringBuilder testProgram = new StringBuilder();

            // TStatesByMachineCycle = "7 (4,3)"
            testProgram.AppendLine("LD A,5");
            // TStatesByMachineCycle = "10 (4, 3, 3)"
            testProgram.AppendLine("LD HL,100");
            // TStatesByMachineCycle = "10 (4, 3, 3)"
            testProgram.AppendLine("LD (HL),10");
            // TStatesByMachineCycle = 1 (4)
            testProgram.AppendLine("SCF");
            // TStatesByMachineCycle = 7 (4, 3)
            testProgram.AppendLine("ADC A,(HL)");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(5);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/Arithmetic_8bits/Logs/Check_Instruction_3_ADC_Register_Register16Address"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #7
0
        public static void Check_Instruction_150_SUB_Register()
        {
            StringBuilder testProgram = new StringBuilder();

            // TStatesByMachineCycle = "7 (4,3)"
            testProgram.AppendLine("LD A,10");
            // TStatesByMachineCycle = "7 (4,3)"
            testProgram.AppendLine("LD B,4");
            // TStatesByMachineCycle = 1 (4)
            testProgram.AppendLine("SUB B");
            // TStatesByMachineCycle = "11 (4,4,3)"
            testProgram.AppendLine("LD IXh,3");
            // TStatesByMachineCycle = "8 (4, 4)"
            testProgram.AppendLine("SUB IXh");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(5);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/Arithmetic_8bits/Logs/Check_Instruction_150_SUB_Register"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #8
0
        public static void Check_Instruction_17_BIT_Bit_IndexedAddress()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("LD IX,10100000000000B");
            testProgram.AppendLine("LD (IX+1),00000001B");
            testProgram.AppendLine("BIT 0,(IX+1)");
            testProgram.AppendLine("LD (IX+1),10000000B");
            testProgram.AppendLine("BIT 7,(IX+1)");
            testProgram.AppendLine("BIT 4,(IX+1)");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(6);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/BitSetResetAndTest/Logs/Check_Instruction_17_BIT_Bit_IndexedAddress"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #9
0
        public static void Check_Instruction_128_SCF()
        {
            StringBuilder testProgram = new StringBuilder();

            // TStatesByMachineCycle = "1 (4)"
            testProgram.AppendLine("CCF");
            // TStatesByMachineCycle = "7 (4,3)"
            testProgram.AppendLine("LD A,0");
            // TStatesByMachineCycle = "1 (4)"
            testProgram.AppendLine("SCF");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(3);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/ArithmeticGeneralPurpose/Logs/Check_Instruction_128_SCF"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #10
0
        public static void Check_FetchOpcode(bool simulateSlowMemoryAndDevices)
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("LD A,B");
            testProgram.AppendLine("LD R,A");

            TestSystem testSystem = new TestSystem(simulateSlowMemoryAndDevices);

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState |
                CPUStateLogger.CPUStateElements.Registers |
                CPUStateLogger.CPUStateElements.Buses |
                CPUStateLogger.CPUStateElements.ControlPins,
                new Z80CPU.LifecycleEventType[] {
                Z80CPU.LifecycleEventType.HalfTState,
                Z80CPU.LifecycleEventType.InstructionEnd,
                Z80CPU.LifecycleEventType.InstructionStart,
                Z80CPU.LifecycleEventType.MachineCycleEnd,
                Z80CPU.LifecycleEventType.MachineCycleStart
            });
            testSystem.ExecuteInstructionCount(2);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_FetchOpcode" + GetSlowSuffix(simulateSlowMemoryAndDevices)))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #11
0
        public static void Check_Instruction_93_RES_Bit_Register16Address()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("LD HL,100");
            testProgram.AppendLine("LD (HL),0FFH");
            testProgram.AppendLine("RES 2,(HL)");
            testProgram.AppendLine("LD A,(HL)");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(4);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/BitSetResetAndTest/Logs/Check_Instruction_93_RES_Bit_Register16Address"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #12
0
        public static void Check_Instruction_127_SBC_Register16_Register16()
        {
            string sampleProgramFileName = "ALU/Arithmetic16bits/Samples/testsbc16.asm";
            string sampleResultFileName  = "ALU/Arithmetic16bits/Samples/resultsbc16.csv";

            Compare16bitsExecutionResultsWithSample(sampleProgramFileName, sampleResultFileName, 4);

            StringBuilder testProgram = new StringBuilder();

            // TStatesByMachineCycle = "10 (4,3,3)"
            testProgram.AppendLine("LD BC,1");
            // TStatesByMachineCycle = "10 (4,3,3)"
            testProgram.AppendLine("LD DE,2");
            // TStatesByMachineCycle = "10 (4,3,3)"
            testProgram.AppendLine("LD HL,10");
            // TStatesByMachineCycle = "10 (4,3,3)"
            testProgram.AppendLine("LD SP,4");
            // TStatesByMachineCycle = "4"
            testProgram.AppendLine("SCF");
            // TStatesByMachineCycle = "11 (4,4,3)"
            testProgram.AppendLine("SBC HL,BC");
            // TStatesByMachineCycle = "4"
            testProgram.AppendLine("SCF");
            // TStatesByMachineCycle = "11 (4,4,3)"
            testProgram.AppendLine("SBC HL,DE");
            // TStatesByMachineCycle = "4"
            testProgram.AppendLine("SCF");
            // TStatesByMachineCycle = "11 (4,4,3)"
            testProgram.AppendLine("SBC HL,HL");
            // TStatesByMachineCycle = "4"
            testProgram.AppendLine("SCF");
            // TStatesByMachineCycle = "11 (4,4,3)"
            testProgram.AppendLine("SBC HL,SP");

            TestSystem testSystem = new TestSystem();

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers,
                new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd });
            testSystem.ExecuteInstructionCount(12);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("ALU/Arithmetic16bits/Logs/Check_Instruction_127_SBC_Register16_Register16"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #13
0
        public static void Check_TwoBytesOpCodesAndDDFDPrefixes()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("INC A");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("INC B");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("INC C");
            testProgram.AppendLine("INC IX");
            testProgram.AppendLine("INC IY");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("DEC IY");

            int[][] startAfterTStatesAndActivateDuringTStates = new int[][] {
                new int[] { 40, 26 }
            };

            TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(null, null, startAfterTStatesAndActivateDuringTStates, null, null);

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState |
                CPUStateLogger.CPUStateElements.Registers |
                CPUStateLogger.CPUStateElements.ControlPins,
                new Z80CPU.LifecycleEventType[] {
                Z80CPU.LifecycleEventType.MachineCycleEnd
            });
            testSystem.Clock.Tick(74);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_TwoBytesOpCodesAndDDFDPrefixes"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #14
0
        public static void Check_FourBytesOpCodes()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("LD IX,100");
            testProgram.AppendLine("LD (IX+0),1000000B");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("INC B");
            testProgram.AppendLine("INC IY");
            testProgram.AppendLine("BIT 0,(IX+0)");
            testProgram.AppendLine("LD IY,200");
            testProgram.AppendLine("LD (IY+0),0000001B");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("INC C");
            testProgram.AppendLine("INC IX");
            testProgram.AppendLine("BIT 0,(IY+0)");

            int[][] startAfterTStatesAndActivateDuringTStates = new int[][] {
                new int[] { 51, 18 }
            };

            TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(null, null, startAfterTStatesAndActivateDuringTStates, null, null);

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState |
                CPUStateLogger.CPUStateElements.Registers |
                CPUStateLogger.CPUStateElements.ControlPins,
                new Z80CPU.LifecycleEventType[] {
                Z80CPU.LifecycleEventType.MachineCycleEnd
            });
            testSystem.ExecuteInstructionCount(10);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_FourBytesOpCodes"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #15
0
        public static void Check_BusRequestAcknowledge()
        {
            StringBuilder testProgram = new StringBuilder();

            testProgram.AppendLine("START: INC A");
            testProgram.AppendLine("JR START");

            int[][] startAfterTStatesAndActivateDuringTStates = new int[][] {
                new int[] { 1, 1 },
                new int[] { 12, 4 },
                new int[] { 20, 3 },
                new int[] { 29, 10 }
            };

            TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(startAfterTStatesAndActivateDuringTStates, null, null, null, null);

            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);

            logger.StartLogging(
                CPUStateLogger.CPUStateElements.InternalState |
                CPUStateLogger.CPUStateElements.Registers |
                CPUStateLogger.CPUStateElements.Buses |
                CPUStateLogger.CPUStateElements.ControlPins |
                CPUStateLogger.CPUStateElements.MicroInstructions,
                new Z80CPU.LifecycleEventType[] {
                Z80CPU.LifecycleEventType.HalfTState,
                Z80CPU.LifecycleEventType.InstructionEnd,
                Z80CPU.LifecycleEventType.InstructionStart,
                Z80CPU.LifecycleEventType.MachineCycleEnd,
                Z80CPU.LifecycleEventType.MachineCycleStart
            });
            testSystem.Clock.Tick(50);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_BusRequestAcknowledge"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #16
0
        public static void Check_BusRequestAcknowledge()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("START: INC A");
            testProgram.AppendLine("JR START");

            int[][] startAfterTStatesAndActivateDuringTStates = new int[][] {
                new int[] { 1, 1 },
                new int[] { 12, 4 },
                new int[] { 20, 3 },
                new int[] { 29, 10 }
            };

            TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(startAfterTStatesAndActivateDuringTStates, null, null, null, null);
            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);
            logger.StartLogging(
               CPUStateLogger.CPUStateElements.InternalState |
               CPUStateLogger.CPUStateElements.Registers |
               CPUStateLogger.CPUStateElements.Buses |
               CPUStateLogger.CPUStateElements.ControlPins |
               CPUStateLogger.CPUStateElements.MicroInstructions,
               new Z80CPU.LifecycleEventType[] {
                    Z80CPU.LifecycleEventType.HalfTState,
                    Z80CPU.LifecycleEventType.InstructionEnd,
                    Z80CPU.LifecycleEventType.InstructionStart,
                    Z80CPU.LifecycleEventType.MachineCycleEnd,
                    Z80CPU.LifecycleEventType.MachineCycleStart
                });
            testSystem.Clock.Tick(50);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_BusRequestAcknowledge"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #17
0
        public static void Check_FourBytesOpCodes()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD IX,100");
            testProgram.AppendLine("LD (IX+0),1000000B");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("INC B");
            testProgram.AppendLine("INC IY");
            testProgram.AppendLine("BIT 0,(IX+0)");
            testProgram.AppendLine("LD IY,200");
            testProgram.AppendLine("LD (IY+0),0000001B");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("INC C");
            testProgram.AppendLine("INC IX");
            testProgram.AppendLine("BIT 0,(IY+0)");

            int[][] startAfterTStatesAndActivateDuringTStates = new int[][] {
                new int[] { 51, 18 }
            };

            TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(null, null, startAfterTStatesAndActivateDuringTStates, null, null);
            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);
            logger.StartLogging(
               CPUStateLogger.CPUStateElements.InternalState |
               CPUStateLogger.CPUStateElements.Registers |
               CPUStateLogger.CPUStateElements.ControlPins,
               new Z80CPU.LifecycleEventType[] {
                    Z80CPU.LifecycleEventType.MachineCycleEnd
                });
            testSystem.ExecuteInstructionCount(10);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_FourBytesOpCodes"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #18
0
        public static void Check_TwoBytesOpCodesAndDDFDPrefixes()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("INC A");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("INC B");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("INC C");
            testProgram.AppendLine("INC IX");
            testProgram.AppendLine("INC IY");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("DEFB 0DDH");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("DEFB 0FDH");
            testProgram.AppendLine("DEC IY");

            int[][] startAfterTStatesAndActivateDuringTStates = new int[][] {
                new int[] { 40, 26 }
            };

            TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(null, null, startAfterTStatesAndActivateDuringTStates, null, null);
            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);
            logger.StartLogging(
               CPUStateLogger.CPUStateElements.InternalState |
               CPUStateLogger.CPUStateElements.Registers |
               CPUStateLogger.CPUStateElements.ControlPins,
               new Z80CPU.LifecycleEventType[] {
                    Z80CPU.LifecycleEventType.MachineCycleEnd
                });
            testSystem.Clock.Tick(74);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_TwoBytesOpCodesAndDDFDPrefixes"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #19
0
        public static void Check_StackMemoryReadAndWrite()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD A,10");
            testProgram.AppendLine("PUSH AF");
            testProgram.AppendLine("POP BC");

            TestSystem testSystem = new TestSystem();
            testSystem.LoadProgramInMemory(testProgram.ToString());

            CPUStateLogger logger = new CPUStateLogger(testSystem.CPU);
            logger.StartLogging(
               CPUStateLogger.CPUStateElements.InternalState |
               CPUStateLogger.CPUStateElements.Registers |
               CPUStateLogger.CPUStateElements.Buses |
               CPUStateLogger.CPUStateElements.ControlPins,
               new Z80CPU.LifecycleEventType[] {
                    Z80CPU.LifecycleEventType.HalfTState,
                    Z80CPU.LifecycleEventType.InstructionEnd,
                    Z80CPU.LifecycleEventType.InstructionStart,
                    Z80CPU.LifecycleEventType.MachineCycleEnd,
                    Z80CPU.LifecycleEventType.MachineCycleStart
                });
            testSystem.ExecuteInstructionCount(3);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("MachineCycles/Logs/Check_StackMemoryReadAndWrite"))
            {
                throw new Exception("Log compare failed");
            }
        }