コード例 #1
0
        public static void Check_Instruction_45_IN_Flags_RegisterIOPort()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD B,8FH");
            testProgram.AppendLine("LD C,1");
            testProgram.AppendLine("IN F,(C)");
            testProgram.AppendLine("LD C,2");
            testProgram.AppendLine("IN F,(C)");
            testProgram.AppendLine("LD C,3");
            testProgram.AppendLine("IN F,(C)");

            IDictionary<byte, IList<byte>> valuesForPortAddresses = new Dictionary<byte, IList<byte>>();
            valuesForPortAddresses[1] = new byte[] { 0xAA };
            valuesForPortAddresses[2] = new byte[] { 0x00 };
            valuesForPortAddresses[3] = new byte[] { 0x29 };
            TestSystem testSystem = new TestSystemWithMultiportDevice(valuesForPortAddresses);
            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(7);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("CPU/InputAndOutput/Logs/Check_Instruction_45_IN_Flags_RegisterIOPort"))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #2
0
        public static void Check_Instruction_89_OUTI()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD B,3");
            testProgram.AppendLine("LD HL,100");
            testProgram.AppendLine("LD (HL),0AAH");
            testProgram.AppendLine("INC HL");
            testProgram.AppendLine("LD (HL),00H");
            testProgram.AppendLine("INC HL");
            testProgram.AppendLine("LD (HL),29H");
            testProgram.AppendLine("LD HL,100");
            testProgram.AppendLine("LD C,1");
            testProgram.AppendLine("OUTI");
            testProgram.AppendLine("LD C,2");
            testProgram.AppendLine("OUTI");
            testProgram.AppendLine("LD C,3");
            testProgram.AppendLine("OUTI");

            IDictionary<byte, IList<byte>> valuesForPortAddresses = new Dictionary<byte, IList<byte>>();
            valuesForPortAddresses[1] = new byte[] { 0x00 };
            valuesForPortAddresses[2] = new byte[] { 0x00 };
            valuesForPortAddresses[3] = new byte[] { 0x00 };
            TestSystemWithMultiportDevice testSystem = new TestSystemWithMultiportDevice(valuesForPortAddresses);
            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(14);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("CPU/InputAndOutput/Logs/Check_Instruction_89_OUTI") ||
                !(testSystem.MultiportDevice.WrittenValuesForPortAddresses[1][0] == 0xAA &&
                  testSystem.MultiportDevice.WrittenValuesForPortAddresses[2][0] == 0x00 &&
                  testSystem.MultiportDevice.WrittenValuesForPortAddresses[3][0] == 0x29))
            {
                throw new Exception("Log compare failed");
            }
        }
コード例 #3
0
        public static void Check_Instruction_53_INIR()
        {
            StringBuilder testProgram = new StringBuilder();
            testProgram.AppendLine("LD B,3");
            testProgram.AppendLine("LD C,85");
            testProgram.AppendLine("LD HL,100");
            testProgram.AppendLine("INIR");

            IDictionary<byte, IList<byte>> valuesForPortAddresses = new Dictionary<byte, IList<byte>>();
            valuesForPortAddresses[85] = new byte[] { 0xAA, 0x00, 0x29 };
            TestSystem testSystem = new TestSystemWithMultiportDevice(valuesForPortAddresses);
            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(7);
            logger.StopLogging();

            if (!logger.CompareWithSavedLog("CPU/InputAndOutput/Logs/Check_Instruction_53_INIR") ||
                !(testSystem.Memory.CheckByte(100) == 0xAA && testSystem.Memory.CheckByte(101) == 0x00 && testSystem.Memory.CheckByte(102) == 0x29))
            {
                throw new Exception("Log compare failed");
            }
        }