![kueller](/assets/img/avatar_default.png)
git-svn-id: svn://svn.compuextreme.de/Viitor/V961/Viitor_cc65@4236 504e572c-2e33-0410-9681-be2bf7408885
62 lines
2.4 KiB
HTML
62 lines
2.4 KiB
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-175.html" REL=next>
|
|
<LINK HREF="funcref-173.html" REL=previous>
|
|
<LINK HREF="funcref.html#toc3" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="funcref-175.html">Next</A>
|
|
<A HREF="funcref-173.html">Previous</A>
|
|
<A HREF="funcref.html#toc3">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="set_brk"></A> 3.129 <A HREF="funcref.html#toc3.129">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 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.</P>
|
|
<DT><B>Limits</B><DD><P>
|
|
<UL>
|
|
<LI>The function is only available as fastcall function, so it may only
|
|
be used in presence of a prototype.</LI>
|
|
<LI>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.</LI>
|
|
<LI>The <CODE>brk_pc</CODE> variable points to the <CODE>BRK</CODE> instruction. If you want
|
|
the 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 necessary
|
|
to call <CODE>
|
|
<A HREF="funcref-171.html#reset_brk">reset_brk</A></CODE> as part of the cleanup when
|
|
the program terminates.</LI>
|
|
</UL>
|
|
</P>
|
|
<DT><B>Availability</B><DD><P>cc65</P>
|
|
<DT><B>See also</B><DD><P>
|
|
<A HREF="funcref-171.html#reset_brk">reset_brk</A></P>
|
|
<DT><B>Example</B><DD><P>None.</P>
|
|
</DL>
|
|
</BLOCKQUOTE>
|
|
</P>
|
|
|
|
|
|
<HR>
|
|
<A HREF="funcref-175.html">Next</A>
|
|
<A HREF="funcref-173.html">Previous</A>
|
|
<A HREF="funcref.html#toc3">Contents</A>
|
|
</BODY>
|
|
</HTML>
|