Reshaped doc's
[fw/sdcc] / doc / sdccman.html / node25.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
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 -->
8 <HTML>
9 <HEAD>
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">
15
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">
19
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
21
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">
26 </HEAD>
27
28 <BODY >
29 <!--Navigation Panel-->
30 <A NAME="tex2html626"
31  HREF="node26.html">
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
33 <A NAME="tex2html620"
34  HREF="node19.html">
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
36 <A NAME="tex2html614"
37  HREF="node24.html">
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
39 <A NAME="tex2html622"
40  HREF="node1.html">
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
42 <A NAME="tex2html624"
43  HREF="node61.html">
44 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
45 <BR>
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 &amp; Local</A>
52  &nbsp <B>  <A NAME="tex2html623"
53  HREF="node1.html">Contents</A></B> 
54  &nbsp <B>  <A NAME="tex2html625"
55  HREF="node61.html">Index</A></B> 
56 <BR>
57 <BR>
58 <!--End of Navigation Panel-->
59
60 <H2><A NAME="SECTION00046000000000000000">
61 3.6 Overlaying</A>
62 </H2>
63
64 <P>
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.
72
73 <P>
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&nbsp;NOOVERLAY if they
77 are not reentrant.
78
79 <P>
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&nbsp;NOOVERLAY should be used.
85
86 <P>
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.:
90 <BR>
91
92 <BR>
93 <TT>#pragma SAVE </TT>&nbsp;
94 <BR>
95 <TT>#pragma NOOVERLAY </TT>&nbsp;
96 <BR>
97 <TT>void set_error(unsigned char errcd) </TT>&nbsp;
98 <BR>
99 <TT>{</TT>&nbsp;
100 <BR>
101 <TT>&nbsp;&nbsp;&nbsp;&nbsp;P3 = errcd;</TT>&nbsp;
102 <BR>
103 <TT>} </TT>&nbsp;
104 <BR>
105 <TT>#pragma RESTORE </TT>&nbsp;
106 <BR>&nbsp;
107 <BR>
108 <TT>void some_isr () interrupt 2 using 1 </TT>&nbsp;
109 <BR>
110 <TT>{</TT>&nbsp;
111 <BR>
112 <TT>&nbsp;&nbsp;&nbsp;&nbsp;...</TT>&nbsp;
113 <BR>
114 <TT>&nbsp;&nbsp;&nbsp;&nbsp;set_error(10);</TT>&nbsp;
115 <BR>
116 <TT>&nbsp;&nbsp;&nbsp;&nbsp;... </TT>&nbsp;
117 <BR>
118 <TT>}</TT>&nbsp;
119 <BR>&nbsp;
120 <BR>
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&nbsp;NOOVERLAY
123 was not present, this could cause unpredictable runtime behavior when
124 called from an ISR. The #pragma&nbsp;NOOVERLAY ensures that the parameters
125 and local variables for the function are NOT overlayed.
126
127 <P>
128 <HR>
129 <!--Navigation Panel-->
130 <A NAME="tex2html626"
131  HREF="node26.html">
132 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
133 <A NAME="tex2html620"
134  HREF="node19.html">
135 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
136 <A NAME="tex2html614"
137  HREF="node24.html">
138 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
139 <A NAME="tex2html622"
140  HREF="node1.html">
141 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
142 <A NAME="tex2html624"
143  HREF="node61.html">
144 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
145 <BR>
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 &amp; Local</A>
152  &nbsp <B>  <A NAME="tex2html623"
153  HREF="node1.html">Contents</A></B> 
154  &nbsp <B>  <A NAME="tex2html625"
155  HREF="node61.html">Index</A></B> 
156 <!--End of Navigation Panel-->
157 <ADDRESS>
158 <I>Johan Knol</I>
159 <BR><I>2001-07-13</I>
160 </ADDRESS>
161 </BODY>
162 </HTML>