Mercurial > hg > Members > kono > nitros9-code
view docs/ccguide/intercept.refentry @ 2772:0a3f4d8ea6d5
Found ENDC in wrong location in dwread.asm and dwwrite.asm. Corrected.
Moved the native 6309 code in dwread.asm and dwwrite.asm into the H6309 labeled area and changed IFEQ H6309 to IFNE H6309. Also moved the 57600bps 6809 code to the default location. This change had been done in the old dwread.asm and dwwrite.asm files to make it easier to follow. Though these two files were overwritten from the HDBDOS project dwread.asm and dwwrite.asm files. So this conversion needed to be done again so it made the source easier to follow.
author | drencor-xeen |
---|---|
date | Wed, 23 Jan 2013 12:36:55 -0600 |
parents | 0fa5d3280b5e |
children |
line wrap: on
line source
<refentry id="intercept"> <refnamediv> <refname>Intercept</refname> <refpurpose>set function for interrupt processing</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcprototype> <funcdef><function>intercept</function></funcdef> <paramdef>int <parameter>(* func)</parameter> <funcparams>int</funcparams></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1><title>Assembler Equivalent</title> <para> os9 F$ICPT </para> </refsect1> <refsect1><title>Description</title> <para> Intercept instructs OS-9 to pass control to the function "func" when an interrupt (signal) is received by the current process. </para> <para> If the interrupt processing function has an argument, it will contain the value of the signal received. On return from "func", the process resumes at the point in the program where it was interrupted by the signal. "Interrupt()" is an alternative to the use of "signal()" to process interrupts. </para> <para> As an example, suppose we wish to ensure that a partially completed output file is deleted if an interrupt is received. The body of the program might include: <programlisting> char *temp_file = "temp"; /* name of temporary file */ int pn=0; /* path number */ int intrupt(); /* predeclaration */ ... intercept(intrupt); /* route interrupt processing */ pn = creat(temp_file,3); /* make a new file */ ... write(pn,string,count); /* write string to temp file */ ... close(pn); pn=0; ... </programlisting> The interrupt routine might be coded: <programlisting> intrupt(sig); { if (pn){ /* only done if pn refers to an open file */ close(pn); unlink(temp_file); /* delete */ } exit(sig); } </programlisting> </para> </refsect1> <refsect1><title>Caveats</title> <para> "Intercept()" and "signal()" are mutually incompatible so that calls to both must not appear in the same program. The linker guards against this by giving an "entry name clash - _sigint" error if it is attempted. </para> </refsect1> <refsect1><title>See Also</title> <para> <link linkend="signal">signal()</link> </para> </refsect1> </refentry>