1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
5 <TITLE>SDCC Compiler User Guide</TITLE>
6 <LINK HREF="SDCCUdoc-1.html" REL=next>
11 <A HREF="SDCCUdoc-1.html">Next</A>
15 <H1>SDCC Compiler User Guide</H1>
17 <H2>Sandeep Dutta (sandeep.dutta@usa.net)</H2>
19 <H2><A NAME="toc1">1.</A> <A HREF="SDCCUdoc-1.html">Introduction</A></H2>
22 <H2><A NAME="toc2">2.</A> <A HREF="SDCCUdoc-2.html">Installation </A></H2>
25 <LI><A HREF="SDCCUdoc-2.html#ss2.1">2.1 Components of SDCC</A>
26 <LI><A HREF="SDCCUdoc-2.html#ss2.2">2.2 Installation for Version <= 2.1.7</A>
27 <LI><A HREF="SDCCUdoc-2.html#ss2.3">2.3 Installation for Version >= 2.1.8a</A>
29 <H2><A NAME="toc3">3.</A> <A HREF="SDCCUdoc-3.html">Compiling.</A></H2>
32 <LI><A HREF="SDCCUdoc-3.html#ss3.1">3.1 Single Source file projects.</A>
33 <LI><A HREF="SDCCUdoc-3.html#ss3.2">3.2 Projects with multiple source files.</A>
34 <LI><A HREF="SDCCUdoc-3.html#ss3.3">3.3 Projects with additional libraries.</A>
36 <H2><A NAME="toc4">4.</A> <A HREF="SDCCUdoc-4.html">Command Line options</A></H2>
39 <H2><A NAME="toc5">5.</A> <A HREF="SDCCUdoc-5.html">Language Extensions</A></H2>
42 <LI><A HREF="SDCCUdoc-5.html#ss5.1">5.1 Storage Classes.</A>
44 <H2><A NAME="toc6">6.</A> <A HREF="SDCCUdoc-6.html">Optimizations</A></H2>
47 <LI><A HREF="SDCCUdoc-6.html#ss6.1">6.1 Sub-expression elimination</A>
48 <LI><A HREF="SDCCUdoc-6.html#ss6.2">6.2 Dead-Code elimination.</A>
49 <LI><A HREF="SDCCUdoc-6.html#ss6.3">6.3 Copy-Propagation:</A>
50 <LI><A HREF="SDCCUdoc-6.html#ss6.4">6.4 Loop optimizations</A>
51 <LI><A HREF="SDCCUdoc-6.html#ss6.5">6.5 Algebraic simplifications:</A>
52 <LI><A HREF="SDCCUdoc-6.html#ss6.6">6.6 'switch' statements.</A>
53 <LI><A HREF="SDCCUdoc-6.html#ss6.7">6.7 bit-shifting operations.</A>
54 <LI><A HREF="SDCCUdoc-6.html#ss6.8">6.8 Highest Order Bit.</A>
55 <LI><A HREF="SDCCUdoc-6.html#ss6.9">6.9 Peep-hole optimizer.</A>
57 <H2><A NAME="toc7">7.</A> <A HREF="SDCCUdoc-7.html">Pointers</A></H2>
60 <H2><A NAME="toc8">8.</A> <A HREF="SDCCUdoc-8.html">Parameters & Local Variables</A></H2>
63 <LI><A HREF="SDCCUdoc-8.html#ss8.1">8.1 Overlaying</A>
65 <H2><A NAME="toc9">9.</A> <A HREF="SDCCUdoc-9.html">critical Functions.</A></H2>
68 <H2><A NAME="toc10">10.</A> <A HREF="SDCCUdoc-10.html">Absolute addressing.</A></H2>
71 <H2><A NAME="toc11">11.</A> <A HREF="SDCCUdoc-11.html">Interrupt Service Routines</A></H2>
74 <H2><A NAME="toc12">12.</A> <A HREF="SDCCUdoc-12.html">Startup Code</A></H2>
77 <H2><A NAME="toc13">13.</A> <A HREF="SDCCUdoc-13.html">Inline assembler code.</A></H2>
80 <H2><A NAME="toc14">14.</A> <A HREF="SDCCUdoc-14.html">int (16 bit) and long (32 bit ) support.</A></H2>
83 <H2><A NAME="toc15">15.</A> <A HREF="SDCCUdoc-15.html">Floating point support</A></H2>
86 <H2><A NAME="toc16">16.</A> <A HREF="SDCCUdoc-16.html">Memory Models</A></H2>
89 <H2><A NAME="toc17">17.</A> <A HREF="SDCCUdoc-17.html">Defines created by the compiler.</A></H2>
92 <H2><A NAME="toc18">18.</A> <A HREF="SDCCUdoc-18.html">Pragmas</A></H2>
95 <H2><A NAME="toc19">19.</A> <A HREF="SDCCUdoc-19.html">Library routines.</A></H2>
99 printf_small("my str %s, my int %d\n",(char _generic *)mystr,myint);
105 <LI><B>stdarg.h </B>- contains definition for the following macros to be used for
106 variable parameter list, note that a function can have a variable parameter
107 list if and only if it is 'reentrant'
108 <P>va_list, va_start, va_arg, va_end.
110 <LI><B>setjmp.h </B>- contains defintion for ANSI<B> setjmp </B>& <B>longjmp</B> routines. Note
111 in this case setjmp & longjmp can be used between functions executing within
112 the same register bank, if long jmp is executed from a function that is using
113 a different register bank from the function issuing the setjmp function, the
114 results may be unpredictable. The jump buffer requires 3 bytes of data (the
115 stack pointer & a 16 byte return address), and can be placed in any address
117 <LI><B>stdlib.h</B> - contains the following functions.
120 <LI><B>string.h </B>- contains the following functions.
121 <P>strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, strspn,
122 strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp, memset.
124 <LI><B>ctype.h</B> - contains the following routines.
125 <P>iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace,
126 isxdigit, isalnum, isalpha.
128 <LI><B>malloc.h</B> - The malloc routines are developed by Dmitry S. Obukhov (dso@usa.net).
129 These routines will allocate memory from the external ram. Here is a description
130 on how to use them (as described by the author).
133 // #define DYNAMIC_MEMORY_SIZE 0x2000
136 // unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
138 // unsigned char xdata * current_buffer;
145 init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE);
147 //Now it's possible to use malloc.
155 <LI><B>serial.h</B> - Serial IO routines are also developed by Dmitry S. Obukhov (dso@usa.net).
156 These routines are interrupt driven with a 256 byte circular buffer, they also
157 expect external ram to be present. Please see documentation in file SDCCDIR/sdcc51lib/serial.c
158 . Note the header file "serial.h" MUST be included in the file containing the
159 'main' function.</LI>
160 <LI><B>ser.h </B>- Alternate serial routine provided by Wolfgang Esslinger <wolfgang@WiredMinds.com>
161 these routines are more compact and faster. Please see documentation in file
162 SDCCDIR/sdcc51lib/ser.c</LI>
163 <LI><B>ser_ir.h </B>- Another alternate set of serial routines provided by Josef Wolf
164 <jw@raven.inka.de> , these routines do not use the external ram.</LI>
165 <LI><B>reg51.h</B> - contains register definitions for a standard 8051</LI>
166 <LI><B>reg552.h </B>- contains register definitions for 80C552.</LI>
167 <LI><B>float.h</B> - contains min, max and other floating point related stuff.</LI>
169 <P>All library routines are compiled as --model-small , they are all non-reentrant,
170 if you plan to use the large model or want to make these routines reentrant,
171 then they will have to be recompiled with the appropriate compiler option.
172 <P>Have not had time to do the more involved routines like printf, will get
175 <H2><A NAME="toc20">20.</A> <A HREF="SDCCUdoc-20.html">Interfacing with assembly routines.</A></H2>
178 <LI><A HREF="SDCCUdoc-20.html#ss20.1">20.1 Global registers used for parameter passing.</A>
179 <LI><A HREF="SDCCUdoc-20.html#ss20.2">20.2 With --noregparms option.</A>
181 <H2><A NAME="toc21">21.</A> <A HREF="SDCCUdoc-21.html">External Stack.</A></H2>
184 <H2><A NAME="toc22">22.</A> <A HREF="SDCCUdoc-22.html">ANSI-Compliance.</A></H2>
187 <H2><A NAME="toc23">23.</A> <A HREF="SDCCUdoc-23.html">Cyclomatic Complexity</A></H2>
190 <H2><A NAME="toc24">24.</A> <A HREF="SDCCUdoc-24.html">TIPS</A></H2>
193 <H2><A NAME="toc25">25.</A> <A HREF="SDCCUdoc-25.html">Retargetting for other MCUs.</A></H2>
196 <H2><A NAME="toc26">26.</A> <A HREF="SDCCUdoc-26.html">Reporting Bugs</A></H2>
199 <H2><A NAME="toc27">27.</A> <A HREF="SDCCUdoc-27.html">SDCDB - Source level debugger.</A></H2>
202 <LI><A HREF="SDCCUdoc-27.html#ss27.1">27.1 Compiling for debugging.</A>
203 <LI><A HREF="SDCCUdoc-27.html#ss27.2">27.2 How the debugger works.</A>
204 <LI><A HREF="SDCCUdoc-27.html#ss27.3">27.3 Starting the debugger.</A>
205 <LI><A HREF="SDCCUdoc-27.html#ss27.4">27.4 Command line options.</A>
206 <LI><A HREF="SDCCUdoc-27.html#ss27.5">27.5 Debugger Commands.</A>
207 <LI><A HREF="SDCCUdoc-27.html#ss27.6">27.6 Interfacing with XEmacs.</A>
209 <H2><A NAME="toc28">28.</A> <A HREF="SDCCUdoc-28.html">Conclusion</A></H2>
212 <H2><A NAME="toc29">29.</A> <A HREF="SDCCUdoc-29.html">Acknowledgments</A></H2>
215 <A HREF="SDCCUdoc-1.html">Next</A>