private void DecodeInterruptingDeviceInstruction()
        {
            // The interrupting device inserts an instruction code on the data bus
            InstructionCode candidateInstructionCode = Z80OpCodes.Tables[0, InternalDataBus];            

            // An opcode was recognized, decode it and prepare its execution
            if (candidateInstructionCode.FetchMoreBytes == 0 && candidateInstructionCode.SwitchToTableNumber == null)
            {
                InstructionCode instructionCode = candidateInstructionCode;

                // Register decoded instruction
                instructionOrigin = new InstructionOrigin(InstructionSource.InterruptingDevice, instructionCode, 0);
                currentInstruction = new Instruction(instructionCode.InstructionTypeIndex, instructionCode.InstructionTypeParamVariant);
                DecodeInstructionExecutionMethod();                

                // Correct the actual duration of the current opcode fetch cycle (depends on the instruction)
                currentMachineCycle = currentInstruction.ExecutionTimings.MachineCycles[machineCycleIndex];

                // Decrease the half T state index to execute the decoded instruction as if it was fetched from memory
                halfTStateIndex = 4;
            }
            // We need to read more bytes to recognize a multi-byte opcode
            else
            {
                throw new NotSupportedException("Multi bytes opcodes are not supported in interrupt mode 0 by this simulator");
            }

            if (TraceMicroInstructions)
            {
                TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.CPUControlDecodeInterruptingDeviceInstruction));
            }
        }
예제 #2
0
        private void StartInstruction(Instruction instruction)
        {
            if (instruction == Instruction.RESET)
            {
                // Instruction count should be zero after a RESET
                instructionCounter = 0;
            }
            else
            {
                // Any other internal instruction increments the instruction counter
                instructionCounter++;
            }

            if (instruction == Instruction.FetchNewInstruction)
            {
                instructionOrigin = new InstructionOrigin(InstructionSource.Memory, null, PC);
            }
            else
            {
                instructionOrigin = InstructionOrigin.Internal;
            }
            currentInstruction = instruction;
            DecodeInstructionExecutionMethod();
        }
예제 #3
0
 private void EndInstruction()
 {
     instructionOrigin  = null;
     currentInstruction = null;
     executeInstruction = null;
 }