public static void Check_Instruction_43_IN_Register_IOPort()
        {
            StringBuilder testProgram = new StringBuilder();
            // TStatesByMachineCycle = "11 (4, 3, 4)"
            testProgram.AppendLine("IN A,(1)");
            // TStatesByMachineCycle = "11 (4, 3, 4)"
            testProgram.AppendLine("IN A,(2)");

            TestSystem testSystem = new TestSystemWithTwoDevices(false);
            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(2);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("CPU/InputAndOutput/Logs/Check_Instruction_43_IN_Register_IOPort"))
            {
                throw new Exception("Log compare failed");
            }
        }
        public static void Check_Instruction_87_OUT_RegisterIOPort_Register()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD A,0AFH");
            testProgram.AppendLine("LD B,0BFH");
            testProgram.AppendLine("LD L,0CFH");
            testProgram.AppendLine("LD C,1");
            testProgram.AppendLine("OUT (C),A");
            testProgram.AppendLine("LD C,2");
            testProgram.AppendLine("OUT (C),L");
            testProgram.AppendLine("LD A,0");
            testProgram.AppendLine("IN A,(1)");
            testProgram.AppendLine("LD A,0");
            testProgram.AppendLine("IN A,(2)");

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

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

            if (!logger.CompareWithSavedLog("CPU/InputAndOutput/Logs/Check_Instruction_87_OUT_RegisterIOPort_Register"))
            {
                throw new Exception("Log compare failed");
            }
        }
        public static void Check_Output(bool simulateSlowMemoryAndDevices)
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD A,23");
            testProgram.AppendLine("OUT (1),A");
            testProgram.AppendLine("LD A,0");
            testProgram.AppendLine("OUT (2),A");
            testProgram.AppendLine("IN A,(1)");
            testProgram.AppendLine("IN A,(2)");

            TestSystem testSystem = new TestSystemWithTwoDevices(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(6);
            logger.StopLogging();

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