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>SDCC Compiler User Guide</TITLE>
11 <META NAME="description" CONTENT="SDCC Compiler User Guide">
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="node1.html">
26 <!--Navigation Panel-->
29 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
30 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif_gr.gif">
31 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif_gr.gif">
34 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
37 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
39 <B> Next:</B> <A NAME="tex2html7"
40 HREF="node1.html">Contents</A>
41   <B> <A NAME="tex2html3"
42 HREF="node1.html">Contents</A></B>
43   <B> <A NAME="tex2html5"
44 HREF="node61.html">Index</A></B>
47 <!--End of Navigation Panel-->
53 <H1 ALIGN="CENTER">SDCC Compiler User Guide</H1>
55 <!--Table of Child-Links-->
56 <A NAME="CHILD_LINKS"></A>
59 <LI><A NAME="tex2html8"
60 HREF="node1.html">Contents</A>
61 <LI><A NAME="tex2html9"
62 HREF="node2.html">1. Introduction</A>
64 <LI><A NAME="tex2html10"
65 HREF="node3.html">1.1 About SDCC</A>
66 <LI><A NAME="tex2html11"
67 HREF="node4.html">1.2 Open Source</A>
68 <LI><A NAME="tex2html12"
69 HREF="node5.html">1.3 Typographic conventions</A>
70 <LI><A NAME="tex2html13"
71 HREF="node6.html">1.4 Compatibility with previous versions</A>
72 <LI><A NAME="tex2html14"
73 HREF="node7.html">1.5 System Requirements</A>
74 <LI><A NAME="tex2html15"
75 HREF="node8.html">1.6 Other Resources</A>
76 <LI><A NAME="tex2html16"
77 HREF="node9.html">1.7 Wishes for the future</A>
79 <LI><A NAME="tex2html17"
80 HREF="node10.html">2. Installation</A>
82 <LI><A NAME="tex2html18"
83 HREF="node11.html">2.1 Linux/Unix Installation</A>
84 <LI><A NAME="tex2html19"
85 HREF="node12.html">2.2 Windows Installation</A>
87 <LI><A NAME="tex2html20"
88 HREF="node12.html#SECTION00032100000000000000">2.2.1 Windows Install Using a Binary Package</A>
89 <LI><A NAME="tex2html21"
90 HREF="node12.html#SECTION00032200000000000000">2.2.2 Windows Install Using Cygwin</A>
92 <LI><A NAME="tex2html22"
93 HREF="node13.html">2.3 Testing out the SDCC Compiler</A>
94 <LI><A NAME="tex2html23"
95 HREF="node14.html">2.4 Install Trouble-shooting</A>
97 <LI><A NAME="tex2html24"
98 HREF="node14.html#SECTION00034100000000000000">2.4.1 SDCC cannot find libraries or header files.</A>
99 <LI><A NAME="tex2html25"
100 HREF="node14.html#SECTION00034200000000000000">2.4.2 SDCC does not compile correctly.</A>
101 <LI><A NAME="tex2html26"
102 HREF="node14.html#SECTION00034300000000000000">2.4.3 What the ''./configure'' does</A>
103 <LI><A NAME="tex2html27"
104 HREF="node14.html#SECTION00034400000000000000">2.4.4 What the ''make'' does.</A>
105 <LI><A NAME="tex2html28"
106 HREF="node14.html#SECTION00034500000000000000">2.4.5 What the ''make install'' command does.</A>
108 <LI><A NAME="tex2html29"
109 HREF="node15.html">2.5 Additional Information for Windows Users</A>
111 <LI><A NAME="tex2html30"
112 HREF="node15.html#SECTION00035100000000000000">2.5.1 Getting started with Cygwin</A>
113 <LI><A NAME="tex2html31"
114 HREF="node15.html#SECTION00035200000000000000">2.5.2 Running SDCC as Native Compiled Executables</A>
116 <LI><A NAME="tex2html32"
117 HREF="node16.html">2.6 SDCC on Other Platforms</A>
118 <LI><A NAME="tex2html33"
119 HREF="node17.html">2.7 Advanced Install Options</A>
120 <LI><A NAME="tex2html34"
121 HREF="node18.html">2.8 Components of SDCC</A>
123 <LI><A NAME="tex2html35"
124 HREF="node18.html#SECTION00038100000000000000">2.8.1 sdcc - The Compiler</A>
125 <LI><A NAME="tex2html36"
126 HREF="node18.html#SECTION00038200000000000000">2.8.2 sdcpp (C-Preprocessor)</A>
127 <LI><A NAME="tex2html37"
128 HREF="node18.html#SECTION00038300000000000000">2.8.3 asx8051, as-z80, as-gbz80, aslink, link-z80, link-gbz80 (The Assemblers
129 and Linkage Editors)</A>
130 <LI><A NAME="tex2html38"
131 HREF="node18.html#SECTION00038400000000000000">2.8.4 s51 - Simulator</A>
132 <LI><A NAME="tex2html39"
133 HREF="node18.html#SECTION00038500000000000000">2.8.5 sdcdb - Source Level Debugger</A>
136 <LI><A NAME="tex2html40"
137 HREF="node19.html">3. Using SDCC</A>
139 <LI><A NAME="tex2html41"
140 HREF="node20.html">3.1 Compiling</A>
142 <LI><A NAME="tex2html42"
143 HREF="node20.html#SECTION00041100000000000000">3.1.1 Single Source File Projects</A>
144 <LI><A NAME="tex2html43"
145 HREF="node20.html#SECTION00041200000000000000">3.1.2 Projects with Multiple Source Files</A>
146 <LI><A NAME="tex2html44"
147 HREF="node20.html#SECTION00041300000000000000">3.1.3 Projects with Additional Libraries</A>
149 <LI><A NAME="tex2html45"
150 HREF="node21.html">3.2 Command Line Options</A>
152 <LI><A NAME="tex2html46"
153 HREF="node21.html#SECTION00042100000000000000">3.2.1 Processor Selection Options</A>
154 <LI><A NAME="tex2html47"
155 HREF="node21.html#SECTION00042200000000000000">3.2.2 Preprocessor Options</A>
156 <LI><A NAME="tex2html48"
157 HREF="node21.html#SECTION00042300000000000000">3.2.3 Linker Options</A>
158 <LI><A NAME="tex2html49"
159 HREF="node21.html#SECTION00042400000000000000">3.2.4 MCS51 Options</A>
160 <LI><A NAME="tex2html50"
161 HREF="node21.html#SECTION00042500000000000000">3.2.5 DS390 Options</A>
162 <LI><A NAME="tex2html51"
163 HREF="node21.html#SECTION00042600000000000000">3.2.6 Optimization Options</A>
164 <LI><A NAME="tex2html52"
165 HREF="node21.html#SECTION00042700000000000000">3.2.7 Other Options</A>
166 <LI><A NAME="tex2html53"
167 HREF="node21.html#SECTION00042800000000000000">3.2.8 Intermediate Dump Options</A>
169 <LI><A NAME="tex2html54"
170 HREF="node22.html">3.3 MCS51/DS390 Storage Class Language Extensions</A>
172 <LI><A NAME="tex2html55"
173 HREF="node22.html#SECTION00043100000000000000">3.3.1 xdata</A>
174 <LI><A NAME="tex2html56"
175 HREF="node22.html#SECTION00043200000000000000">3.3.2 data</A>
176 <LI><A NAME="tex2html57"
177 HREF="node22.html#SECTION00043300000000000000">3.3.3 idata</A>
178 <LI><A NAME="tex2html58"
179 HREF="node22.html#SECTION00043400000000000000">3.3.4 bit</A>
180 <LI><A NAME="tex2html59"
181 HREF="node22.html#SECTION00043500000000000000">3.3.5 sfr / sbit</A>
183 <LI><A NAME="tex2html60"
184 HREF="node23.html">3.4 Pointers</A>
185 <LI><A NAME="tex2html61"
186 HREF="node24.html">3.5 Parameters & Local Variables</A>
187 <LI><A NAME="tex2html62"
188 HREF="node25.html">3.6 Overlaying</A>
189 <LI><A NAME="tex2html63"
190 HREF="node26.html">3.7 Interrupt Service Routines</A>
191 <LI><A NAME="tex2html64"
192 HREF="node27.html">3.8 Critical Functions</A>
193 <LI><A NAME="tex2html65"
194 HREF="node28.html">3.9 Naked Functions</A>
195 <LI><A NAME="tex2html66"
196 HREF="node29.html">3.10 Functions using private banks</A>
197 <LI><A NAME="tex2html67"
198 HREF="node30.html">3.11 Absolute Addressing</A>
199 <LI><A NAME="tex2html68"
200 HREF="node31.html">3.12 Startup Code</A>
201 <LI><A NAME="tex2html69"
202 HREF="node32.html">3.13 Inline Assembler Code</A>
203 <LI><A NAME="tex2html70"
204 HREF="node33.html">3.14 int(16 bit) and long (32 bit) Support</A>
205 <LI><A NAME="tex2html71"
206 HREF="node34.html">3.15 Floating Point Support</A>
207 <LI><A NAME="tex2html72"
208 HREF="node35.html">3.16 MCS51 Memory Models</A>
209 <LI><A NAME="tex2html73"
210 HREF="node36.html">3.17 DS390 Memory Models</A>
211 <LI><A NAME="tex2html74"
212 HREF="node37.html">3.18 Defines Created by the Compiler</A>
214 <LI><A NAME="tex2html75"
215 HREF="node38.html">4. SDCC Technical Data</A>
217 <LI><A NAME="tex2html76"
218 HREF="node39.html">4.1 Optimizations</A>
220 <LI><A NAME="tex2html77"
221 HREF="node39.html#SECTION00051100000000000000">4.1.1 Sub-expression Elimination</A>
222 <LI><A NAME="tex2html78"
223 HREF="node39.html#SECTION00051200000000000000">4.1.2 Dead-Code Elimination</A>
224 <LI><A NAME="tex2html79"
225 HREF="node39.html#SECTION00051300000000000000">4.1.3 Copy-Propagation</A>
226 <LI><A NAME="tex2html80"
227 HREF="node39.html#SECTION00051400000000000000">4.1.4 Loop Optimizations</A>
228 <LI><A NAME="tex2html81"
229 HREF="node39.html#SECTION00051500000000000000">4.1.5 Loop Reversing</A>
230 <LI><A NAME="tex2html82"
231 HREF="node39.html#SECTION00051600000000000000">4.1.6 Algebraic Simplifications</A>
232 <LI><A NAME="tex2html83"
233 HREF="node39.html#SECTION00051700000000000000">4.1.7 'switch' Statements</A>
234 <LI><A NAME="tex2html84"
235 HREF="node39.html#SECTION00051800000000000000">4.1.8 Bit-shifting Operations.</A>
236 <LI><A NAME="tex2html85"
237 HREF="node39.html#SECTION00051900000000000000">4.1.9 Bit-rotation</A>
238 <LI><A NAME="tex2html86"
239 HREF="node39.html#SECTION000511000000000000000">4.1.10 Highest Order Bit</A>
240 <LI><A NAME="tex2html87"
241 HREF="node39.html#SECTION000511100000000000000">4.1.11 Peep-hole Optimizer</A>
243 <LI><A NAME="tex2html88"
244 HREF="node40.html">4.2 Pragmas</A>
245 <LI><A NAME="tex2html89"
246 HREF="node41.html">4.3 <I><pending: this is messy and incomplete></I> Library Routines</A>
247 <LI><A NAME="tex2html90"
248 HREF="node42.html">4.4 Interfacing with Assembly Routines</A>
250 <LI><A NAME="tex2html91"
251 HREF="node42.html#SECTION00054100000000000000">4.4.1 Global Registers used for Parameter Passing</A>
252 <LI><A NAME="tex2html92"
253 HREF="node42.html#SECTION00054200000000000000">4.4.2 Assembler Routine(non-reentrant)</A>
254 <LI><A NAME="tex2html93"
255 HREF="node42.html#SECTION00054300000000000000">4.4.3 Assembler Routine(reentrant)</A>
257 <LI><A NAME="tex2html94"
258 HREF="node43.html">4.5 External Stack</A>
259 <LI><A NAME="tex2html95"
260 HREF="node44.html">4.6 ANSI-Compliance</A>
261 <LI><A NAME="tex2html96"
262 HREF="node45.html">4.7 Cyclomatic Complexity</A>
264 <LI><A NAME="tex2html97"
265 HREF="node46.html">5. TIPS</A>
267 <LI><A NAME="tex2html98"
268 HREF="node47.html">5.1 Notes on MCS51 memory layout</A>
270 <LI><A NAME="tex2html99"
271 HREF="node48.html">6. Retargetting for other MCUs.</A>
272 <LI><A NAME="tex2html100"
273 HREF="node49.html">7. SDCDB - Source Level Debugger</A>
275 <LI><A NAME="tex2html101"
276 HREF="node50.html">7.1 Compiling for Debugging</A>
277 <LI><A NAME="tex2html102"
278 HREF="node51.html">7.2 How the Debugger Works</A>
279 <LI><A NAME="tex2html103"
280 HREF="node52.html">7.3 Starting the Debugger</A>
281 <LI><A NAME="tex2html104"
282 HREF="node53.html">7.4 Command Line Options.</A>
283 <LI><A NAME="tex2html105"
284 HREF="node54.html">7.5 Debugger Commands.</A>
286 <LI><A NAME="tex2html106"
287 HREF="node54.html#SECTION00085100000000000000">7.5.1 break [line | file:line | function | file:function]</A>
288 <LI><A NAME="tex2html107"
289 HREF="node54.html#SECTION00085200000000000000">7.5.2 clear [line | file:line | function | file:function ]</A>
290 <LI><A NAME="tex2html108"
291 HREF="node54.html#SECTION00085300000000000000">7.5.3 continue</A>
292 <LI><A NAME="tex2html109"
293 HREF="node54.html#SECTION00085400000000000000">7.5.4 finish</A>
294 <LI><A NAME="tex2html110"
295 HREF="node54.html#SECTION00085500000000000000">7.5.5 delete [n]</A>
296 <LI><A NAME="tex2html111"
297 HREF="node54.html#SECTION00085600000000000000">7.5.6 info [break | stack | frame | registers ]</A>
298 <LI><A NAME="tex2html112"
299 HREF="node54.html#SECTION00085700000000000000">7.5.7 step</A>
300 <LI><A NAME="tex2html113"
301 HREF="node54.html#SECTION00085800000000000000">7.5.8 next</A>
302 <LI><A NAME="tex2html114"
303 HREF="node54.html#SECTION00085900000000000000">7.5.9 run</A>
304 <LI><A NAME="tex2html115"
305 HREF="node54.html#SECTION000851000000000000000">7.5.10 ptype variable </A>
306 <LI><A NAME="tex2html116"
307 HREF="node54.html#SECTION000851100000000000000">7.5.11 print variable</A>
308 <LI><A NAME="tex2html117"
309 HREF="node54.html#SECTION000851200000000000000">7.5.12 file filename</A>
310 <LI><A NAME="tex2html118"
311 HREF="node54.html#SECTION000851300000000000000">7.5.13 frame</A>
312 <LI><A NAME="tex2html119"
313 HREF="node54.html#SECTION000851400000000000000">7.5.14 set srcmode</A>
314 <LI><A NAME="tex2html120"
315 HREF="node54.html#SECTION000851500000000000000">7.5.15 ! simulator command</A>
316 <LI><A NAME="tex2html121"
317 HREF="node54.html#SECTION000851600000000000000">7.5.16 quit.</A>
319 <LI><A NAME="tex2html122"
320 HREF="node55.html">7.6 Interfacing with XEmacs.</A>
322 <LI><A NAME="tex2html123"
323 HREF="node56.html">8. Other Processors</A>
325 <LI><A NAME="tex2html124"
326 HREF="node57.html">8.1 The Z80 and gbz80 port</A>
328 <LI><A NAME="tex2html125"
329 HREF="node58.html">9. Support</A>
331 <LI><A NAME="tex2html126"
332 HREF="node59.html">9.1 Reporting Bugs</A>
334 <LI><A NAME="tex2html127"
335 HREF="node60.html">10. Acknowledgments</A>
336 <LI><A NAME="tex2html128"
337 HREF="node61.html">Index</A>
338 <LI><A NAME="tex2html129"
339 HREF="node62.html">About this document ...</A>
341 <!--End of Table of Child-Links-->
345 <BR><I>2001-07-13</I>