📄 funcref-136.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20"> <TITLE>cc65 function reference: Alphabetical function reference: set_brk</TITLE> <LINK HREF="funcref-137.html" REL=next> <LINK HREF="funcref-135.html" REL=previous> <LINK HREF="funcref.html#toc3" REL=contents></HEAD><BODY><A HREF="funcref-137.html">Next</A><A HREF="funcref-135.html">Previous</A><A HREF="funcref.html#toc3">Contents</A><HR><H2><A NAME="set_brk"></A> 3.95 <A HREF="funcref.html#toc3.95">set_brk</A></H2><P><BLOCKQUOTE><DL><DT><B>Function</B><DD><P>Set the break vector to a user function.</P><DT><B>Header</B><DD><P><CODE><A HREF="funcref-3.html#6502.h">6502.h</A></CODE></P><DT><B>Declaration</B><DD><P><CODE>void __fastcall__ set_brk (brk_handler func);</CODE></P><DT><B>Description</B><DD><P><CODE>set_brk</CODE> allows a user program to handle breaks within theprogram code by letting the vector point to a user written C function. Theruntime library installs a small stub that saves the registers into globalvariables that may be accessed (and changed) by the break handler.</P><DT><B>Limits</B><DD><P><UL><LI>The function is only available as fastcall function, so it may onlybe used in presence of a prototype.</LI><LI>The stub saves the zero page registers used by the C runtime and switchesto 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 localvariables, and do not enable stack checks for the handler function or any otherfunction called from it.</LI><LI>The <CODE>brk_pc</CODE> variable points to the <CODE>BRK</CODE> instruction. If you wantthe continue with the interrupted code, you have to adjust <CODE>brk_pc</CODE>,otherwise the <CODE>BRK</CODE> instruction will get executed over and over again.</LI><LI>Since <CODE>set_brk</CODE> installs an exit handler, it is not strictly necessaryto call <CODE><A HREF="funcref-133.html#reset_brk">reset_brk</A></CODE> as part of the cleanup whenthe program terminates.</LI></UL></P><DT><B>Availability</B><DD><P>cc65</P><DT><B>See also</B><DD><P><A HREF="funcref-133.html#reset_brk">reset_brk</A></P><DT><B>Example</B><DD><P>None.</P></DL></BLOCKQUOTE></P><HR><A HREF="funcref-137.html">Next</A><A HREF="funcref-135.html">Previous</A><A HREF="funcref.html#toc3">Contents</A></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -