Skip to content

Latest commit

 

History

History
9 lines (5 loc) · 1.81 KB

Interrupts.md

File metadata and controls

9 lines (5 loc) · 1.81 KB

Interrupts

IZ80Processor supports maskable and non-maskable interrupts. In order to be able to trigger interrupts, you need to create and plug interrupt sources, which are classes that implement IZ80InterruptSource. Interrupt sources must be registered by using the IZ80Processor.RegisterInterruptSource method so that the triggered interrupts are recognized by the processor instance. More than one interrupt source can be registered at the same time.

Non-maskable interrupts are triggered by the interrupt source by firing its NmiInterruptPulse event. This will cause the processor to handle the interrupt the standard way (maskable interrupts are disabled and a call to address 0x0066 is performed) the next time an instruction finishes its execution. Note that the Start and Reset methods cause a pending non-maskable interrupt to be lost.

Maskable interrupts are handled by the processor in the following way: after an instruction execution is finished, and if maskable interrupts are enabled, the list of registered interrupts sources is scanned for instances that have the IntLineIsActive property set to true. If at least one match is found, the interrupt is serviced the standard way (depends on the current interrupt mode). For interrupt mode 2 the ValueOnDataBus of the interrupt source is used as well, so it should have a meaningful value.

The HALT instruction behaves the expected way: after this instruction is executed the processor will enter a loop in which NOP instructions are executed (PC is not incremented) until an interrupt is received; note however that if AutoSopOnDiPlusHalt is true a HALT instruction may cause the execution to stop (depends on the processor configuration).