public static void Check_Instruction_85_OUT_IOPort_Register() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,23"); // TStatesByMachineCycle = "11 (4, 3, 4)" testProgram.AppendLine("OUT (1),A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,0"); // TStatesByMachineCycle = "11 (4, 3, 4)" testProgram.AppendLine("OUT (2),A"); // 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(6); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/InputAndOutput/Logs/Check_Instruction_85_OUT_IOPort_Register")) { 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_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"); } }
public static void Check_Instruction_62_LD_Register_Register16Address() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "10 (4,3,3)" testProgram.AppendLine("LD HL,100"); // TStatesByMachineCycle = "10 (4, 3, 3)" testProgram.AppendLine("LD (HL),32"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD E,(HL)"); // TStatesByMachineCycle = "10 (4,3,3)" testProgram.AppendLine("LD BC,100"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,(BC)"); 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("CPU/Load_8Bit/Logs/Check_Instruction_62_LD_Register_Register16Address")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_65_LD_Register16_Register16() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "10 (4, 3, 3)" testProgram.AppendLine("LD HL,1547"); // TStatesByMachineCycle = "1 (6)" testProgram.AppendLine("LD SP,HL"); // TStatesByMachineCycle = "14 (4, 4, 3, 3)" testProgram.AppendLine("LD IY,3225"); // TStatesByMachineCycle = "10 (4, 6)" testProgram.AppendLine("LD SP,IY"); 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("CPU/Load16Bit/Logs/Check_Instruction_65_LD_Register16_Register16")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_161_RESET() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("START: INC A"); testProgram.AppendLine("JR START"); int[][] startAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 30, 10 } }; TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(null, null, null, startAfterTStatesAndActivateDuringTStates, 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, 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("CPU/CPUControl/Logs/Check_Instruction_161_RESET")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_20_CCF() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "1 (4)" testProgram.AppendLine("CCF"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,0"); // TStatesByMachineCycle = "1 (4)" testProgram.AppendLine("CCF"); // TStatesByMachineCycle = "1 (4)" testProgram.AppendLine("CCF"); 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/ArithmeticGeneralPurpose/Logs/Check_Instruction_20_CCF")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_25_CPD() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD HL,100"); testProgram.AppendLine("LD (HL),1"); testProgram.AppendLine("LD HL,101"); testProgram.AppendLine("LD (HL),2"); testProgram.AppendLine("LD HL,102"); testProgram.AppendLine("LD (HL),3"); testProgram.AppendLine("LD BC,3"); testProgram.AppendLine("LD A,1"); testProgram.AppendLine("CPD"); testProgram.AppendLine("CPD"); testProgram.AppendLine("CPD"); 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(11); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/ExchangeBlockTransferAndSearch/Logs/Check_Instruction_25_CPD")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_26_CPDR() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD HL,100"); testProgram.AppendLine("LD (HL),1"); testProgram.AppendLine("LD HL,101"); testProgram.AppendLine("LD (HL),2"); testProgram.AppendLine("LD HL,102"); testProgram.AppendLine("LD (HL),3"); testProgram.AppendLine("LD BC,3"); testProgram.AppendLine("LD A,5"); testProgram.AppendLine("CPDR"); testProgram.AppendLine("LD HL,102"); testProgram.AppendLine("LD BC,3"); testProgram.AppendLine("LD A,2"); testProgram.AppendLine("CPDR"); 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(17); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/ExchangeBlockTransferAndSearch/Logs/Check_Instruction_26_CPDR")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_39_EX_Register16Address_Register16() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD BC,1000"); testProgram.AppendLine("LD HL,2000"); testProgram.AppendLine("LD IX,3000"); testProgram.AppendLine("LD IY,4000"); testProgram.AppendLine("PUSH BC"); testProgram.AppendLine("EX (SP),HL"); testProgram.AppendLine("EX (SP),IX"); testProgram.AppendLine("EX (SP),IY"); 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, new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd }); testSystem.ExecuteInstructionCount(9); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/ExchangeBlockTransferAndSearch/Logs/Check_Instruction_39_EX_Register16Address_Register16")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_55_JP_Register16Address() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD A,0"); testProgram.AppendLine("LD HL,100"); testProgram.AppendLine("JP (HL)"); testProgram.AppendLine("ORG 100"); testProgram.AppendLine("LD IX,110"); testProgram.AppendLine("JP (IX)"); testProgram.AppendLine("ORG 110"); testProgram.AppendLine("LD IY,120"); testProgram.AppendLine("JP (IY)"); testProgram.AppendLine("ORG 120"); testProgram.AppendLine("LD A,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(8); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/Jump/Logs/Check_Instruction_55_JP_Register16Address")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_125_SBC_Register_Register16Address() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,10"); // TStatesByMachineCycle = "10 (4, 3, 3)" testProgram.AppendLine("LD HL,100"); // TStatesByMachineCycle = "10 (4, 3, 3)" testProgram.AppendLine("LD (HL),5"); // TStatesByMachineCycle = 1 (4) testProgram.AppendLine("SCF"); // TStatesByMachineCycle = 7 (4, 3) testProgram.AppendLine("SBC 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_125_SBC_Register_Register16Address")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_36_DJNZ_RelativeDisplacement() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD A,0"); testProgram.AppendLine("LD B,3"); testProgram.AppendLine("INC A"); testProgram.AppendLine("DJNZ -1"); testProgram.AppendLine("LD A,0FFH"); 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(9); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/Jump/Logs/Check_Instruction_36_DJNZ_RelativeDisplacement")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_96_RET() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD A,0"); testProgram.AppendLine("CALL FUNC1"); testProgram.AppendLine("LD A,4"); testProgram.AppendLine("ORG 100"); testProgram.AppendLine("FUNC1: LD A,1"); testProgram.AppendLine("CALL FUNC2"); testProgram.AppendLine("LD A,3"); testProgram.AppendLine("RET"); testProgram.AppendLine("ORG 200"); testProgram.AppendLine("FUNC2: LD A,2"); testProgram.AppendLine("RET"); 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(9); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/CallAndReturn/Logs/Check_Instruction_96_RET")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_18_CALL_Address() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD A,0"); testProgram.AppendLine("CALL FUNC"); testProgram.AppendLine("LD A,2"); testProgram.AppendLine("ORG 100"); testProgram.AppendLine("FUNC: LD A,1"); testProgram.AppendLine("RET"); 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("CPU/CallAndReturn/Logs/Check_Instruction_18_CALL_Address")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_35_DI() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "4" testProgram.AppendLine("EI"); // TStatesByMachineCycle = "4" testProgram.AppendLine("DI"); 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(2); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/CPUControl/Logs/Check_Instruction_35_DI")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_57_JR_RelativeDisplacement() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("NEAR: LD A,0"); // TStatesByMachineCycle = "12 (4, 3, 5)" testProgram.AppendLine("JR FAR"); testProgram.AppendLine("ORG 100"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("FAR: LD A,1"); // TStatesByMachineCycle = "12 (4, 3, 5)" testProgram.AppendLine("JR NEAR"); 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(9); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/Jump/Logs/Check_Instruction_57_JR_RelativeDisplacement")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_100_RL_Register() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD B,00000001B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); testProgram.AppendLine("RL B"); 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(10); logger.StopLogging(); if (!logger.CompareWithSavedLog("ALU/RotateAndShift/Logs/Check_Instruction_100_RL_Register")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_56_JP_FlagCondition_Address() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD A,0"); testProgram.AppendLine("JP M,100"); testProgram.AppendLine("ORG 100"); testProgram.AppendLine("JP P,110"); testProgram.AppendLine("LD A,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("CPU/Jump/Logs/Check_Instruction_56_JP_FlagCondition_Address")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_71_LD_IndexedAddress_Number8() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "14 (4, 4, 3, 3)" testProgram.AppendLine("LD IX,110"); // TStatesByMachineCycle = "19 (4, 4, 3,5,3)" testProgram.AppendLine("LD (IX-10),20"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD A,(100)"); // TStatesByMachineCycle = "14 (4, 4, 3, 3)" testProgram.AppendLine("LD IY,95"); // TStatesByMachineCycle = "19 (4, 4, 3,5,3)" testProgram.AppendLine("LD (IY+5),30"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD A,(100)"); 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("CPU/Load_8Bit/Logs/Check_Instruction_71_LD_IndexedAddress_Number8")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_59_LD_Register_Number8() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD H,30"); // TStatesByMachineCycle = "11 (4,4,3)" testProgram.AppendLine("LD IXl,55"); 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(2); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/Load_8Bit/Logs/Check_Instruction_59_LD_Register_Number8")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_44_IN_Register_RegisterIOPort() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD B,8FH"); testProgram.AppendLine("LD C,1"); testProgram.AppendLine("IN D,(C)"); testProgram.AppendLine("LD C,2"); testProgram.AppendLine("IN B,(C)"); testProgram.AppendLine("LD C,3"); testProgram.AppendLine("IN H,(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_44_IN_Register_RegisterIOPort")) { throw new Exception("Log compare failed"); } }
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"); } }
public static void Check_Instruction_90_POP_Register16() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,17"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4253),A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,18"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4252),A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,19"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4251),A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,20"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4250),A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,21"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4249),A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,22"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4248),A"); // TStatesByMachineCycle = "10 (4, 3, 3)" testProgram.AppendLine("LD SP,4248"); // TStatesByMachineCycle = "10 (4, 3, 3)", testProgram.AppendLine("POP AF"); // TStatesByMachineCycle = "10 (4, 3, 3)", testProgram.AppendLine("POP HL"); // TStatesByMachineCycle = "14 (4, 4, 3, 3)" testProgram.AppendLine("POP IX"); 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(16); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/Load16Bit/Logs/Check_Instruction_90_POP_Register16")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_160_INT_2() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("IM 2"); testProgram.AppendLine("EI"); testProgram.AppendLine("LD A,2"); testProgram.AppendLine("LD I,A"); testProgram.AppendLine("START: INC A"); testProgram.AppendLine("JR START"); testProgram.AppendLine("ORG 520"); // 520 = 2 x 256 + 8 testProgram.AppendLine("DEFB 10H"); testProgram.AppendLine("DEFB 04H"); testProgram.AppendLine("ORG 1040"); // 1040 = 0410H testProgram.AppendLine("INC B"); testProgram.AppendLine("EI"); testProgram.AppendLine("RETI"); int[][] startAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 30, 1 } }; TestSystemWithInterruptingDevice testSystem = new TestSystemWithInterruptingDevice(0xFE, 0, 0, startAfterTStatesAndActivateDuringTStates, 8); 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.Clock.Tick(89); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/CPUControl/Logs/Check_Instruction_160_INT_2")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_60_LD_Register_Register() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD C,10"); // TStatesByMachineCycle = "1 (4)" testProgram.AppendLine("LD D,C"); // TStatesByMachineCycle = "8 (4,4)" testProgram.AppendLine("LD IXh,D"); // TStatesByMachineCycle = "8 (4,4)" testProgram.AppendLine("LD E,IXh"); // TStatesByMachineCycle = "8 (4,4)" testProgram.AppendLine("LD IXl,IXh"); // TStatesByMachineCycle = "11 (4,4,3)" testProgram.AppendLine("LD IYh,32"); // TStatesByMachineCycle = "8 (4,4)" testProgram.AppendLine("LD IYl,IYh"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,55"); // TStatesByMachineCycle = "9 (4, 5)" testProgram.AppendLine("LD R,A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,0"); // TStatesByMachineCycle = "9 (4, 5)" testProgram.AppendLine("LD A,R"); // TStatesByMachineCycle = "9 (4, 5)" testProgram.AppendLine("LD A,I"); 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("CPU/Load_8Bit/Logs/Check_Instruction_60_LD_Register_Register")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_41_HALT() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("IM 1"); testProgram.AppendLine("EI"); testProgram.AppendLine("HALT"); testProgram.AppendLine("INC A"); testProgram.AppendLine("ORG 38H"); testProgram.AppendLine("INC B"); testProgram.AppendLine("EI"); testProgram.AppendLine("RETI"); testProgram.AppendLine("ORG 66H"); testProgram.AppendLine("INC C"); testProgram.AppendLine("RETN"); int[][] startNMIAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 29, 3 } }; int[][] startRESETAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 62, 3 } }; int[][] startINTAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 97, 3 } }; TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(null, startINTAfterTStatesAndActivateDuringTStates, startNMIAfterTStatesAndActivateDuringTStates, startRESETAfterTStatesAndActivateDuringTStates, null); testSystem.LoadProgramInMemory(testProgram.ToString()); CPUStateLogger logger = new CPUStateLogger(testSystem.CPU); logger.StartLogging( CPUStateLogger.CPUStateElements.InternalState | CPUStateLogger.CPUStateElements.Registers | CPUStateLogger.CPUStateElements.ControlPins | CPUStateLogger.CPUStateElements.MicroInstructions, new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.MachineCycleEnd }); testSystem.Clock.Tick(139); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/CPUControl/Logs/Check_Instruction_41_HALT")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_157_NMI() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("EI"); testProgram.AppendLine("START: INC A"); testProgram.AppendLine("JR START"); testProgram.AppendLine("ORG 66H"); testProgram.AppendLine("INC B"); testProgram.AppendLine("RETN"); int[][] startNMIAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 4, 2 }, new int[] { 18, 1 }, new int[] { 50, 3 }, new int[] { 66, 1 } }; int[][] startINTAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 18, 3 } }; TestSystemWithTestSignals testSystem = new TestSystemWithTestSignals(null, startINTAfterTStatesAndActivateDuringTStates, startNMIAfterTStatesAndActivateDuringTStates, 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, new Z80CPU.LifecycleEventType[] { Z80CPU.LifecycleEventType.HalfTState, Z80CPU.LifecycleEventType.InstructionEnd, Z80CPU.LifecycleEventType.InstructionStart, Z80CPU.LifecycleEventType.MachineCycleEnd, Z80CPU.LifecycleEventType.MachineCycleStart }); testSystem.Clock.Tick(127); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/CPUControl/Logs/Check_Instruction_157_NMI")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_122_RST_ResetAddress() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD A,0"); testProgram.AppendLine("RST 08H"); testProgram.AppendLine("ORG 08H"); testProgram.AppendLine("LD A,1"); testProgram.AppendLine("RST 10H"); testProgram.AppendLine("ORG 10H"); testProgram.AppendLine("LD A,2"); testProgram.AppendLine("RST 18H"); testProgram.AppendLine("ORG 18H"); testProgram.AppendLine("LD A,3"); testProgram.AppendLine("RST 20H"); testProgram.AppendLine("ORG 20H"); testProgram.AppendLine("LD A,4"); testProgram.AppendLine("RST 28H"); testProgram.AppendLine("ORG 28H"); testProgram.AppendLine("LD A,5"); testProgram.AppendLine("RST 30H"); testProgram.AppendLine("ORG 30H"); testProgram.AppendLine("LD A,6"); testProgram.AppendLine("RST 38H"); testProgram.AppendLine("ORG 38H"); testProgram.AppendLine("LD A,7"); testProgram.AppendLine("RST 00H"); 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(17); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/CallAndReturn/Logs/Check_Instruction_122_RST_ResetAddress")) { throw new Exception("Log compare failed"); } }
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"); } }
public static void Check_Instruction_91_PUSH_Register16() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,21"); // TStatesByMachineCycle = "10 (4, 3, 3)" testProgram.AppendLine("LD BC,4370"); // TStatesByMachineCycle = "14 (4, 4, 3, 3)" testProgram.AppendLine("LD IY,4884"); // TStatesByMachineCycle = "11 (5, 3, 3)" testProgram.AppendLine("PUSH AF"); // TStatesByMachineCycle = "11 (5, 3, 3)" testProgram.AppendLine("PUSH BC"); // TStatesByMachineCycle = "15 (4, 5, 3, 3)" testProgram.AppendLine("PUSH IY"); // TStatesByMachineCycle = "10 (4, 3, 3)", testProgram.AppendLine("POP DE"); // TStatesByMachineCycle = "10 (4, 3, 3)", testProgram.AppendLine("POP DE"); // TStatesByMachineCycle = "10 (4, 3, 3)", testProgram.AppendLine("POP DE"); 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(9); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/Load16Bit/Logs/Check_Instruction_91_PUSH_Register16")) { throw new Exception("Log compare failed"); } }
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_131_SET_Bit_IndexedAddress() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD IY,100"); testProgram.AppendLine("LD (IY+1),0"); testProgram.AppendLine("SET 7,(IY+1)"); 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/BitSetResetAndTest/Logs/Check_Instruction_131_SET_Bit_IndexedAddress")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_42_IM_InterruptMode() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "8 (4,4)" testProgram.AppendLine("IM 2"); // TStatesByMachineCycle = "8 (4,4)" testProgram.AppendLine("IM 1"); // TStatesByMachineCycle = "8 (4,4)" testProgram.AppendLine("IM 0"); 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("CPU/CPUControl/Logs/Check_Instruction_42_IM_InterruptMode")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_158_INT_0() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("IM 0"); testProgram.AppendLine("EI"); testProgram.AppendLine("START: INC A"); testProgram.AppendLine("JR START"); testProgram.AppendLine("ORG 18H"); //OpCode = 0xDF,"RST 18H", testProgram.AppendLine("INC B"); testProgram.AppendLine("EI"); testProgram.AppendLine("RETI"); int[][] startAfterTStatesAndActivateDuringTStates = new int[][] { new int[] { 14, 1 } }; TestSystemWithInterruptingDevice testSystem = new TestSystemWithInterruptingDevice(0xFE, 0, 0, startAfterTStatesAndActivateDuringTStates, 0xDF); 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.Clock.Tick(67); logger.StopLogging(); if (!logger.CompareWithSavedLog("CPU/CPUControl/Logs/Check_Instruction_158_INT_0")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_58_JR_FlagCondition_RelativeDisplacement() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD A,0"); testProgram.AppendLine("JR Z,NEAR"); testProgram.AppendLine("ORG 10"); testProgram.AppendLine("NEAR: JR NZ,FAR"); testProgram.AppendLine("LD A,1"); testProgram.AppendLine("ORG 100"); testProgram.AppendLine("FAR: LD A,2"); 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("CPU/Jump/Logs/Check_Instruction_58_JR_FlagCondition_RelativeDisplacement")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_7_ADD_Register_Register() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,5"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD B,252"); // TStatesByMachineCycle = 1 (4) testProgram.AppendLine("ADD A,B"); // TStatesByMachineCycle = "11 (4,4,3)" testProgram.AppendLine("LD IXh,13"); // TStatesByMachineCycle = "8 (4, 4)" testProgram.AppendLine("ADD A,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_7_ADD_Register_Register")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_16_BIT_Bit_Register16Address() { StringBuilder testProgram = new StringBuilder(); testProgram.AppendLine("LD HL,10100000000000B"); testProgram.AppendLine("LD BC,1"); testProgram.AppendLine("ADD HL,BC"); testProgram.AppendLine("LD (HL),00000001B"); testProgram.AppendLine("BIT 0,(HL)"); testProgram.AppendLine("LD (HL),10000000B"); testProgram.AppendLine("BIT 7,(HL)"); testProgram.AppendLine("BIT 4,(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/BitSetResetAndTest/Logs/Check_Instruction_16_BIT_Bit_Register16Address")) { throw new Exception("Log compare failed"); } }
public static void Check_Instruction_66_LD_Register16_Address() { StringBuilder testProgram = new StringBuilder(); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,12"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4253),A"); // TStatesByMachineCycle = "7 (4,3)" testProgram.AppendLine("LD A,120"); // TStatesByMachineCycle = "13 (4, 3, 3, 3)" testProgram.AppendLine("LD (4254),A"); // TStatesByMachineCycle = "16 (4, 3, 3, 3, 3)" testProgram.AppendLine("LD HL,(4253)"); // TStatesByMachineCycle = "20 (4, 4, 3, 3, 3, 3)" testProgram.AppendLine("LD DE,(4253)"); // TStatesByMachineCycle = "20 (4, 4, 3, 3, 3, 3)" testProgram.AppendLine("LD IX,(4253)"); // TStatesByMachineCycle = "20 (4, 4, 3, 3, 3, 3)" testProgram.AppendLine("LD SP,(4253)"); 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("CPU/Load16Bit/Logs/Check_Instruction_66_LD_Register16_Address")) { throw new Exception("Log compare failed"); } }
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"); } }
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"); } }
public static void Check_Instruction_82_OR_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("OR (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_82_OR_IndexedAddress")) { throw new Exception("Log compare failed"); } }
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"); } }