What is an interrupt ?

An interrupt is a piece of code that starts executing automatically when an event occurs. To do this it has to interrupt whatever code was running before the event occurred. As part of this, the Program Counter (PC) is saved on the GB stack and interrupts are turned off as soon as the interrupt code starts executing. At the end of the interrupt, a RETI assembly instruction is usually executed which returns to executing code that was running before the interrupt occurred and enables interrupts again.