Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > e677bbbdff6d27fe001f15e0ef2bb4cc > files > 241

sdcc-3.0.0-0.fc14.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2008 (1.71)
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.11 Functions using private register banks(mcs51/ds390)</TITLE>
<META NAME="description" CONTENT="3.11 Functions using private register banks(mcs51/ds390)">
<META NAME="keywords" CONTENT="sdccman">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="sdccman.css">

<LINK REL="next" HREF="node77.html">
<LINK REL="previous" HREF="node72.html">
<LINK REL="up" HREF="node37.html">
<LINK REL="next" HREF="node77.html">
</HEAD>

<BODY >
<!--Navigation Panel-->
<A NAME="tex2html1819"
  HREF="node77.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1813"
  HREF="node37.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1807"
  HREF="node75.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1815"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1817"
  HREF="node191.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1820"
  HREF="node77.html">3.12 Startup Code</A>
<B> Up:</B> <A NAME="tex2html1814"
  HREF="node37.html">3. Using SDCC</A>
<B> Previous:</B> <A NAME="tex2html1808"
  HREF="node75.html">3.10.3 Semaphore locking (mcs51/ds390)</A>
 &nbsp; <B>  <A NAME="tex2html1816"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1818"
  HREF="node191.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION004110000000000000000"></A><A NAME="sub:Functions-using-private-banks"></A>
<BR>
3.11 Functions using private register banks(mcs51/ds390)
</H1>

<P>
Some architectures have support for quickly changing register sets.
SDCC supports this feature with the <I>using<A NAME="1822"></A><A NAME="1823"></A></I>
attribute (which tells the compiler to use a register bank<A NAME="1824"></A>
other than the default bank zero). It should only be applied to <I>interrupt<A NAME="1825"></A></I>
functions (see footnote 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="tex2html33"
  HREF="footnode.html#foot1828"><SUP>3.4</SUP></A>).
<BR><I>(pending: Note, nowadays the</I> using <I>attribute has an
effect on</I> <I>the generated code for a</I> non-interrupt <I>function</I>.<I>)</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<A NAME="1835"></A><A NAME="1836"></A> 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><P>
<BR>


<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1819"
  HREF="node77.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1813"
  HREF="node37.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1807"
  HREF="node75.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1815"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1817"
  HREF="node191.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1820"
  HREF="node77.html">3.12 Startup Code</A>
<B> Up:</B> <A NAME="tex2html1814"
  HREF="node37.html">3. Using SDCC</A>
<B> Previous:</B> <A NAME="tex2html1808"
  HREF="node75.html">3.10.3 Semaphore locking (mcs51/ds390)</A>
 &nbsp; <B>  <A NAME="tex2html1816"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1818"
  HREF="node191.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>

2011-03-20
</ADDRESS>
</BODY>
</HTML>