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_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"); } }
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_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"); } }
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"); } }