gbdk-releases/sdcc/doc/sdccman.html/node29.html
2015-01-10 16:25:09 +01:00

136 lines
5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>3.10 Functions using private banks</TITLE>
<META NAME="description" CONTENT="3.10 Functions using private banks">
<META NAME="keywords" CONTENT="sdccman">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="sdccman.css">
<LINK REL="next" HREF="node30.html">
<LINK REL="previous" HREF="node28.html">
<LINK REL="up" HREF="node19.html">
<LINK REL="next" HREF="node30.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html682"
HREF="node30.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html676"
HREF="node19.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html670"
HREF="node28.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
<A NAME="tex2html678"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
<A NAME="tex2html680"
HREF="node61.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html683"
HREF="node30.html">3.11 Absolute Addressing</A>
<B> Up:</B> <A NAME="tex2html677"
HREF="node19.html">3. Using SDCC</A>
<B> Previous:</B> <A NAME="tex2html671"
HREF="node28.html">3.9 Naked Functions</A>
&nbsp <B> <A NAME="tex2html679"
HREF="node1.html">Contents</A></B>
&nbsp <B> <A NAME="tex2html681"
HREF="node61.html">Index</A></B>
<BR>
<BR>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000410000000000000000">
3.10 Functions using private banks</A>
</H2>
<P>
The <I>using</I> attribute (which tells the compiler to use a register
bank other than the default bank zero) should only be applied to <I>interrupt</I>
functions (see note 1 below). This will in most circumstances make
the generated ISR code more efficient since it will not have to save
registers on the stack.
<P>
The <I>using</I> attribute will have no effect on the generated code
for a <I>non-interrupt</I> function (but may occasionally be useful
anyway<A NAME="tex2html1"
HREF="footnode.html#foot531"><SUP>1</SUP></A>).
<BR>
<I>(pending: I don't think this has been done yet)</I>
<P>
An <I>interrupt</I> function using a non-zero bank will assume that
it can trash that register bank, and will not save it. Since high-priority
interrupts can interrupt low-priority ones on the 8051 and friends,
this means that if a high-priority ISR <I>using</I> a particular bank
occurs while processing a low-priority ISR <I>using</I> the same bank,
terrible and bad things can happen. To prevent this, no single register
bank should be <I>used</I> by both a high priority and a low priority
ISR. This is probably most easily done by having all high priority
ISRs use one bank and all low priority ISRs use another. If you have
an ISR which can change priority at runtime, you're on your own: I
suggest using the default bank zero and taking the small performance
hit.
<P>
It is most efficient if your ISR calls no other functions. If your
ISR must call other functions, it is most efficient if those functions
use the same bank as the ISR (see note 1 below); the next best is
if the called functions use bank zero. It is very inefficient to call
a function using a different, non-zero bank from an ISR.
<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html682"
HREF="node30.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html676"
HREF="node19.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html670"
HREF="node28.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
<A NAME="tex2html678"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
<A NAME="tex2html680"
HREF="node61.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
<BR>
<B> Next:</B> <A NAME="tex2html683"
HREF="node30.html">3.11 Absolute Addressing</A>
<B> Up:</B> <A NAME="tex2html677"
HREF="node19.html">3. Using SDCC</A>
<B> Previous:</B> <A NAME="tex2html671"
HREF="node28.html">3.9 Naked Functions</A>
&nbsp <B> <A NAME="tex2html679"
HREF="node1.html">Contents</A></B>
&nbsp <B> <A NAME="tex2html681"
HREF="node61.html">Index</A></B>
<!--End of Navigation Panel-->
<ADDRESS>
<I>Johan Knol</I>
<BR><I>2001-07-13</I>
</ADDRESS>
</BODY>
</HTML>