Initial revision
[fw/sdcc] / doc / SDCCUdoc.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
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>
7
8
9 </HEAD>
10 <BODY>
11 <A HREF="SDCCUdoc-1.html">Next</A>
12 Previous
13 Contents
14 <HR>
15 <H1>SDCC Compiler User Guide</H1>
16
17 <H2>Sandeep Dutta (sandeep.dutta@usa.net)</H2>
18 <P>
19 <H2><A NAME="toc1">1.</A> <A HREF="SDCCUdoc-1.html">Introduction</A></H2>
20
21 <P>
22 <H2><A NAME="toc2">2.</A> <A HREF="SDCCUdoc-2.html">Installation </A></H2>
23
24 <UL>
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 &lt;= 2.1.7</A>
27 <LI><A HREF="SDCCUdoc-2.html#ss2.3">2.3 Installation for Version &gt;= 2.1.8a</A>
28 <P>
29 <H2><A NAME="toc3">3.</A> <A HREF="SDCCUdoc-3.html">Compiling.</A></H2>
30
31 <UL>
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>
35 <P>
36 <H2><A NAME="toc4">4.</A> <A HREF="SDCCUdoc-4.html">Command Line options</A></H2>
37
38 <P>
39 <H2><A NAME="toc5">5.</A> <A HREF="SDCCUdoc-5.html">Language Extensions</A></H2>
40
41 <UL>
42 <LI><A HREF="SDCCUdoc-5.html#ss5.1">5.1 Storage Classes.</A>
43 <P>
44 <H2><A NAME="toc6">6.</A> <A HREF="SDCCUdoc-6.html">Optimizations</A></H2>
45
46 <UL>
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>
56 <P>
57 <H2><A NAME="toc7">7.</A> <A HREF="SDCCUdoc-7.html">Pointers</A></H2>
58
59 <P>
60 <H2><A NAME="toc8">8.</A> <A HREF="SDCCUdoc-8.html">Parameters &amp; Local Variables</A></H2>
61
62 <UL>
63 <LI><A HREF="SDCCUdoc-8.html#ss8.1">8.1 Overlaying</A>
64 <P>
65 <H2><A NAME="toc9">9.</A> <A HREF="SDCCUdoc-9.html">critical Functions.</A></H2>
66
67 <P>
68 <H2><A NAME="toc10">10.</A> <A HREF="SDCCUdoc-10.html">Absolute addressing.</A></H2>
69
70 <P>
71 <H2><A NAME="toc11">11.</A> <A HREF="SDCCUdoc-11.html">Interrupt Service Routines</A></H2>
72
73 <P>
74 <H2><A NAME="toc12">12.</A> <A HREF="SDCCUdoc-12.html">Startup Code</A></H2>
75
76 <P>
77 <H2><A NAME="toc13">13.</A> <A HREF="SDCCUdoc-13.html">Inline assembler code.</A></H2>
78
79 <P>
80 <H2><A NAME="toc14">14.</A> <A HREF="SDCCUdoc-14.html">int (16 bit) and long (32 bit ) support.</A></H2>
81
82 <P>
83 <H2><A NAME="toc15">15.</A> <A HREF="SDCCUdoc-15.html">Floating point support</A></H2>
84
85 <P>
86 <H2><A NAME="toc16">16.</A> <A HREF="SDCCUdoc-16.html">Memory Models</A></H2>
87
88 <P>
89 <H2><A NAME="toc17">17.</A> <A HREF="SDCCUdoc-17.html">Defines created by the compiler.</A></H2>
90
91 <P>
92 <H2><A NAME="toc18">18.</A> <A HREF="SDCCUdoc-18.html">Pragmas</A></H2>
93
94 <P>
95 <H2><A NAME="toc19">19.</A> <A HREF="SDCCUdoc-19.html">Library routines.</A></H2>
96
97 <P>
98 <PRE>
99 printf_small("my str %s, my int %d\n",(char _generic *)mystr,myint);
100   
101 </PRE>
102
103 <P>
104 <UL>
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.
109 </LI>
110 <LI><B>setjmp.h </B>- contains defintion for ANSI<B> setjmp </B>&amp; <B>longjmp</B> routines. Note
111 in this case setjmp &amp; 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 &amp; a 16 byte return address), and can be placed in any address
116 space.</LI>
117 <LI><B>stdlib.h</B> - contains the following functions.
118 <P>atoi, atol.
119 </LI>
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.
123 </LI>
124 <LI><B>ctype.h</B> - contains the following routines.
125 <P>iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace,
126 isxdigit, isalnum, isalpha.
127 </LI>
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).
131 <PRE>
132 //Example: 
133      //     #define DYNAMIC_MEMORY_SIZE 0x2000 
134      //    
135  ..... 
136      //     unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
137  
138      //     unsigned char xdata * current_buffer; 
139      //     ..... 
140     
141  //     void main(void) 
142      //     { 
143      //         ... 
144      //        
145  init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE); 
146      //        
147  //Now it's possible to use malloc. 
148      //         ... 
149      //         current_buffer
150  = malloc(0x100); 
151      //
152   
153 </PRE>
154 </LI>
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 &lt;wolfgang@WiredMinds.com&gt;
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 &lt;jw@raven.inka.de&gt; , 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>
168 </UL>
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
173 to them shortly.
174 <P>
175 <H2><A NAME="toc20">20.</A> <A HREF="SDCCUdoc-20.html">Interfacing with assembly routines.</A></H2>
176
177 <UL>
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>
180 <P>
181 <H2><A NAME="toc21">21.</A> <A HREF="SDCCUdoc-21.html">External Stack.</A></H2>
182
183 <P>
184 <H2><A NAME="toc22">22.</A> <A HREF="SDCCUdoc-22.html">ANSI-Compliance.</A></H2>
185
186 <P>
187 <H2><A NAME="toc23">23.</A> <A HREF="SDCCUdoc-23.html">Cyclomatic Complexity</A></H2>
188
189 <P>
190 <H2><A NAME="toc24">24.</A> <A HREF="SDCCUdoc-24.html">TIPS</A></H2>
191
192 <P>
193 <H2><A NAME="toc25">25.</A> <A HREF="SDCCUdoc-25.html">Retargetting for other MCUs.</A></H2>
194
195 <P>
196 <H2><A NAME="toc26">26.</A> <A HREF="SDCCUdoc-26.html">Reporting Bugs</A></H2>
197
198 <P>
199 <H2><A NAME="toc27">27.</A> <A HREF="SDCCUdoc-27.html">SDCDB - Source level debugger.</A></H2>
200
201 <UL>
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>
208 <P>
209 <H2><A NAME="toc28">28.</A> <A HREF="SDCCUdoc-28.html">Conclusion</A></H2>
210
211 <P>
212 <H2><A NAME="toc29">29.</A> <A HREF="SDCCUdoc-29.html">Acknowledgments</A></H2>
213
214 <HR>
215 <A HREF="SDCCUdoc-1.html">Next</A>
216 Previous
217 Contents
218 </BODY>
219 </HTML>