1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
3 <!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
4 original version by: Nikos Drakos, CBLU, University of Leeds
5 * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
6 * with significant contributions from:
7 Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
10 <TITLE>3.6 Overlaying</TITLE>
11 <META NAME="description" CONTENT="3.6 Overlaying">
12 <META NAME="keywords" CONTENT="sdccman">
13 <META NAME="resource-type" CONTENT="document">
14 <META NAME="distribution" CONTENT="global">
16 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
17 <META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
18 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
22 <LINK REL="next" HREF="node26.html">
23 <LINK REL="previous" HREF="node24.html">
24 <LINK REL="up" HREF="node19.html">
25 <LINK REL="next" HREF="node26.html">
29 <!--Navigation Panel-->
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
44 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
46 <B> Next:</B> <A NAME="tex2html627"
47 HREF="node26.html">3.7 Interrupt Service Routines</A>
48 <B> Up:</B> <A NAME="tex2html621"
49 HREF="node19.html">3. Using SDCC</A>
50 <B> Previous:</B> <A NAME="tex2html615"
51 HREF="node24.html">3.5 Parameters & Local</A>
52   <B> <A NAME="tex2html623"
53 HREF="node1.html">Contents</A></B>
54   <B> <A NAME="tex2html625"
55 HREF="node61.html">Index</A></B>
58 <!--End of Navigation Panel-->
60 <H2><A NAME="SECTION00046000000000000000">
65 For non-reentrant functions SDCC will try to reduce internal ram space
66 usage by overlaying parameters and local variables of a function (if
67 possible). Parameters and local variables of a function will be allocated
68 to an overlayable segment if the function has <I>no other function
69 calls and the function is non-reentrant and the memory model is small.</I>
70 If an explicit storage class is specified for a local variable, it
71 will NOT be overlayed.
74 Note that the compiler (not the linkage editor) makes the decision
75 for overlaying the data items. Functions that are called from an interrupt
76 service routine should be preceded by a #pragma NOOVERLAY if they
80 Also note that the compiler does not do any processing of inline assembler
81 code, so the compiler might incorrectly assign local variables and
82 parameters of a function into the overlay segment if the inline assembler
83 code calls other c-functions that might use the overlay. In that case
84 the #pragma NOOVERLAY should be used.
87 Parameters and Local variables of functions that contain 16 or 32
88 bit multiplication or division will NOT be overlayed since these are
89 implemented using external functions, e.g.:
93 <TT>#pragma SAVE </TT>
95 <TT>#pragma NOOVERLAY </TT>
97 <TT>void set_error(unsigned char errcd) </TT>
101 <TT> P3 = errcd;</TT>
105 <TT>#pragma RESTORE </TT>
108 <TT>void some_isr () interrupt 2 using 1 </TT>
112 <TT> ...</TT>
114 <TT> set_error(10);</TT>
116 <TT> ... </TT>
121 In the above example the parameter <I>errcd</I> for the function <I>set_error</I>
122 would be assigned to the overlayable segment if the #pragma NOOVERLAY
123 was not present, this could cause unpredictable runtime behavior when
124 called from an ISR. The #pragma NOOVERLAY ensures that the parameters
125 and local variables for the function are NOT overlayed.
129 <!--Navigation Panel-->
130 <A NAME="tex2html626"
132 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
133 <A NAME="tex2html620"
135 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
136 <A NAME="tex2html614"
138 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
139 <A NAME="tex2html622"
141 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
142 <A NAME="tex2html624"
144 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
146 <B> Next:</B> <A NAME="tex2html627"
147 HREF="node26.html">3.7 Interrupt Service Routines</A>
148 <B> Up:</B> <A NAME="tex2html621"
149 HREF="node19.html">3. Using SDCC</A>
150 <B> Previous:</B> <A NAME="tex2html615"
151 HREF="node24.html">3.5 Parameters & Local</A>
152   <B> <A NAME="tex2html623"
153 HREF="node1.html">Contents</A></B>
154   <B> <A NAME="tex2html625"
155 HREF="node61.html">Index</A></B>
156 <!--End of Navigation Panel-->
159 <BR><I>2001-07-13</I>