Set the break vector to a user function.
void __fastcall__ set_brk (brk_handler func);
set_brkallows a user program to handle breaks within the program code by letting the vector point to a user written C function. The runtime library installs a small stub that saves the registers into global variables that may be accessed (and changed) by the break handler.
- The function is only available as fastcall function, so it may only be used in presence of a prototype.
- The stub saves the zero page registers used by the C runtime and switches to a small break handler stack. This means that it is safe to execute C code, even if C code was interrupted. Be careful however not to use too many local variables, and do not enable stack checks for the handler function or any other function called from it.
brk_pcvariable points to the
BRKinstruction. If you want the continue with the interrupted code, you have to adjust
brk_pc, otherwise the
BRKinstruction will get executed over and over again.
set_brkinstalls an exit handler, it is not strictly necessary to call
reset_brkas part of the cleanup when the program terminates.
- See also