The CPU checks at the end of each clock cycle whether there are any interrupts to be processed. When an interrupt is detected, the processor stops fetching instructions and instead pushes the current contents of its registers onto a stack. The CPU uses an interrupt service routine to process the interrupt. When processing has finished, the values can be popped from the stack and reloaded into the CPU.