Sets a user provided function as new interrupt handler.
void cpct_setInterruptHandler ( void (*intHandler)(void) )
(2B HL) intHandler | A pointer to the function that will handle interrupts from now on |
call cpct_setInterruptHandler_asm
It modifies the interrupt vector to establish a new interrupt handler that calls user provided function. The user must provide a pointer to the function (intHandler) that will handle interrupts. This function does not call intHandler or check it in any way. It just sets it for being called at the next interrupts. Provided intHandler function must not return any value nor accept any parameter.
This function creates wrapper code to safely call user provided intHandler. This code saves registers on the stack (AF, BC, DE, HL and IX) and restores them after user code from intHandler finishes. Therefore, user does not have to worry about saving registers. However, be very careful if you modify the alternate set of registers (AF’, BC’, DE’, HL’) as they will not be saved by default. User is responsible for saving and restoring the values on the alternate register set whenever they are modified. Otherwise, behaviour is undefined when returning from the function.
A, HL
40 bytes (17 bytes function + 23 bytes for safe interrupt wrapper code)
Case | microSecs (us) | CPU Cycles ------------------------------------- Any | 23 | 92 -------------------------------------
Case | microSecs (us) | CPU Cycles ------------------------------------------ Overhead | 58 | 184 ------------------------------------------