1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
6 pdftitle={SDCC Compiler User Guide},
7 pdfauthor={SDCC development team},
8 pdfsubject={installation, user manual},
9 pdfkeywords={8032, 8051, ansi, c, compiler, CPU, DS390,
10 embedded, GPL, manual, mcs51, PIC, small, Z80},
12 linkcolor=blue] {hyperref}
16 \inputencoding default
19 \paperfontsize default
21 \papersize letterpaper
26 \use_numerical_citations 0
27 \paperorientation portrait
34 \paragraph_separation indent
36 \quotes_language swedish
44 Please note: double dashed longoptions (e.g.
45 --version) are written this way: -
59 three consecutive dashes simply result in a long resp.
63 Architecture specific stuff (like memory models, code examples) should maybe
67 into seperate sections/chapters/appendices (it is hard to document PIC or
71 a 8051 centered document)
74 SDCC Compiler User Guide
77 The strings enclosed in $ are automatically updated by cvs:
91 \begin_inset LatexCommand \tableofcontents{}
108 is a Freeware, retargettable, optimizing ANSI-C compiler by
112 designed for 8 bit Microprocessors.
113 The current version targets Intel MCS51 based Microprocessors (8031, 8032,
115 \begin_inset LatexCommand \index{8031, 8032, 8051, 8052 CPU}
119 , etc), Dallas DS80C390 variants, Motorola HC08 and Zilog Z80 based MCUs
121 It can be retargetted for other microprocessors, support for Microchip
122 PIC, Atmel AVR is under development.
123 The entire source code for the compiler is distributed under GPL.
124 SDCC uses ASXXXX & ASLINK, a Freeware, retargettable assembler & linker.
125 SDCC has extensive language extensions suitable for utilizing various microcont
126 rollers and underlying hardware effectively.
131 In addition to the MCU specific optimizations SDCC also does a host of standard
135 global sub expression elimination,
138 loop optimizations (loop invariant, strength reduction of induction variables
142 constant folding & propagation,
148 dead code elimination
158 For the back-end SDCC uses a global register allocation scheme which should
159 be well suited for other 8 bit MCUs.
164 The peep hole optimizer uses a rule based substitution mechanism which is
170 Supported data-types are:
173 char (8 bits, 1 byte),
176 short and int (16 bits, 2 bytes),
179 long (32 bit, 4 bytes)
186 The compiler also allows
188 inline assembler code
190 to be embedded anywhere in a function.
191 In addition, routines developed in assembly can also be called.
195 SDCC also provides an option (-
205 -cyclomatic) to report the relative complexity of a function.
206 These functions can then be further optimized, or hand coded in assembly
212 SDCC also comes with a companion source level debugger SDCDB, the debugger
213 currently uses ucSim a freeware simulator for 8051 and other micro-controllers.
218 The latest version can be downloaded from
219 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
229 Please note: the compiler will probably always be some steps ahead of this
234 \begin_inset LatexCommand \index{Status of documentation}
244 Obviously this has pros and cons
253 All packages used in this compiler system are
261 ; source code for all the sub-packages (pre-processor, assemblers, linkers
262 etc) is distributed with the package.
263 This documentation is maintained using a freeware word processor (LyX).
265 This program is free software; you can redistribute it and/or modify it
266 under the terms of the GNU General Public License
267 \begin_inset LatexCommand \index{GNU General Public License, GPL}
271 as published by the Free Software Foundation; either version 2, or (at
272 your option) any later version.
273 This program is distributed in the hope that it will be useful, but WITHOUT
274 ANY WARRANTY; without even the implied warranty
275 \begin_inset LatexCommand \index{warranty}
279 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
280 See the GNU General Public License for more details.
281 You should have received a copy of the GNU General Public License along
282 with this program; if not, write to the Free Software Foundation, 59 Temple
283 Place - Suite 330, Boston, MA 02111-1307, USA.
284 In other words, you are welcome to use, share and improve this program.
285 You are forbidden to forbid anyone else to use, share and improve what
287 Help stamp out software-hoarding!
290 Typographic conventions
291 \begin_inset LatexCommand \index{Typographic conventions}
298 Throughout this manual, we will use the following convention.
299 Commands you have to type in are printed in
307 Code samples are printed in
312 Interesting items and new terms are printed in
317 Compatibility with previous versions
320 This version has numerous bug fixes compared with the previous version.
321 But we also introduced some incompatibilities with older versions.
322 Not just for the fun of it, but to make the compiler more stable, efficient
324 \begin_inset LatexCommand \index{ANSI-compliance}
329 \begin_inset LatexCommand \ref{sub:ANSI-Compliance}
333 for ANSI-Compliance).
339 short is now equivalent to int (16 bits), it used to be equivalent to char
340 (8 bits) which is not ANSI compliant
343 the default directory for gcc-builds where include, library and documentation
344 files are stored is now in /usr/local/share
347 char type parameters to vararg functions are casted to int unless explicitly
364 will push a as an int and as a char resp.
377 -regextend has been removed
390 -noregparms has been removed
403 -stack-after-data has been removed
408 <pending: more incompatibilities?>
414 What do you need before you start installation of SDCC? A computer, and
416 The preferred method of installation is to compile SDCC from source using
418 For Windows some pre-compiled binary distributions are available for your
420 You should have some experience with command line tools and compiler use.
426 The SDCC home page at
427 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
431 is a great place to find distribution sets.
432 You can also find links to the user mailing lists that offer help or discuss
433 SDCC with other SDCC users.
434 Web links to other SDCC related sites can also be found here.
435 This document can be found in the DOC directory of the source package as
437 Some of the other tools (simulator and assembler) included with SDCC contain
438 their own documentation and can be found in the source distribution.
439 If you want the latest unreleased software, the complete source package
440 is available directly by anonymous CVS on cvs.sdcc.sourceforge.net.
443 Wishes for the future
446 There are (and always will be) some things that could be done.
447 Here are some I can think of:
454 char KernelFunction3(char p) at 0x340;
462 \begin_inset LatexCommand \index{code banking (not supported)}
472 If you can think of some more, please see the chapter
473 \begin_inset LatexCommand \ref{sub:Requesting-Features}
477 about filing feature requests
478 \begin_inset LatexCommand \index{Requesting features}
483 \begin_inset LatexCommand \index{Feature request}
493 \begin_inset LatexCommand \index{Installation}
500 For most users it is sufficient to skip to either section
501 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
506 \begin_inset LatexCommand \ref{sub:Windows-Install}
511 More detailled instructions follow below.
515 \begin_inset LatexCommand \index{Options SDCC configuration}
522 The install paths, search paths and other options are defined when running
524 The defaults can be overridden by:
526 \labelwidthstring 00.00.0000
538 -prefix see table below
540 \labelwidthstring 00.00.0000
552 -exec_prefix see table below
554 \labelwidthstring 00.00.0000
566 -bindir see table below
568 \labelwidthstring 00.00.0000
580 -datadir see table below
582 \labelwidthstring 00.00.0000
584 docdir environment variable, see table below
586 \labelwidthstring 00.00.0000
588 include_dir_suffix environment variable, see table below
590 \labelwidthstring 00.00.0000
592 lib_dir_suffix environment variable, see table below
594 \labelwidthstring 00.00.0000
596 sdccconf_h_dir_separator environment variable, either / or
601 This character will only be used in sdccconf.h; don't forget it's a C-header,
602 therefore a double-backslash is needed there.
604 \labelwidthstring 00.00.0000
616 -disable-mcs51-port Excludes the Intel mcs51 port
618 \labelwidthstring 00.00.0000
630 -disable-gbz80-port Excludes the Gameboy gbz80 port
632 \labelwidthstring 00.00.0000
644 -disable-z80-port Excludes the z80 port
646 \labelwidthstring 00.00.0000
658 -disable-avr-port Excludes the AVR port
660 \labelwidthstring 00.00.0000
672 -disable-ds390-port Excludes the DS390 port
674 \labelwidthstring 00.00.0000
686 -disable-hc08-port Excludes the HC08 port
688 \labelwidthstring 00.00.0000
700 -disable-pic-port Excludes the PIC port
702 \labelwidthstring 00.00.0000
714 -disable-xa51-port Excludes the XA51 port
716 \labelwidthstring 00.00.0000
728 -disable-ucsim Disables configuring and building of ucsim
730 \labelwidthstring 00.00.0000
742 -disable-device-lib-build Disables automatically building device libraries
744 \labelwidthstring 00.00.0000
756 -disable-packihx Disables building packihx
758 \labelwidthstring 00.00.0000
770 -enable-libgc Use the Bohem memory allocator.
771 Lower runtime footprint.
774 Furthermore the environment variables CC, CFLAGS, ...
775 the tools and their arguments can be influenced.
776 Please see `configure -
786 -help` and the man/info pages of `configure` for details.
790 The names of the standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB,
791 STD_FP_LIB, STD_DS390_LIB, STD_XA51_LIB and the environment variables SDCC_DIR_
792 NAME, SDCC_INCLUDE_NAME, SDCC_LIB_NAME are defined by `configure` too.
793 At the moment it's not possible to change the default settings (it was
794 simply never required).
798 These configure options are compiled into the binaries, and can only be
799 changed by rerunning 'configure' and recompiling SDCC.
800 The configure options are written in
804 to distinguish them from run time environment variables (see section search
810 \begin_inset Quotes sld
814 \begin_inset Quotes srd
817 are used by the SDCC team to build the official Win32 binaries.
818 The SDCC team uses Mingw32 to build the official Windows binaries, because
825 a gcc compiler and last but not least
828 the binaries can be built by cross compiling on Sourceforge's compile farm.
831 See the examples, how to pass the Win32 settings to 'configure'.
832 The other Win32 builds using Borland, VC or whatever don't use 'configure',
833 but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
845 <lyxtabular version="3" rows="8" columns="3">
847 <column alignment="block" valignment="top" leftline="true" width="0in">
848 <column alignment="block" valignment="top" leftline="true" width="0in">
849 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
850 <row topline="true" bottomline="true">
851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
867 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
877 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
887 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
895 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
927 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
949 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
961 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
999 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1010 <row topline="true">
1011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1033 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1048 <row topline="true">
1049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1067 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1076 <row topline="true" bottomline="true">
1077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1113 'configure' also computes relative paths.
1114 This is needed for full relocatability of a binary package and to complete
1115 search paths (see section search paths below):
1121 \begin_inset Tabular
1122 <lyxtabular version="3" rows="4" columns="3">
1124 <column alignment="block" valignment="top" leftline="true" width="0in">
1125 <column alignment="block" valignment="top" leftline="true" width="0in">
1126 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1127 <row topline="true" bottomline="true">
1128 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1136 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1144 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1153 <row topline="true" bottomline="true">
1154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1172 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1181 <row bottomline="true">
1182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1200 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1209 <row bottomline="true">
1210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1220 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1228 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1261 \begin_inset Quotes srd
1265 \begin_inset Quotes srd
1279 \begin_inset Quotes srd
1283 \begin_inset Quotes srd
1311 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
1320 \begin_inset Quotes srd
1323 i586-mingw32msvc-gcc
1324 \begin_inset Quotes srd
1328 \begin_inset Quotes srd
1331 i586-mingw32msvc-g++
1332 \begin_inset Quotes srd
1340 \begin_inset Quotes srd
1343 i586-mingw32msvc-ranlib
1344 \begin_inset Quotes srd
1352 \begin_inset Quotes srd
1355 i586-mingw32msvc-strip
1356 \begin_inset Quotes srd
1374 \begin_inset Quotes srd
1378 \begin_inset Quotes srd
1396 \begin_inset Quotes srd
1400 \begin_inset Quotes srd
1408 \begin_inset Quotes srd
1412 \begin_inset Quotes srd
1420 \begin_inset Quotes srd
1424 \begin_inset Quotes srd
1432 \begin_inset Quotes srd
1436 \begin_inset Quotes srd
1443 sdccconf_h_dir_separator=
1444 \begin_inset Quotes srd
1456 \begin_inset Quotes srd
1473 -disable-device-lib-build
1501 -host=i586-mingw32msvc -
1511 -build=unknown-unknown-linux-gnu
1515 \begin_inset Quotes sld
1519 \begin_inset Quotes srd
1522 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
1531 \begin_inset Quotes srd
1535 \begin_inset Quotes srd
1543 \begin_inset Quotes srd
1547 \begin_inset Quotes srd
1565 \begin_inset Quotes srd
1569 \begin_inset Quotes srd
1587 \begin_inset Quotes srd
1591 \begin_inset Quotes srd
1599 \begin_inset Quotes srd
1603 \begin_inset Quotes srd
1611 \begin_inset Quotes srd
1615 \begin_inset Quotes srd
1623 \begin_inset Quotes srd
1627 \begin_inset Quotes srd
1634 sdccconf_h_dir_separator=
1635 \begin_inset Quotes srd
1647 \begin_inset Quotes srd
1667 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
1678 -C' turns on caching, which gives a little bit extra speed.
1679 However if options are changed, it can be necessary to delete the config.cache
1684 \begin_inset LatexCommand \label{sub:Install-paths}
1689 \begin_inset LatexCommand \index{Install paths}
1695 \added_space_top medskip \align center
1697 \begin_inset Tabular
1698 <lyxtabular version="3" rows="5" columns="4">
1700 <column alignment="center" valignment="top" leftline="true" width="0">
1701 <column alignment="center" valignment="top" leftline="true" width="0">
1702 <column alignment="center" valignment="top" leftline="true" width="0">
1703 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
1704 <row topline="true" bottomline="true">
1705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1715 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1725 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1735 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1746 <row topline="true">
1747 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1773 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1786 <row topline="true">
1787 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1795 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1802 $DATADIR/ $INCLUDE_DIR_SUFFIX
1805 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1810 /usr/local/share/sdcc/include
1813 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1826 <row topline="true">
1827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1842 $DATADIR/$LIB_DIR_SUFFIX
1845 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1850 /usr/local/share/sdcc/lib
1853 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1866 <row topline="true" bottomline="true">
1867 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1885 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1890 /usr/local/share/sdcc/doc
1893 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1915 *compiler, preprocessor, assembler, and linker
1921 is auto-appended by the compiler, e.g.
1922 small, large, z80, ds390 etc
1925 The install paths can still be changed during `make install` with e.g.:
1928 make install prefix=$(HOME)/local/sdcc
1931 Of course this doesn't change the search paths compiled into the binaries.
1935 \begin_inset LatexCommand \label{sub:Search-Paths}
1940 \begin_inset LatexCommand \index{Search path}
1947 Some search paths or parts of them are determined by configure variables
1952 , see section above).
1953 Further search paths are determined by environment variables during runtime.
1956 The paths searched when running the compiler are as follows (the first catch
1962 Binary files (preprocessor, assembler and linker)
1968 \begin_inset Tabular
1969 <lyxtabular version="3" rows="4" columns="3">
1971 <column alignment="block" valignment="top" leftline="true" width="0in">
1972 <column alignment="block" valignment="top" leftline="true" width="0in">
1973 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1974 <row topline="true" bottomline="true">
1975 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1991 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2000 <row topline="true">
2001 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2019 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2030 <row topline="true">
2031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2036 Path of argv[0] (if available)
2039 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2047 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2056 <row topline="true" bottomline="true">
2057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2073 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2098 \begin_inset Tabular
2099 <lyxtabular version="3" rows="6" columns="3">
2101 <column alignment="block" valignment="top" leftline="true" width="1.5in">
2102 <column alignment="block" valignment="top" leftline="true" width="1.5in">
2103 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2104 <row topline="true" bottomline="true">
2105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2113 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2121 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2130 <row topline="true">
2131 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2149 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2167 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2186 <row topline="true">
2187 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2203 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2212 <row topline="true">
2213 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2227 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2239 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2250 <row topline="true">
2251 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2319 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2332 <row topline="true" bottomline="true">
2333 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2349 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2354 /usr/local/share/sdcc/
2359 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2387 -nostdinc disables the last two search paths.
2397 With the exception of
2398 \begin_inset Quotes sld
2412 \begin_inset Quotes srd
2419 is auto-appended by the compiler (e.g.
2420 small, large, z80, ds390 etc.).
2427 \begin_inset Tabular
2428 <lyxtabular version="3" rows="6" columns="3">
2430 <column alignment="block" valignment="top" leftline="true" width="1.7in">
2431 <column alignment="block" valignment="top" leftline="true" width="1.2in">
2432 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
2433 <row topline="true" bottomline="true">
2434 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2442 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2450 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2459 <row topline="true">
2460 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2496 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2515 <row topline="true">
2516 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2528 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2540 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2555 <row topline="true">
2556 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2567 $LIB_DIR_SUFFIX/<model>
2570 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2584 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2601 <row topline="true">
2602 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2617 $LIB_DIR_SUFFIX/<model>
2620 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
2673 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2729 <row topline="true" bottomline="true">
2730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2739 $LIB_DIR_SUFFIX/<model>
2742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2747 /usr/local/share/sdcc/
2754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2772 Don't delete any of the stray spaces in the table above without checking
2773 the HTML output (last line)!
2789 -nostdlib disables the last two search paths.
2793 \begin_inset LatexCommand \index{Building SDCC}
2798 \layout Subsubsection
2800 Building SDCC on Linux
2801 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
2810 Download the source package
2812 either from the SDCC CVS repository or from the
2813 \begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
2819 , it will be named something like sdcc
2832 Bring up a command line terminal, such as xterm.
2837 Unpack the file using a command like:
2840 "tar -xvzf sdcc.src.tar.gz
2845 , this will create a sub-directory called sdcc with all of the sources.
2848 Change directory into the main SDCC directory, for example type:
2865 This configures the package for compilation on your system.
2881 All of the source packages will compile, this can take a while.
2897 This copies the binary executables, the include files, the libraries and
2898 the documentation to the install directories.
2899 \layout Subsubsection
2901 Building SDCC on OSX 2.x
2904 Follow the instruction for Linux.
2908 On OSX 2.x it was reported, that the default gcc (version 3.1 20020420 (prerelease
2909 )) fails to compile SDCC.
2910 Fortunately there's also gcc 2.9.x installed, which works fine.
2911 This compiler can be selected by running 'configure' with:
2914 ./configure CC=gcc2 CXX=g++2
2915 \layout Subsubsection
2917 Cross compiling SDCC on Linux for Windows
2920 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
2921 See section 'Configure Options'.
2922 \layout Subsubsection
2924 Building SDCC on Windows
2927 With the exception of Cygwin the SDCC binaries uCsim and sdcdb can't be
2929 They use Unix-sockets, which are not available on Win32.
2930 \layout Subsubsection
2932 Building SDCC using Cygwin and Mingw32
2935 For building and installing a Cygwin executable follow the instructions
2941 \begin_inset Quotes sld
2945 \begin_inset Quotes srd
2948 Win32-binary can be built, which will not need the Cygwin-DLL.
2949 For the necessary 'configure' options see section 'configure options' or
2950 the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
2954 In order to install Cygwin on Windows download setup.exe from
2955 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
2961 \begin_inset Quotes sld
2964 default text file type
2965 \begin_inset Quotes srd
2969 \begin_inset Quotes sld
2973 \begin_inset Quotes srd
2976 and download/install at least the following packages.
2977 Some packages are selected by default, others will be automatically selected
2978 because of dependencies with the manually selected packages.
2979 Never deselect these packages!
2988 gcc ; version 3.x is fine, no need to use the old 2.9x
2991 binutils ; selected with gcc
2997 rxvt ; a nice console, which makes life much easier under windoze (see below)
3000 man ; not really needed for building SDCC, but you'll miss it sooner or
3004 less ; not really needed for building SDCC, but you'll miss it sooner or
3008 cvs ; only if you use CVS access
3011 If you want to develop something you'll need:
3014 python ; for the regression tests
3017 gdb ; the gnu debugger, together with the nice GUI
3018 \begin_inset Quotes sld
3022 \begin_inset Quotes srd
3028 openssh ; to access the CF or commit changes
3031 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
3032 use autoconf-stable!
3035 rxvt is a nice console with history.
3036 Replace in your cygwin.bat the line
3055 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
3058 -bg black -fg white -geometry 100x65 -e bash -
3071 Text selected with the mouse is automatically copied to the clipboard, pasting
3072 works with shift-insert.
3076 The other good tip is to make sure you have no //c/-style paths anywhere,
3077 use /cygdrive/c/ instead.
3078 Using // invokes a network lookup which is very slow.
3080 \begin_inset Quotes sld
3084 \begin_inset Quotes srd
3087 is too long, you can change it with e.g.
3093 SDCC sources use the unix line ending LF.
3094 Life is much easier, if you store the source tree on a drive which is mounted
3096 And use an editor which can handle LF-only line endings.
3097 Make sure not to commit files with windows line endings.
3098 The tabulator spacing used in the project is 8.
3099 \layout Subsubsection
3101 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
3106 Download the source package
3108 either from the SDCC CVS repository or from the
3109 \begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
3115 , it will be named something like sdcc
3122 SDCC is distributed with all the projects, workspaces, and files you need
3123 to build it using Visual C++ 6.0/NET (except for sdcdb.exe which currently
3124 doesn't build under MSVC).
3125 The workspace name is 'sdcc.dsw'.
3126 Please note that as it is now, all the executables are created in a folder
3130 Once built you need to copy the executables from sdcc
3134 bin before running SDCC.
3139 In order to build SDCC with MSVC you need win32 executables of bison.exe,
3140 flex.exe, and gawk.exe.
3141 One good place to get them is
3142 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
3150 Download the file UnxUtils
3151 \begin_inset LatexCommand \index{UnxUtils}
3156 Now you have to install the utilities and setup MSVC so it can locate the
3158 Here there are two alternatives (choose one!):
3165 a) Extract UnxUtils.zip to your C:
3167 hard disk PRESERVING the original paths, otherwise bison won't work.
3168 (If you are using WinZip make certain that 'Use folder names' is selected)
3172 b) In the Visual C++ IDE click Tools, Options, select the Directory tab,
3173 in 'Show directories for:' select 'Executable files', and in the directories
3174 window add a new path: 'C:
3184 (As a side effect, you get a bunch of Unix utilities that could be useful,
3185 such as diff and patch.)
3192 This one avoids extracting a bunch of files you may not use, but requires
3197 a) Create a directory were to put the tools needed, or use a directory already
3205 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and gawk.exe
3206 to such directory WITHOUT preserving the original paths.
3207 (If you are using WinZip make certain that 'Use folder names' is not selected)
3211 c) Rename bison.exe to '_bison.exe'.
3215 d) Create a batch file 'bison.bat' in 'C:
3219 ' and add these lines:
3239 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
3243 Steps 'c' and 'd' are needed because bison requires by default that the
3244 files 'bison.simple' and 'bison.hairy' reside in some weird Unix directory,
3245 '/usr/local/share/' I think.
3246 So it is necessary to tell bison where those files are located if they
3247 are not in such directory.
3248 That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
3252 e) In the Visual C++ IDE click Tools, Options, select the Directory tab,
3253 in 'Show directories for:' select 'Executable files', and in the directories
3254 window add a new path: 'c:
3257 Note that you can use any other path instead of 'c:
3259 util', even the path where the Visual C++ tools are, probably: 'C:
3263 Microsoft Visual Studio
3268 So you don't have to execute step 'e' :)
3272 Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
3273 the executables from sdcc
3277 bin, and you can compile using SDCC.
3278 \layout Subsubsection
3280 Building SDCC Using Borland
3283 From the sdcc directory, run the command "make -f Makefile.bcc".
3284 This should regenerate all the .exe files in the bin directory except for
3285 sdcdb.exe (which currently doesn't build under Borland C++).
3288 If you modify any source files and need to rebuild, be aware that the dependenci
3289 es may not be correctly calculated.
3290 The safest option is to delete all .obj files and run the build again.
3291 From a Cygwin BASH prompt, this can easily be done with the command (be
3292 sure you are in the sdcc directory):
3302 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul'
3304 ) -print -exec rm {}
3313 or on Windows NT/2000/XP from the command prompt with the command:
3320 del /s *.obj *.lib *.rul
3323 from the sdcc directory.
3324 \layout Subsubsection
3326 Windows Install Using a Binary Package
3327 \begin_inset LatexCommand \label{sub:Windows-Install}
3334 Download the binary package from
3335 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
3339 and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
3340 This should unpack to a group of sub-directories.
3341 An example directory structure after unpacking the mingw32 package is:
3346 bin for the executables, c:
3354 lib for the include and libraries.
3357 Adjust your environment variable PATH to include the location of the bin
3358 directory or start sdcc using the full path.
3361 Building the Documentation
3364 If the necessary tools (LyX, LaTeX, latex2html) are installed it is as easy
3365 as changing into the doc directory and typing
3369 \begin_inset Quotes srd
3373 \begin_inset Quotes srd
3380 If you want to avoid installing the tools you will have some success with
3381 a bootable Knoppix CD
3382 \begin_inset LatexCommand \url{http://www.knopper.net}
3387 Prebuilt documentation in html and pdf format is available from
3388 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
3395 Reading the Documentation
3398 Currently reading the document in pdf format is recommended, as for unknown
3399 reason the hyperlinks are working there whereas in the html version they
3402 This documentation is in some aspects different from a commercial documentation:
3406 It tries to document SDCC for several processor architectures in one document
3407 (commercially these probably would be separate documents/products).
3409 \begin_inset LatexCommand \index{Status of documentation}
3413 currently matches SDCC for mcs51 and DS390 best and does give too few informati
3418 There are many references pointing away from this documentation.
3419 Don't let this distract you.
3421 was a reference like
3422 \begin_inset LatexCommand \url{www.opencores.org}
3426 together with a statement
3427 \begin_inset Quotes sld
3430 some processors which are targetted by SDCC can be implemented in a
3447 \begin_inset LatexCommand \index{fpga (field programmable gate array)}
3452 \begin_inset Quotes srd
3455 we expect you to have a quick look there and come back.
3456 If you read this you are on the right track.
3459 Some sections attribute more space to problems, restrictions and warnings
3460 than to the solution.
3463 The installation section and the section about the debugger is intimidating.
3466 There are still lots of typos and there are more different writing styles
3470 Testing the SDCC Compiler
3473 The first thing you should do after installing your SDCC compiler is to
3489 \begin_inset LatexCommand \index{version}
3496 at the prompt, and the program should run and tell you the version.
3497 If it doesn't run, or gives a message about not finding sdcc program, then
3498 you need to check over your installation.
3499 Make sure that the sdcc bin directory is in your executable search path
3500 defined by the PATH environment setting (
3505 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
3512 Install trouble-shooting for suggestions
3515 Make sure that the sdcc program is in the bin folder, if not perhaps something
3516 did not install correctly.
3524 is commonly installed as described in section
3525 \begin_inset Quotes sld
3528 Install and search paths
3529 \begin_inset Quotes srd
3538 Make sure the compiler works on a very simple example.
3539 Type in the following test.c program using your favorite
3565 Compile this using the following command:
3574 If all goes well, the compiler will generate a test.asm and test.rel file.
3575 Congratulations, you've just compiled your first program with SDCC.
3576 We used the -c option to tell SDCC not to link the generated code, just
3577 to keep things simple for this step.
3585 The next step is to try it with the linker.
3595 If all goes well the compiler will link with the libraries and produce
3596 a test.ihx output file.
3601 (no test.ihx, and the linker generates warnings), then the problem is most
3610 usr/local/share/sdcc/lib directory
3617 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
3624 Install trouble-shooting for suggestions).
3632 The final test is to ensure
3640 header files and libraries.
3641 Edit test.c and change it to the following:
3658 strcpy(str1, "testing");
3665 Compile this by typing
3672 This should generate a test.ihx output file, and it should give no warnings
3673 such as not finding the string.h file.
3674 If it cannot find the string.h file, then the problem is that
3678 cannot find the /usr/local/share/sdcc/include directory
3685 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
3692 Install trouble-shooting section for suggestions).
3710 \begin_inset LatexCommand \index{-\/-print-search-dirs}
3714 to find exactly where SDCC is looking for the include and lib files.
3717 Install Trouble-shooting
3718 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
3723 \begin_inset LatexCommand \index{Install trouble-shooting}
3728 \layout Subsubsection
3730 SDCC does not build correctly.
3733 A thing to try is starting from scratch by unpacking the .tgz source package
3734 again in an empty directory.
3742 ./configure 2>&1 | tee configure.log
3756 make 2>&1 | tee make.log
3763 If anything goes wrong, you can review the log files to locate the problem.
3764 Or a relevant part of this can be attached to an email that could be helpful
3765 when requesting help from the mailing list.
3766 \layout Subsubsection
3769 \begin_inset Quotes sld
3773 \begin_inset Quotes srd
3780 \begin_inset Quotes sld
3784 \begin_inset Quotes srd
3787 command is a script that analyzes your system and performs some configuration
3788 to ensure the source package compiles on your system.
3789 It will take a few minutes to run, and will compile a few tests to determine
3790 what compiler features are installed.
3791 \layout Subsubsection
3794 \begin_inset Quotes sld
3798 \begin_inset Quotes srd
3804 This runs the GNU make tool, which automatically compiles all the source
3805 packages into the final installed binary executables.
3806 \layout Subsubsection
3809 \begin_inset Quotes sld
3813 \begin_inset Quotes erd
3819 This will install the compiler, other executables libraries and include
3820 files into the appropriate directories.
3822 \begin_inset LatexCommand \ref{sub:Install-paths}
3828 \begin_inset LatexCommand \ref{sub:Search-Paths}
3833 about install and search paths.
3835 On most systems you will need super-user privileges to do this.
3841 SDCC is not just a compiler, but a collection of tools by various developers.
3842 These include linkers, assemblers, simulators and other components.
3843 Here is a summary of some of the components.
3844 Note that the included simulator and assembler have separate documentation
3845 which you can find in the source package in their respective directories.
3846 As SDCC grows to include support for other processors, other packages from
3847 various developers are included and may have their own sets of documentation.
3851 You might want to look at the files which are installed in <installdir>.
3852 At the time of this writing, we find the following programs for gcc-builds:
3856 In <installdir>/bin:
3859 sdcc - The compiler.
3862 sdcpp - The C preprocessor.
3865 asx8051 - The assembler for 8051 type processors.
3872 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
3875 aslink -The linker for 8051 type processors.
3882 link-gbz80 - The Z80 and GameBoy Z80 linkers.
3885 s51 - The ucSim 8051 simulator.
3888 sdcdb - The source debugger.
3891 packihx - A tool to pack (compress) Intel hex files.
3894 In <installdir>/share/sdcc/include
3900 In <installdir>/share/sdcc/lib
3903 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
3907 In <installdir>/share/sdcc/doc
3913 As development for other processors proceeds, this list will expand to include
3914 executables to support processors like AVR, PIC, etc.
3915 \layout Subsubsection
3920 This is the actual compiler, it in turn uses the c-preprocessor and invokes
3921 the assembler and linkage editor.
3922 \layout Subsubsection
3925 \begin_inset LatexCommand \index{sdcpp}
3929 - The C-Preprocessor
3932 The preprocessor is a modified version of the GNU preprocessor.
3933 The C preprocessor is used to pull in #include sources, process #ifdef
3934 statements, #defines and so on.
3935 \layout Subsubsection
3937 asx8051, as-z80, as-gbz80, aslink, link-z80, link-gbz80 - The Assemblers
3941 This is retargettable assembler & linkage editor, it was developed by Alan
3943 John Hartman created the version for 8051, and I (Sandeep) have made some
3944 enhancements and bug fixes for it to work properly with SDCC.
3945 \layout Subsubsection
3948 \begin_inset LatexCommand \index{s51}
3955 S51 is a freeware, opensource simulator developed by Daniel Drotos (
3956 \begin_inset LatexCommand \url{mailto:drdani@mazsola.iit.uni-miskolc.hu}
3961 The simulator is built as part of the build process.
3962 For more information visit Daniel's web site at:
3963 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
3968 It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
3970 \layout Subsubsection
3973 \begin_inset LatexCommand \index{sdcdb}
3977 - Source Level Debugger
3980 Sdcdb is the companion source level debugger.
3981 The current version of the debugger uses Daniel's Simulator S51
3982 \begin_inset LatexCommand \index{s51}
3986 , but can be easily changed to use other simulators.
3993 \layout Subsubsection
3995 Single Source File Projects
3998 For single source file 8051 projects the process is very simple.
3999 Compile your programs with the following command
4002 "sdcc sourcefile.c".
4006 This will compile, assemble and link your source file.
4007 Output files are as follows
4011 \begin_inset LatexCommand \index{.asm}
4016 \begin_inset LatexCommand \index{Assembler source}
4020 file created by the compiler
4024 \begin_inset LatexCommand \index{.lst}
4029 \begin_inset LatexCommand \index{Assembler listing}
4033 file created by the Assembler
4037 \begin_inset LatexCommand \index{.rst}
4042 \begin_inset LatexCommand \index{Assembler listing}
4046 file updated with linkedit information, created by linkage editor
4050 \begin_inset LatexCommand \index{.sym}
4055 \begin_inset LatexCommand \index{Symbol listing}
4059 for the sourcefile, created by the assembler
4063 \begin_inset LatexCommand \index{.rel}
4068 \begin_inset LatexCommand \index{Object file}
4072 created by the assembler, input to Linkage editor
4076 \begin_inset LatexCommand \index{.map}
4081 \begin_inset LatexCommand \index{Memory map}
4085 for the load module, created by the Linker
4089 \begin_inset LatexCommand \index{.mem}
4093 - A file with a summary of the memory usage
4097 \begin_inset LatexCommand \index{.ihx}
4101 - The load module in Intel hex format
4102 \begin_inset LatexCommand \index{Intel hex format}
4106 (you can select the Motorola S19 format
4107 \begin_inset LatexCommand \index{Motorola S19 format}
4122 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
4127 If you need another format you might want to use
4134 \begin_inset LatexCommand \index{objdump}
4145 \begin_inset LatexCommand \index{srecord}
4153 \begin_inset LatexCommand \index{.adb}
4157 - An intermediate file containing debug information needed to create the
4169 \begin_inset LatexCommand \index{-\/-debug}
4177 \begin_inset LatexCommand \index{.cdb}
4181 - An optional file (with -
4191 -debug) containing debug information
4196 \begin_inset LatexCommand \index{. (no extension)}
4201 \begin_inset LatexCommand \index{AOMF51}
4205 file containing debug information (with -
4216 This format is commonly used by third party tools (debuggers
4217 \begin_inset LatexCommand \index{Debugger}
4221 , simulators, emulators)
4225 \begin_inset LatexCommand \index{.dump*}
4229 - Dump file to debug the compiler it self (with -
4239 -dumpall) (see section
4240 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
4246 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
4252 \begin_inset Quotes sld
4255 Anatomy of the compiler
4256 \begin_inset Quotes srd
4260 \layout Subsubsection
4262 Projects with Multiple Source Files
4265 SDCC can compile only ONE file at a time.
4266 Let us for example assume that you have a project containing the following
4271 foo1.c (contains some functions)
4273 foo2.c (contains some more functions)
4275 foomain.c (contains more functions and the function main)
4283 The first two files will need to be compiled separately with the commands:
4315 Then compile the source file containing the
4320 \begin_inset LatexCommand \index{Linker}
4324 the files together with the following command:
4332 foomain.c\SpecialChar ~
4333 foo1.rel\SpecialChar ~
4338 \begin_inset LatexCommand \index{.rel}
4350 can be separately compiled as well:
4361 sdcc foomain.rel foo1.rel foo2.rel
4368 The file containing the
4383 file specified in the command line, since the linkage editor processes
4384 file in the order they are presented to it.
4385 The linker is invoked from SDCC using a script file with extension .lnk
4386 \begin_inset LatexCommand \index{.lnk}
4391 You can view this file to troubleshoot linking problems such as those arising
4392 from missing libraries.
4393 \layout Subsubsection
4395 Projects with Additional Libraries
4396 \begin_inset LatexCommand \index{Libraries}
4403 Some reusable routines may be compiled into a library, see the documentation
4404 for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
4408 \begin_inset LatexCommand \index{.lib}
4415 Libraries created in this manner can be included in the command line.
4416 Make sure you include the -L <library-path> option to tell the linker where
4417 to look for these files if they are not in the current directory.
4418 Here is an example, assuming you have the source file
4430 (if that is not the same as your current project):
4437 sdcc foomain.c foolib.lib -L mylib
4448 must be an absolute path name.
4452 The most efficient way to use libraries is to keep separate modules in separate
4454 The lib file now should name all the modules.rel
4455 \begin_inset LatexCommand \index{rel}
4460 For an example see the standard library file
4464 in the directory <installdir>/share/lib/small.
4467 Command Line Options
4468 \begin_inset LatexCommand \index{Command Line Options}
4473 \layout Subsubsection
4475 Processor Selection Options
4476 \begin_inset LatexCommand \index{Options processor selection}
4481 \begin_inset LatexCommand \index{Processor selection options}
4487 \labelwidthstring 00.00.0000
4492 \begin_inset LatexCommand \index{-mmcs51}
4498 Generate code for the Intel MCS51
4499 \begin_inset LatexCommand \index{MCS51}
4503 family of processors.
4504 This is the default processor target.
4506 \labelwidthstring 00.00.0000
4511 \begin_inset LatexCommand \index{-mds390}
4517 Generate code for the Dallas DS80C390
4518 \begin_inset LatexCommand \index{DS80C390}
4524 \labelwidthstring 00.00.0000
4529 \begin_inset LatexCommand \index{-mds400}
4535 Generate code for the Dallas DS80C400
4536 \begin_inset LatexCommand \index{DS80C400}
4542 \labelwidthstring 00.00.0000
4547 \begin_inset LatexCommand \index{-mhc08}
4553 Generate code for the Motorola HC08
4554 \begin_inset LatexCommand \index{HC08}
4558 family of processors (added Oct 2003).
4560 \labelwidthstring 00.00.0000
4565 \begin_inset LatexCommand \index{-mz80}
4571 Generate code for the Zilog Z80
4572 \begin_inset LatexCommand \index{Z80}
4576 family of processors.
4578 \labelwidthstring 00.00.0000
4583 \begin_inset LatexCommand \index{-mgbz80}
4589 Generate code for the GameBoy Z80
4590 \begin_inset LatexCommand \index{GameBoy Z80}
4596 \labelwidthstring 00.00.0000
4601 \begin_inset LatexCommand \index{-mavr}
4607 Generate code for the Atmel AVR
4608 \begin_inset LatexCommand \index{AVR}
4612 processor (In development, not complete).
4613 AVR users should probably have a look at avr-gcc
4614 \begin_inset LatexCommand \url{ http://savannah.nongnu.org/download/avr-libc/snapshots/}
4621 I think it is fair to direct users there for now.
4622 Open source is also about avoiding unnecessary work .
4623 But I didn't find the 'official' link.
4625 \labelwidthstring 00.00.0000
4630 \begin_inset LatexCommand \index{-mpic14}
4636 Generate code for the Microchip PIC 14
4637 \begin_inset LatexCommand \index{PIC14}
4641 -bit processors (p16f84 and variants).
4644 p16f627 p16f628 p16f84 p16f873 p16f877?
4646 \labelwidthstring 00.00.0000
4651 \begin_inset LatexCommand \index{-mpic16}
4657 Generate code for the Microchip PIC 16
4658 \begin_inset LatexCommand \index{PIC16}
4662 -bit processors (p18f452 and variants).
4664 \labelwidthstring 00.00.0000
4670 Generate code for the Toshiba TLCS-900H
4671 \begin_inset LatexCommand \index{TLCS-900H}
4675 processor (In development, not complete).
4677 \labelwidthstring 00.00.0000
4682 \begin_inset LatexCommand \index{-mxa51}
4688 Generate code for the Phillips XA51
4689 \begin_inset LatexCommand \index{XA51}
4693 processor (In development, not complete).
4694 \layout Subsubsection
4696 Preprocessor Options
4697 \begin_inset LatexCommand \index{Options preprocessor}
4702 \begin_inset LatexCommand \index{Preprocessor options}
4708 \labelwidthstring 00.00.0000
4713 \begin_inset LatexCommand \index{-I<path>}
4719 The additional location where the pre processor will look for <..h> or
4720 \begin_inset Quotes eld
4724 \begin_inset Quotes erd
4729 \labelwidthstring 00.00.0000
4734 \begin_inset LatexCommand \index{-D<macro[=value]>}
4740 Command line definition of macros.
4741 Passed to the preprocessor.
4743 \labelwidthstring 00.00.0000
4748 \begin_inset LatexCommand \index{-M}
4754 Tell the preprocessor to output a rule suitable for make describing the
4755 dependencies of each object file.
4756 For each source file, the preprocessor outputs one make-rule whose target
4757 is the object file name for that source file and whose dependencies are
4758 all the files `#include'd in it.
4759 This rule may be a single line or may be continued with `
4761 '-newline if it is long.
4762 The list of rules is printed on standard output instead of the preprocessed
4765 \begin_inset LatexCommand \index{-E}
4771 \labelwidthstring 00.00.0000
4776 \begin_inset LatexCommand \index{-C}
4782 Tell the preprocessor not to discard comments.
4783 Used with the `-E' option.
4785 \labelwidthstring 00.00.0000
4790 \begin_inset LatexCommand \index{-MM}
4801 Like `-M' but the output mentions only the user header files included with
4803 \begin_inset Quotes eld
4807 System header files included with `#include <file>' are omitted.
4809 \labelwidthstring 00.00.0000
4814 \begin_inset LatexCommand \index{-Aquestion(answer)}
4820 Assert the answer answer for question, in case it is tested with a preprocessor
4821 conditional such as `#if #question(answer)'.
4822 `-A-' disables the standard assertions that normally describe the target
4825 \labelwidthstring 00.00.0000
4830 \begin_inset LatexCommand \index{-Umacro}
4836 Undefine macro macro.
4837 `-U' options are evaluated after all `-D' options, but before any `-include'
4838 and `-imacros' options.
4840 \labelwidthstring 00.00.0000
4845 \begin_inset LatexCommand \index{-dM}
4851 Tell the preprocessor to output only a list of the macro definitions that
4852 are in effect at the end of preprocessing.
4853 Used with the `-E' option.
4855 \labelwidthstring 00.00.0000
4860 \begin_inset LatexCommand \index{-dD}
4866 Tell the preprocessor to pass all macro definitions into the output, in
4867 their proper sequence in the rest of the output.
4869 \labelwidthstring 00.00.0000
4874 \begin_inset LatexCommand \index{-dN}
4885 Like `-dD' except that the macro arguments and contents are omitted.
4886 Only `#define name' is included in the output.
4887 \layout Subsubsection
4890 \begin_inset LatexCommand \index{Options linker}
4895 \begin_inset LatexCommand \index{Linker options}
4901 \labelwidthstring 00.00.0000
4921 \begin_inset LatexCommand \index{-\/-lib-path}
4926 \begin_inset LatexCommand \index{-L -\/-lib-path}
4935 <absolute path to additional libraries> This option is passed to the linkage
4936 editor's additional libraries
4937 \begin_inset LatexCommand \index{Libraries}
4942 The path name must be absolute.
4943 Additional library files may be specified in the command line.
4944 See section Compiling programs for more details.
4946 \labelwidthstring 00.00.0000
4963 \begin_inset LatexCommand \index{-\/-xram-loc}
4967 <Value> The start location of the external ram
4968 \begin_inset LatexCommand \index{xdata}
4972 , default value is 0.
4973 The value entered can be in Hexadecimal or Decimal format, e.g.: -
4983 -xram-loc 0x8000 or -
4995 \labelwidthstring 00.00.0000
5012 \begin_inset LatexCommand \index{-\/-code-loc}
5016 <Value> The start location of the code
5017 \begin_inset LatexCommand \index{code}
5021 segment, default value 0.
5022 Note when this option is used the interrupt vector table is also relocated
5023 to the given address.
5024 The value entered can be in Hexadecimal or Decimal format, e.g.: -
5034 -code-loc 0x8000 or -
5046 \labelwidthstring 00.00.0000
5063 \begin_inset LatexCommand \index{-\/-stack-loc}
5067 <Value> By default the stack
5068 \begin_inset LatexCommand \index{stack}
5072 is placed after the data segment.
5073 Using this option the stack can be placed anywhere in the internal memory
5075 The value entered can be in Hexadecimal or Decimal format, e.g.
5086 -stack-loc 0x20 or -
5097 Since the sp register is incremented before a push or call, the initial
5098 sp will be set to one byte prior the provided value.
5099 The provided value should not overlap any other memory areas such as used
5100 register banks or the data segment and with enough space for the current
5103 \labelwidthstring 00.00.0000
5120 \begin_inset LatexCommand \index{-\/-data-loc}
5124 <Value> The start location of the internal ram data
5125 \begin_inset LatexCommand \index{data}
5130 The value entered can be in Hexadecimal or Decimal format, eg.
5152 (By default, the start location of the internal ram data segment is set
5153 as low as possible in memory, taking into account the used register banks
5154 and the bit segment at address 0x20.
5155 For example if register banks 0 and 1 are used without bit variables, the
5156 data segment will be set, if -
5166 -data-loc is not used, to location 0x10.)
5168 \labelwidthstring 00.00.0000
5185 \begin_inset LatexCommand \index{-\/-idata-loc}
5189 <Value> The start location of the indirectly addressable internal ram
5190 \begin_inset LatexCommand \index{idata}
5194 , default value is 0x80.
5195 The value entered can be in Hexadecimal or Decimal format, eg.
5206 -idata-loc 0x88 or -
5218 \labelwidthstring 00.00.0000
5233 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
5242 The linker output (final object code) is in Intel Hex format.
5243 \begin_inset LatexCommand \index{Intel hex format}
5247 (This is the default option).
5249 \labelwidthstring 00.00.0000
5264 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5273 The linker output (final object code) is in Motorola S19 format
5274 \begin_inset LatexCommand \index{Motorola S19 format}
5279 \layout Subsubsection
5282 \begin_inset LatexCommand \index{Options MCS51}
5287 \begin_inset LatexCommand \index{MCS51 options}
5293 \labelwidthstring 00.00.0000
5308 \begin_inset LatexCommand \index{-\/-model-small}
5319 Generate code for Small Model programs see section Memory Models for more
5321 This is the default model.
5323 \labelwidthstring 00.00.0000
5338 \begin_inset LatexCommand \index{-\/-model-large}
5344 Generate code for Large model programs see section Memory Models for more
5346 If this option is used all source files in the project have to be compiled
5349 \labelwidthstring 00.00.0000
5364 \begin_inset LatexCommand \index{-\/-xstack}
5370 Uses a pseudo stack in the first 256 bytes in the external ram for allocating
5371 variables and passing parameters.
5373 \begin_inset LatexCommand \ref{sub:External-Stack}
5378 External Stack for more details.
5380 \labelwidthstring 00.00.0000
5397 \begin_inset LatexCommand \index{-\/-iram-size<Value>}
5401 Causes the linker to check if the internal ram usage is within limits of
5404 \labelwidthstring 00.00.0000
5421 \begin_inset LatexCommand \index{-\/-xram-size<Value>}
5425 Causes the linker to check if the external ram usage is within limits of
5428 \labelwidthstring 00.00.0000
5445 \begin_inset LatexCommand \index{-\/-data-loc}
5449 Causes the linker to check if the code memory usage is within limits of
5451 \layout Subsubsection
5454 \begin_inset LatexCommand \index{Options DS390}
5459 \begin_inset LatexCommand \index{DS390 options}
5465 \labelwidthstring 00.00.0000
5482 \begin_inset LatexCommand \index{-\/-model-flat24}
5492 Generate 24-bit flat mode code.
5493 This is the one and only that the ds390 code generator supports right now
5494 and is default when using
5499 See section Memory Models for more details.
5501 \labelwidthstring 00.00.0000
5518 \begin_inset LatexCommand \index{-\/-stack-10bit}
5522 Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
5523 This is the one and only that the ds390 code generator supports right now
5524 and is default when using
5529 In this mode, the stack is located in the lower 1K of the internal RAM,
5530 which is mapped to 0x400000.
5531 Note that the support is incomplete, since it still uses a single byte
5532 as the stack pointer.
5533 This means that only the lower 256 bytes of the potential 1K stack space
5534 will actually be used.
5535 However, this does allow you to reclaim the precious 256 bytes of low RAM
5536 for use for the DATA and IDATA segments.
5537 The compiler will not generate any code to put the processor into 10 bit
5539 It is important to ensure that the processor is in this mode before calling
5540 any re-entrant functions compiled with this option.
5541 In principle, this should work with the
5554 \begin_inset LatexCommand \index{-\/-stack-auto}
5560 option, but that has not been tested.
5561 It is incompatible with the
5574 \begin_inset LatexCommand \index{-\/-xstack}
5581 It also only makes sense if the processor is in 24 bit contiguous addressing
5594 -model-flat24 option
5597 \layout Subsubsection
5600 \begin_inset LatexCommand \index{Options Z80}
5605 \begin_inset LatexCommand \index{Z80 options}
5611 \labelwidthstring 00.00.0000
5628 \begin_inset LatexCommand \index{-\/-callee-saves-bc}
5638 Force a called function to always save BC.
5640 \labelwidthstring 00.00.0000
5657 \begin_inset LatexCommand \index{-\/-no-std-crt0}
5661 When linking, skip the standard crt0.o object file.
5662 You must provide your own crt0.o for your system when linking.
5664 \layout Subsubsection
5666 Optimization Options
5667 \begin_inset LatexCommand \index{Options optimization}
5672 \begin_inset LatexCommand \index{Optimization options}
5678 \labelwidthstring 00.00.0000
5693 \begin_inset LatexCommand \index{-\/-nogcse}
5699 Will not do global subexpression elimination, this option may be used when
5700 the compiler creates undesirably large stack/data spaces to store compiler
5702 A warning message will be generated when this happens and the compiler
5703 will indicate the number of extra bytes it allocated.
5704 It recommended that this option NOT be used, #pragma\SpecialChar ~
5706 \begin_inset LatexCommand \index{\#pragma NOGCSE}
5710 can be used to turn off global subexpression elimination
5711 \begin_inset LatexCommand \index{Subexpression elimination}
5715 for a given function only.
5717 \labelwidthstring 00.00.0000
5732 \begin_inset LatexCommand \index{-\/-noinvariant}
5738 Will not do loop invariant optimizations, this may be turned off for reasons
5739 explained for the previous option.
5740 For more details of loop optimizations performed see section Loop Invariants.It
5741 recommended that this option NOT be used, #pragma\SpecialChar ~
5743 \begin_inset LatexCommand \index{\#pragma NOINVARIANT}
5747 can be used to turn off invariant optimizations for a given function only.
5749 \labelwidthstring 00.00.0000
5764 \begin_inset LatexCommand \index{-\/-noinduction}
5770 Will not do loop induction optimizations, see section strength reduction
5771 for more details.It is recommended that this option is NOT used, #pragma\SpecialChar ~
5774 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
5778 can be used to turn off induction optimizations for a given function only.
5780 \labelwidthstring 00.00.0000
5795 \begin_inset LatexCommand \index{-\/-nojtbound}
5806 Will not generate boundary condition check when switch statements
5807 \begin_inset LatexCommand \index{switch statement}
5811 are implemented using jump-tables.
5813 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
5818 Switch Statements for more details.
5819 It is recommended that this option is NOT used, #pragma\SpecialChar ~
5821 \begin_inset LatexCommand \index{\#pragma NOJTBOUND}
5825 can be used to turn off boundary checking for jump tables for a given function
5828 \labelwidthstring 00.00.0000
5843 \begin_inset LatexCommand \index{-\/-noloopreverse}
5852 Will not do loop reversal
5853 \begin_inset LatexCommand \index{Loop reversing}
5859 \labelwidthstring 00.00.0000
5876 \begin_inset LatexCommand \index{-\/-nolabelopt }
5880 Will not optimize labels (makes the dumpfiles more readable).
5882 \labelwidthstring 00.00.0000
5897 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
5903 Will not memcpy initialized data from code space into xdata space.
5904 This saves a few bytes in code space if you don't have initialized data.
5905 \layout Subsubsection
5908 \begin_inset LatexCommand \index{Options other}
5914 \labelwidthstring 00.00.0000
5930 \begin_inset LatexCommand \index{-\/-compile-only}
5935 \begin_inset LatexCommand \index{-c -\/-compile-only}
5941 will compile and assemble the source, but will not call the linkage editor.
5943 \labelwidthstring 00.00.0000
5962 \begin_inset LatexCommand \index{-\/-c1mode}
5968 reads the preprocessed source from standard input and compiles it.
5969 The file name for the assembler output must be specified using the -o option.
5971 \labelwidthstring 00.00.0000
5976 \begin_inset LatexCommand \index{-E}
5982 Run only the C preprocessor.
5983 Preprocess all the C source files specified and output the results to standard
5986 \labelwidthstring 00.00.0000
5992 \begin_inset LatexCommand \index{-o <path/file>}
5998 The output path resp.
5999 file where everything will be placed.
6000 If the parameter is a path, it must have a trailing slash (or backslash
6001 for the Windows binaries) to be recognized as a path.
6004 \labelwidthstring 00.00.0000
6019 \begin_inset LatexCommand \index{-\/-stack-auto}
6030 All functions in the source file will be compiled as
6035 \begin_inset LatexCommand \index{reentrant}
6040 the parameters and local variables will be allocated on the stack
6041 \begin_inset LatexCommand \index{stack}
6046 see section Parameters and Local Variables for more details.
6047 If this option is used all source files in the project should be compiled
6051 \labelwidthstring 00.00.0000
6066 \begin_inset LatexCommand \index{-\/-callee-saves}
6070 function1[,function2][,function3]....
6073 The compiler by default uses a caller saves convention for register saving
6074 across function calls, however this can cause unnecessary register pushing
6075 & popping when calling small functions from larger functions.
6076 This option can be used to switch the register saving convention for the
6077 function names specified.
6078 The compiler will not save registers when calling these functions, no extra
6079 code will be generated at the entry & exit (function prologue
6082 \begin_inset LatexCommand \index{function prologue}
6091 \begin_inset LatexCommand \index{function epilogue}
6097 ) for these functions to save & restore the registers used by these functions,
6098 this can SUBSTANTIALLY reduce code & improve run time performance of the
6100 In the future the compiler (with inter procedural analysis) will be able
6101 to determine the appropriate scheme to use for each function call.
6102 DO NOT use this option for built-in functions such as _mulint..., if this
6103 option is used for a library function the appropriate library function
6104 needs to be recompiled with the same option.
6105 If the project consists of multiple source files then all the source file
6106 should be compiled with the same -
6116 -callee-saves option string.
6117 Also see #pragma\SpecialChar ~
6119 \begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
6125 \labelwidthstring 00.00.0000
6140 \begin_inset LatexCommand \index{-\/-debug}
6149 When this option is used the compiler will generate debug information, that
6150 can be used with the SDCDB.
6151 The debug information is collected in a file with .cdb extension.
6152 For more information see documentation for SDCDB.
6154 \labelwidthstring 00.00.0000
6159 \begin_inset LatexCommand \index{-S}
6170 Stop after the stage of compilation proper; do not assemble.
6171 The output is an assembler code file for the input file specified.
6173 \labelwidthstring 00.00.0000
6177 -Wa_asmOption[,asmOption]
6180 \begin_inset LatexCommand \index{-Wa\_asmOption[,asmOption]}
6185 Pass the asmOption to the assembler.
6187 \labelwidthstring 00.00.0000
6191 -Wl_linkOption[,linkOption]
6194 \begin_inset LatexCommand \index{-Wl\_linkOption[,linkOption]}
6199 Pass the linkOption to the linker.
6201 \labelwidthstring 00.00.0000
6216 \begin_inset LatexCommand \index{-\/-int-long-reent}
6222 Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
6223 Note by default these libraries are compiled as non-reentrant.
6224 See section Installation for more details.
6226 \labelwidthstring 00.00.0000
6241 \begin_inset LatexCommand \index{-\/-cyclomatic}
6250 This option will cause the compiler to generate an information message for
6251 each function in the source file.
6252 The message contains some
6256 information about the function.
6257 The number of edges and nodes the compiler detected in the control flow
6258 graph of the function, and most importantly the
6260 cyclomatic complexity
6261 \begin_inset LatexCommand \index{Cyclomatic complexity}
6267 see section on Cyclomatic Complexity for more details.
6269 \labelwidthstring 00.00.0000
6284 \begin_inset LatexCommand \index{-\/-float-reent}
6293 Floating point library is compiled as reentrant
6294 \begin_inset LatexCommand \index{reentrant}
6299 See section Installation for more details.
6301 \labelwidthstring 00.00.0000
6316 \begin_inset LatexCommand \index{-\/-nooverlay}
6322 The compiler will not overlay parameters and local variables of any function,
6323 see section Parameters and local variables for more details.
6325 \labelwidthstring 00.00.0000
6340 \begin_inset LatexCommand \index{-\/-main-return}
6346 This option can be used when the code generated is called by a monitor
6348 The compiler will generate a 'ret' upon return from the 'main'
6349 \begin_inset LatexCommand \index{main return}
6354 The default setting is to lock up i.e.
6361 \labelwidthstring 00.00.0000
6378 \begin_inset LatexCommand \index{-\/-peep-file}
6382 <filename> This option can be used to use additional rules to be used by
6383 the peep hole optimizer.
6385 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
6390 Peep Hole optimizations for details on how to write these rules.
6392 \labelwidthstring 00.00.0000
6407 \begin_inset LatexCommand \index{-\/-no-peep}
6413 Disable peep-hole optimization.
6415 \labelwidthstring 00.00.0000
6430 \begin_inset LatexCommand \index{-\/-peep-asm}
6436 Pass the inline assembler code through the peep hole optimizer.
6437 This can cause unexpected changes to inline assembler code, please go through
6438 the peephole optimizer
6439 \begin_inset LatexCommand \index{Peephole optimizer}
6443 rules defined in the source file tree '<target>/peeph.def' before using
6446 \labelwidthstring 00.00.0000
6461 \begin_inset LatexCommand \index{-\/-nostdincl}
6467 This will prevent the compiler from passing on the default include path
6468 to the preprocessor.
6470 \labelwidthstring 00.00.0000
6485 \begin_inset LatexCommand \index{-\/-nostdlib}
6491 This will prevent the compiler from passing on the default library
6492 \begin_inset LatexCommand \index{Libraries}
6498 \labelwidthstring 00.00.0000
6513 \begin_inset LatexCommand \index{-\/-verbose}
6519 Shows the various actions the compiler is performing.
6521 \labelwidthstring 00.00.0000
6526 \begin_inset LatexCommand \index{-V}
6532 Shows the actual commands the compiler is executing.
6534 \labelwidthstring 00.00.0000
6549 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
6555 Hides your ugly and inefficient c-code from the asm file, so you can always
6556 blame the compiler :).
6558 \labelwidthstring 00.00.0000
6573 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
6579 Include i-codes in the asm file.
6580 Sounds like noise but is most helpful for debugging the compiler itself.
6582 \labelwidthstring 00.00.0000
6597 \begin_inset LatexCommand \index{-\/-less-pedantic}
6603 Disable some of the more pedantic warnings
6604 \begin_inset LatexCommand \index{Warnings}
6608 (jwk burps: please be more specific here, please!).
6609 If you want rather more than less warnings you should consider using a
6610 separate tool dedicated to syntax checking like
6611 \begin_inset LatexCommand \url{www.splint.org}
6617 \labelwidthstring 00.00.0000
6632 \begin_inset LatexCommand \index{-\/-print-search-dirs}
6638 Display the directories in the compiler's search path
6640 \labelwidthstring 00.00.0000
6655 \begin_inset LatexCommand \index{-\/-vc}
6661 Display errors and warnings using MSVC style, so you can use SDCC with
6664 \labelwidthstring 00.00.0000
6679 \begin_inset LatexCommand \index{-\/-use-stdout}
6685 Send errors and warnings to stdout instead of stderr.
6686 \layout Subsubsection
6688 Intermediate Dump Options
6689 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
6694 \begin_inset LatexCommand \index{Options intermediate dump}
6699 \begin_inset LatexCommand \index{Intermediate dump options}
6706 The following options are provided for the purpose of retargetting and debugging
6708 These provided a means to dump the intermediate code (iCode
6709 \begin_inset LatexCommand \index{iCode}
6713 ) generated by the compiler in human readable form at various stages of
6714 the compilation process.
6717 \labelwidthstring 00.00.0000
6732 \begin_inset LatexCommand \index{-\/-dumpraw}
6738 This option will cause the compiler to dump the intermediate code into
6741 <source filename>.dumpraw
6743 just after the intermediate code has been generated for a function, i.e.
6744 before any optimizations are done.
6746 \begin_inset LatexCommand \index{Basic blocks}
6750 at this stage ordered in the depth first number, so they may not be in
6751 sequence of execution.
6753 \labelwidthstring 00.00.0000
6768 \begin_inset LatexCommand \index{-\/-dumpgcse}
6774 Will create a dump of iCode's, after global subexpression elimination
6775 \begin_inset LatexCommand \index{Global subexpression elimination}
6781 <source filename>.dumpgcse.
6783 \labelwidthstring 00.00.0000
6798 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
6804 Will create a dump of iCode's, after deadcode elimination
6805 \begin_inset LatexCommand \index{Dead-code elimination}
6811 <source filename>.dumpdeadcode.
6813 \labelwidthstring 00.00.0000
6828 \begin_inset LatexCommand \index{-\/-dumploop}
6837 Will create a dump of iCode's, after loop optimizations
6838 \begin_inset LatexCommand \index{Loop optimization}
6844 <source filename>.dumploop.
6846 \labelwidthstring 00.00.0000
6861 \begin_inset LatexCommand \index{-\/-dumprange}
6870 Will create a dump of iCode's, after live range analysis
6871 \begin_inset LatexCommand \index{Live range analysis}
6877 <source filename>.dumprange.
6879 \labelwidthstring 00.00.0000
6894 \begin_inset LatexCommand \index{-\/-dumlrange}
6900 Will dump the life ranges
6901 \begin_inset LatexCommand \index{Live range analysis}
6907 \labelwidthstring 00.00.0000
6922 \begin_inset LatexCommand \index{-\/-dumpregassign}
6931 Will create a dump of iCode's, after register assignment
6932 \begin_inset LatexCommand \index{Register assignment}
6938 <source filename>.dumprassgn.
6940 \labelwidthstring 00.00.0000
6955 \begin_inset LatexCommand \index{-\/-dumplrange}
6961 Will create a dump of the live ranges of iTemp's
6963 \labelwidthstring 00.00.0000
6978 \begin_inset LatexCommand \index{-\/-dumpall}
6989 Will cause all the above mentioned dumps to be created.
6990 \layout Subsubsection
6992 Redirecting output on Windows Shells
6995 By default SDCC writes it's error messages to
6996 \begin_inset Quotes sld
7000 \begin_inset Quotes srd
7004 To force all messages to
7005 \begin_inset Quotes sld
7009 \begin_inset Quotes srd
7033 \begin_inset LatexCommand \index{-\/-use-stdout}
7038 Aditionaly, if you happen to have visual studio installed in your windows
7039 machine, you can use it to compile your sources using a custom build and
7055 \begin_inset LatexCommand \index{-\/-vc}
7060 Something like this should work:
7104 -model-large -c $(InputPath)
7107 Environment variables
7108 \begin_inset LatexCommand \index{Environment variables}
7115 SDCC recognizes the following environment variables:
7117 \labelwidthstring 00.00.0000
7122 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
7128 SDCC installs a signal handler
7129 \begin_inset LatexCommand \index{signal handler}
7133 to be able to delete temporary files after an user break (^C) or an exception.
7134 If this environment variable is set, SDCC won't install the signal handler
7135 in order to be able to debug SDCC.
7137 \labelwidthstring 00.00.0000
7144 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
7150 Path, where temporary files will be created.
7151 The order of the variables is the search order.
7152 In a standard *nix environment these variables are not set, and there's
7153 no need to set them.
7154 On Windows it's recommended to set one of them.
7156 \labelwidthstring 00.00.0000
7161 \begin_inset LatexCommand \index{SDCC\_HOME}
7168 \begin_inset LatexCommand \ref{sub:Install-paths}
7174 \begin_inset Quotes sld
7178 \begin_inset Quotes srd
7183 \labelwidthstring 00.00.0000
7188 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
7195 \begin_inset LatexCommand \ref{sub:Search-Paths}
7201 \begin_inset Quotes sld
7205 \begin_inset Quotes srd
7210 \labelwidthstring 00.00.0000
7215 \begin_inset LatexCommand \index{SDCC\_LIB}
7222 \begin_inset LatexCommand \ref{sub:Search-Paths}
7228 \begin_inset Quotes sld
7232 \begin_inset Quotes srd
7238 There are some more environment variables recognized by SDCC, but these
7239 are solely used for debugging purposes.
7240 They can change or disappear very quickly, and will never be documented.
7243 MCS51/DS390 Storage Class
7244 \begin_inset LatexCommand \index{Storage class}
7251 In addition to the ANSI storage classes SDCC allows the following MCS51
7252 specific storage classes.
7253 \layout Subsubsection
7256 \begin_inset LatexCommand \index{data}
7267 storage class for the Small Memory model.
7268 Variables declared with this storage class will be allocated in the directly
7269 addressable portion of the internal RAM of a 8051, e.g.:
7274 data unsigned char test_data;
7277 Writing 0x01 to this variable generates the assembly code:
7282 75*00 01\SpecialChar ~
7288 \layout Subsubsection
7291 \begin_inset LatexCommand \index{xdata}
7298 Variables declared with this storage class will be placed in the external
7304 storage class for the Large Memory model, e.g.:
7309 xdata unsigned char test_xdata;
7312 Writing 0x01 to this variable generates the assembly code:
7317 90s00r00\SpecialChar ~
7346 \layout Subsubsection
7349 \begin_inset LatexCommand \index{idata}
7356 Variables declared with this storage class will be allocated into the indirectly
7357 addressable portion of the internal ram of a 8051, e.g.:
7362 idata unsigned char test_idata;
7365 Writing 0x01 to this variable generates the assembly code:
7392 \layout Subsubsection
7395 \begin_inset LatexCommand \index{pdata}
7402 Paged xdata access is currently not as straightforward as using the other
7403 addressing modes of a 8051.
7404 The following example writes 0x01 to the address pointed to.
7405 Please note, pdata access physically accesses xdata memory.
7406 The high byte of the address is determined by port P2 (or in case of some
7407 8051 variants by a separate Special Function Register, see section
7408 \begin_inset LatexCommand \ref{sub:MCS51-variants}
7417 pdata unsigned char *test_pdata_ptr;
7429 test_pdata_ptr = (pdata *)0xfe;
7435 *test_pdata_ptr = 1;
7440 Generates the assembly code:
7445 75*01 FE\SpecialChar ~
7449 _test_pdata_ptr,#0xFE
7481 Be extremely carefull if you use pdata together with the -
7492 \begin_inset LatexCommand \index{-\/-xstack}
7497 \layout Subsubsection
7500 \begin_inset LatexCommand \index{code}
7507 'Variables' declared with this storage class will be placed in the code
7513 code unsigned char test_code;
7516 Read access to this variable generates the assembly code:
7521 90s00r6F\SpecialChar ~
7524 mov dptr,#_test_code
7547 \layout Subsubsection
7550 \begin_inset LatexCommand \index{bit}
7557 This is a data-type and a storage class specifier.
7558 When a variable is declared as a bit, it is allocated into the bit addressable
7559 memory of 8051, e.g.:
7567 Writing 1 to this variable generates the assembly code:
7581 \layout Subsubsection
7584 \begin_inset LatexCommand \index{sfr}
7589 \begin_inset LatexCommand \index{sbit}
7596 Like the bit keyword,
7600 signifies both a data-type and storage class, they are used to describe
7601 the special function registers and special bit variables of a 8051, eg:
7607 \begin_inset LatexCommand \index{at}
7611 0x80 P0;\SpecialChar ~
7612 /* special function register P0 at location 0x80 */
7614 sbit at 0xd7 CY; /* CY (Carry Flag
7615 \begin_inset LatexCommand \index{Flags}
7620 \begin_inset LatexCommand \index{Carry flag}
7625 \layout Subsubsection
7628 \begin_inset LatexCommand \index{Pointers}
7632 to MCS51/DS390 specific memory spaces
7635 SDCC allows (via language extensions) pointers to explicitly point to any
7636 of the memory spaces
7637 \begin_inset LatexCommand \index{Memory model}
7642 In addition to the explicit pointers, the compiler uses (by default) generic
7643 pointers which can be used to point to any of the memory spaces.
7647 Pointer declaration examples:
7652 /* pointer physically in internal ram pointing to object in external ram
7655 xdata unsigned char * data p;
7659 /* pointer physically in external ram pointing to object in internal ram
7662 data unsigned char * xdata p;
7666 /* pointer physically in code rom pointing to data in xdata space */
7668 xdata unsigned char * code p;
7672 /* pointer physically in code space pointing to data in code space */
7674 code unsigned char * code p;
7678 /* the following is a generic pointer physically located in xdata space
7684 Well you get the idea.
7689 All unqualified pointers are treated as 3-byte (4-byte for the ds390)
7702 The highest order byte of the
7706 pointers contains the data space information.
7707 Assembler support routines are called whenever data is stored or retrieved
7713 These are useful for developing reusable library
7714 \begin_inset LatexCommand \index{Libraries}
7719 Explicitly specifying the pointer type will generate the most efficient
7724 \begin_inset LatexCommand \index{Absolute addressing}
7731 Data items can be assigned an absolute address with the
7734 \begin_inset LatexCommand \index{at}
7740 keyword, in addition to a storage class, e.g.:
7746 \begin_inset LatexCommand \index{xdata}
7751 \begin_inset LatexCommand \index{at}
7755 0x7ffe unsigned int chksum;
7758 In the above example the variable chksum will located at 0x7ffe and 0x7fff
7759 of the external ram.
7760 The compiler does not actually reserve any space for variables declared
7761 in this way (they are implemented with an equate in the assembler).
7762 Thus it is left to the programmer to make sure there are no overlaps with
7763 other variables that are declared without the absolute address.
7764 The assembler listing file (.lst
7765 \begin_inset LatexCommand \index{.lst}
7769 ) and the linker output files (.rst
7770 \begin_inset LatexCommand \index{.rst}
7775 \begin_inset LatexCommand \index{.map}
7779 ) are good places to look for such overlaps.
7782 In case of memory mapped I/O devices the keyword
7786 should be used to tell the compiler that accesses might not be optimized
7793 \begin_inset LatexCommand \index{volatile}
7798 \begin_inset LatexCommand \index{xdata}
7803 \begin_inset LatexCommand \index{at}
7807 0x8000 unsigned char PORTA_8255;
7810 Absolute address can be specified for variables in all storage classes,
7817 \begin_inset LatexCommand \index{bit}
7822 \begin_inset LatexCommand \index{at}
7829 The above example will allocate the variable at offset 0x02 in the bit-addressab
7831 There is no real advantage to assigning absolute addresses to variables
7832 in this manner, unless you want strict control over all the variables allocated.
7833 One possible use would be to write hardware portable code.
7834 For example, if you have a routine that uses one or more of the microcontroller
7835 I/O pins, and such pins are different for two different hardwares, you
7836 can declare the I/O pins in your routine using:
7841 extern volatile bit SDI;
7843 extern volatile bit SCLK;
7845 extern volatile bit CPOL;
7849 void DS1306_put(unsigned char value)
7857 unsigned char mask=0x80;
7881 SDI=(value & mask)?1:0;
7922 Then, someplace in the code for the first hardware you would use
7927 bit at 0x80 SDI;\SpecialChar ~
7931 /* I/O port 0, bit 0 */
7933 bit at 0x81 SCLK;\SpecialChar ~
7936 /* I/O port 0, bit 1 */
7938 bit CPOL;\SpecialChar ~
7949 /* This is a variable, let the linker allocate this one */
7952 Similarly, for the second hardware you would use
7957 bit at 0x83 SDI;\SpecialChar ~
7961 /* I/O port 0, bit 3 */
7963 bit at 0x91 SCLK;\SpecialChar ~
7966 /* I/O port 1, bit 1 */
7968 bit CPOL;\SpecialChar ~
7979 /* This is a variable, let the linker allocate this one */
7982 and you can use the same hardware dependent routine without changes, as
7983 for example in a library.
7984 This is somehow similar to sbit, but only one absolute address has to be
7985 specified in the whole project.
7989 \begin_inset LatexCommand \index{Parameters}
7994 \begin_inset LatexCommand \index{Local variable}
8001 Automatic (local) variables and parameters to functions can either be placed
8002 on the stack or in data-space.
8003 The default action of the compiler is to place these variables in the internal
8004 RAM (for small model) or external RAM (for large model).
8005 This in fact makes them similar to
8008 \begin_inset LatexCommand \index{static}
8014 so by default functions are non-reentrant
8015 \begin_inset LatexCommand \index{reentrant}
8024 They can be placed on the stack
8025 \begin_inset LatexCommand \index{stack}
8042 \begin_inset LatexCommand \index{-\/-stack-auto}
8048 option or by using the
8051 \begin_inset LatexCommand \index{reentrant}
8057 keyword in the function declaration, e.g.:
8062 unsigned char foo(char i) reentrant
8076 Since stack space on 8051 is limited, the
8094 option should be used sparingly.
8095 Note that the reentrant keyword just means that the parameters & local
8096 variables will be allocated to the stack, it
8100 mean that the function is register bank independent.
8104 Local variables can be assigned storage classes and absolute
8105 \begin_inset LatexCommand \index{Absolute addressing}
8122 xdata unsigned char i;
8134 data at 0x31 unsigned char j;
8146 In the above example the variable
8150 will be allocated in the external ram,
8154 in bit addressable space and
8173 or when a function is declared as
8177 this should only be done for static variables.
8180 Parameters however are not allowed any storage class, (storage classes for
8181 parameters will be ignored), their allocation is governed by the memory
8182 model in use, and the reentrancy options.
8186 \begin_inset LatexCommand \label{sub:Overlaying}
8191 \begin_inset LatexCommand \index{Overlaying}
8199 \begin_inset LatexCommand \index{reentrant}
8203 functions SDCC will try to reduce internal ram space usage by overlaying
8204 parameters and local variables of a function (if possible).
8205 Parameters and local variables of a function will be allocated to an overlayabl
8206 e segment if the function has
8208 no other function calls and the function is non-reentrant and the memory
8210 \begin_inset LatexCommand \index{Memory model}
8217 If an explicit storage class
8218 \begin_inset LatexCommand \index{Storage class}
8222 is specified for a local variable, it will NOT be overlayed.
8225 Note that the compiler (not the linkage editor) makes the decision for overlayin
8227 Functions that are called from an interrupt service routine should be preceded
8228 by a #pragma\SpecialChar ~
8230 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
8234 if they are not reentrant.
8237 Also note that the compiler does not do any processing of inline assembler
8238 code, so the compiler might incorrectly assign local variables and parameters
8239 of a function into the overlay segment if the inline assembler code calls
8240 other c-functions that might use the overlay.
8241 In that case the #pragma\SpecialChar ~
8242 NOOVERLAY should be used.
8245 Parameters and local variables of functions that contain 16 or 32 bit multiplica
8247 \begin_inset LatexCommand \index{Multiplication}
8252 \begin_inset LatexCommand \index{Division}
8256 will NOT be overlayed since these are implemented using external functions,
8265 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
8271 void set_error(unsigned char errcd)
8287 void some_isr () interrupt
8288 \begin_inset LatexCommand \index{interrupt}
8318 In the above example the parameter
8326 would be assigned to the overlayable segment if the #pragma\SpecialChar ~
8328 not present, this could cause unpredictable runtime behavior when called
8330 The #pragma\SpecialChar ~
8331 NOOVERLAY ensures that the parameters and local variables for
8332 the function are NOT overlayed.
8335 Interrupt Service Routines
8336 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
8343 SDCC allows interrupt service routines to be coded in C, with some extended
8349 void timer_isr (void) interrupt 1 using 1
8363 The optional number following the
8366 \begin_inset LatexCommand \index{interrupt}
8372 keyword is the interrupt number this routine will service.
8373 When present, the compiler will insert a call to this routine in the interrupt
8374 vector table for the interrupt number specified.
8379 keyword can be used to tell the compiler to use the specified register
8380 bank (8051 specific) when generating code for this function.
8386 If you have multiple source files in your project, interrupt service routines
8387 can be present in any of them, but a prototype of the isr MUST be present
8388 or included in the file that contains the function
8395 Interrupt numbers and the corresponding address & descriptions for the Standard
8396 8051/8052 are listed below.
8397 SDCC will automatically adjust the interrupt vector table to the maximum
8398 interrupt number specified.
8404 \begin_inset Tabular
8405 <lyxtabular version="3" rows="7" columns="3">
8407 <column alignment="center" valignment="top" leftline="true" width="0in">
8408 <column alignment="center" valignment="top" leftline="true" width="0in">
8409 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0in">
8410 <row topline="true" bottomline="true">
8411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8427 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8436 <row topline="true">
8437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8445 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8453 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8462 <row topline="true">
8463 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8479 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8488 <row topline="true">
8489 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8497 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8505 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8514 <row topline="true">
8515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8531 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8540 <row topline="true">
8541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8557 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8566 <row topline="true" bottomline="true">
8567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8575 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
8583 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
8601 If the interrupt service routine is defined without
8604 \begin_inset LatexCommand \index{using}
8610 a register bank or with register bank 0 (using 0), the compiler will save
8611 the registers used by itself on the stack upon entry and restore them at
8612 exit, however if such an interrupt service routine calls another function
8613 then the entire register bank will be saved on the stack.
8614 This scheme may be advantageous for small interrupt service routines which
8615 have low register usage.
8618 If the interrupt service routine is defined to be using a specific register
8623 are save and restored, if such an interrupt service routine calls another
8624 function (using another register bank) then the entire register bank of
8625 the called function will be saved on the stack.
8626 This scheme is recommended for larger interrupt service routines.
8629 Using interrupts opens the door for some very interesting bugs:
8632 If the interrupt service routines changes variables which are accessed by
8633 other functions these variables should be declared
8638 \begin_inset LatexCommand \index{volatile}
8643 If the access to these variables is not
8646 \begin_inset LatexCommand \index{atomic access}
8653 the processor needs more than one instruction for the access and could
8654 be interrupted while accessing the variable) the interrupt must disabled
8655 during the access to avoid inconsistent data.
8656 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
8657 and should be protected by disabling interrupts.
8658 You're not automatically on the safe side if you use 8 bit variables though.
8659 We need an example here: f.e.
8660 on the 8051 the harmless looking
8661 \begin_inset Quotes srd
8671 \begin_inset Quotes sld
8680 \begin_inset Quotes srd
8690 \begin_inset Quotes sld
8693 from within an interrupt routine might get lost if the interrupt occurs
8696 \begin_inset Quotes sld
8701 counter\SpecialChar ~
8706 \begin_inset Quotes srd
8709 is not atomic on the 8051 even if
8713 is located in data memory.
8714 Bugs like these are hard to reproduce and can cause a lot of trouble.
8718 A special note here, int (16 bit) and long (32 bit) integer division
8719 \begin_inset LatexCommand \index{Division}
8724 \begin_inset LatexCommand \index{Multiplication}
8729 \begin_inset LatexCommand \index{Modulus}
8734 \begin_inset LatexCommand \index{Floating point support}
8738 operations are implemented using external support routines developed in
8740 If an interrupt service routine needs to do any of these operations then
8741 the support routines (as mentioned in a following section) will have to
8742 be recompiled using the
8755 \begin_inset LatexCommand \index{-\/-stack-auto}
8761 option and the source file will need to be compiled using the
8776 \begin_inset LatexCommand \index{-\/-int-long-rent}
8783 Calling other functions from an interrupt service routine is not recommended,
8784 avoid it if possible.
8785 Note that when some function is called from an interrupt service routine
8786 it should be preceded by a #pragma\SpecialChar ~
8788 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
8792 if it is not reentrant.
8793 Furthermore nonreentrant functions should not be called from the main program
8794 while the interrupt service routine might be active.
8800 \begin_inset LatexCommand \ref{sub:Overlaying}
8805 about Overlaying and section
8806 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
8811 about Functions using private banks.
8814 Enabling and Disabling Interrupts
8815 \layout Subsubsection
8817 Critical Functions and Critical Statements
8820 A special keyword may be associated with a function declaring it as
8825 SDCC will generate code to disable all interrupts
8826 \begin_inset LatexCommand \index{interrupt}
8830 upon entry to a critical function and restore the interrupt enable to the
8831 previous state before returning.
8832 Nesting critical functions will need one additional byte on the stack
8833 \begin_inset LatexCommand \index{stack}
8843 \begin_inset LatexCommand \index{critical}
8868 The critical attribute maybe used with other attributes like
8878 may also be used to disable interrupts more locally:
8886 More than one statement could have been included in the block.
8887 \layout Subsubsection
8889 Enabling and Disabling Interrupts directly
8893 \begin_inset LatexCommand \index{interrupt}
8897 can also be disabled and enabled directly (8051):
8915 On other architectures which have seperate opcodes for enabling and disabling
8916 interrupts you might want to make use of defines with inline assembly
8917 \begin_inset LatexCommand \index{Assembler routines}
8927 \begin_inset LatexCommand \index{\_asm}
8936 \begin_inset LatexCommand \index{\_endasm}
8945 #define SEI _asm\SpecialChar ~
8957 Note: it is sometimes sufficient to disable only a specific interrupt source
8959 a timer or serial interrupt by manipulating an
8962 \begin_inset LatexCommand \index{interrupt mask}
8969 Usually the time during which interrupts are disabled should be kept as
8976 \begin_inset LatexCommand \index{interrupt latency}
8980 (the time between the occurrence of the interrupt and the execution of
8981 the first code in the interrupt routine) and
8986 \begin_inset LatexCommand \index{interrupt jitter}
8990 (the difference between the shortest and the longest interrupt latency).
8993 You can reenable interrupts within an interrupt routine and on some architecture
8994 s you can make use of two (or more) levels of
8996 interrupt priorities
8999 \begin_inset LatexCommand \index{interrupt priority}
9004 On architectures which don't support interrupt priorities these can be
9005 implemented by manipulating the interrupt mask and reenabling interrupts
9006 within the interrupt routine.
9007 Don't add complexity unless you have to.
9011 Functions using private banks
9012 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
9017 \begin_inset LatexCommand \index{bank}
9027 \begin_inset LatexCommand \index{using}
9033 attribute (which tells the compiler to use a register bank other than the
9034 default bank zero) should only be applied to
9037 \begin_inset LatexCommand \index{interrupt}
9043 functions (see note 1 below).
9044 This will in most circumstances make the generated ISR code more efficient
9045 since it will not have to save registers on the stack.
9052 attribute will have no effect on the generated code for a
9056 function (but may occasionally be useful anyway
9062 possible exception: if a function is called ONLY from 'interrupt' functions
9063 using a particular bank, it can be declared with the same 'using' attribute
9064 as the calling 'interrupt' functions.
9065 For instance, if you have several ISRs using bank one, and all of them
9066 call memcpy(), it might make sense to create a specialized version of memcpy()
9067 'using 1', since this would prevent the ISR from having to save bank zero
9068 to the stack on entry and switch to bank zero before calling the function
9075 (pending: I don't think this has been done yet)
9082 function using a non-zero bank will assume that it can trash that register
9083 bank, and will not save it.
9084 Since high-priority interrupts
9085 \begin_inset LatexCommand \index{interrupt priority}
9089 can interrupt low-priority ones on the 8051 and friends, this means that
9090 if a high-priority ISR
9094 a particular bank occurs while processing a low-priority ISR
9098 the same bank, terrible and bad things can happen.
9099 To prevent this, no single register bank should be
9103 by both a high priority and a low priority ISR.
9104 This is probably most easily done by having all high priority ISRs use
9105 one bank and all low priority ISRs use another.
9106 If you have an ISR which can change priority at runtime, you're on your
9107 own: I suggest using the default bank zero and taking the small performance
9111 It is most efficient if your ISR calls no other functions.
9112 If your ISR must call other functions, it is most efficient if those functions
9113 use the same bank as the ISR (see note 1 below); the next best is if the
9114 called functions use bank zero.
9115 It is very inefficient to call a function using a different, non-zero bank
9121 \begin_inset LatexCommand \label{sub:Startup-Code}
9126 \begin_inset LatexCommand \index{Startup code}
9131 \layout Subsubsection
9133 MCS51/DS390 Startup Code
9136 The compiler inserts a call to the C routine
9138 _sdcc_external_startup()
9139 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
9148 at the start of the CODE area.
9149 This routine is in the runtime library
9150 \begin_inset LatexCommand \index{Runtime library}
9155 By default this routine returns 0, if this routine returns a non-zero value,
9156 the static & global variable initialization will be skipped and the function
9157 main will be invoked.
9158 Otherwise static & global variables will be initialized before the function
9162 _sdcc_external_startup()
9164 routine to your program to override the default if you need to setup hardware
9165 or perform some other critical operation prior to static & global variable
9167 On some mcs51 variants xdata has to be explicitly enabled before it can
9168 be accessed, this is the place to do it.
9169 See also the compiler option
9188 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9193 \begin_inset LatexCommand \ref{sub:MCS51-variants}
9198 about MCS51-variants.
9199 \layout Subsubsection
9204 On the Z80 the startup code is inserted by linking with crt0.o which is generated
9205 from sdcc/device/lib/z80/crt0.s.
9206 If you need a different startup code you can use the compiler option
9227 \begin_inset LatexCommand \index{-\/-no-std-crt0}
9231 and provide your own crt0.o.
9235 Inline Assembler Code
9236 \begin_inset LatexCommand \index{Assembler routines}
9241 \layout Subsubsection
9243 A Step by Step Introduction
9246 Starting from a small snippet of c-code this example shows for the MCS51
9247 how to use inline assembly, access variables, a function parameter and
9248 an array in xdata memory.
9249 This is a buffer routine which should be optimized:
9255 unsigned char xdata at 0x7f00 buf[0x100];
9257 unsigned char head,tail;
9261 void to_buffer( unsigned char c )
9269 if( head != tail-1 )
9284 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
9285 then a corresponding buffer.asm file is generated.
9286 We define a new function
9290 in file buffer.c in which we cut and paste the generated code, removing
9291 unwanted comments and some ':'.
9293 \begin_inset Quotes sld
9297 \begin_inset Quotes srd
9301 \begin_inset Quotes sld
9305 \begin_inset Quotes srd
9308 to the beginning and the end of the function body:
9314 /* With a cut and paste from the .asm file, we have something to start with.
9319 The function is not yet OK! (registers aren't saved) */
9321 void to_buffer_asm( unsigned char c )
9330 \begin_inset LatexCommand \index{\_asm}
9344 ;buffer.c if( head != tail-1 )
9386 ;buffer.c buf[ head++ ] = c;
9482 The new file buffer.c should compile with only one warning about the unreferenced
9483 function argument 'c'.
9484 Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
9491 unsigned char xdata at 0x7f00 buf[0x100];
9493 unsigned char head,tail;
9495 #define USE_ASSEMBLY
9499 #ifndef USE_ASSEMBLY
9501 void to_buffer( unsigned char c )
9509 if( head != tail-1 )
9529 void to_buffer( unsigned char c )
9537 c; // to avoid warning: unreferenced function argument
9544 \begin_inset LatexCommand \index{\_asm}
9558 ; save used registers here.
9569 ; If we were still using r2,r3 we would have to push them here.
9572 ; if( head != tail-1 )
9615 ; we could do an ANL a,#0x0f here to use a smaller buffer (see below)
9639 ; buf[ head++ ] = c;
9650 a,dpl \SpecialChar ~
9657 ; dpl holds lower byte of function argument
9668 dpl,_head \SpecialChar ~
9671 ; buf is 0x100 byte aligned so head can be used directly
9713 ; we could do an ANL _head,#0x0f here to use a smaller buffer (see above)
9725 ; restore used registers here
9738 The inline assembler code can contain any valid code understood by the assembler
9739 , this includes any assembler directives and comment lines
9745 The assembler does not like some characters like ':' or ''' in comments.
9749 The compiler does not do any validation of the code within the
9752 \begin_inset LatexCommand \index{\_asm}
9760 Specifically it will not know which registers are used and thus register
9762 \begin_inset LatexCommand \index{push/pop}
9766 has to be done manually.
9770 It is strongly recommended that each assembly instruction (including labels)
9771 be placed in a separate line (as the example shows).
9785 \begin_inset LatexCommand \index{-\/-peep-asm}
9791 command line option is used, the inline assembler code will be passed through
9792 the peephole optimizer
9793 \begin_inset LatexCommand \index{Peephole optimizer}
9798 There are only a few (if any) cases where this option makes sense, it might
9799 cause some unexpected changes in the inline assembler code.
9800 Please go through the peephole optimizer rules defined in file
9804 carefully before using this option.
9805 \layout Subsubsection
9808 \begin_inset LatexCommand \label{sub:Naked-Functions}
9813 \begin_inset LatexCommand \index{Naked functions}
9820 A special keyword may be associated with a function declaring it as
9823 \begin_inset LatexCommand \index{\_naked}
9834 function modifier attribute prevents the compiler from generating prologue
9835 \begin_inset LatexCommand \index{function prologue}
9840 \begin_inset LatexCommand \index{function epilogue}
9844 code for that function.
9845 This means that the user is entirely responsible for such things as saving
9846 any registers that may need to be preserved, selecting the proper register
9847 bank, generating the
9851 instruction at the end, etc.
9852 Practically, this means that the contents of the function must be written
9853 in inline assembler.
9854 This is particularly useful for interrupt functions, which can have a large
9855 (and often unnecessary) prologue/epilogue.
9856 For example, compare the code generated by these two functions:
9862 \begin_inset LatexCommand \index{volatile}
9866 data unsigned char counter;
9870 void simpleInterrupt(void) interrupt
9871 \begin_inset LatexCommand \index{interrupt}
9889 void nakedInterrupt(void) interrupt 2 _naked
9898 \begin_inset LatexCommand \index{\_asm}
9927 ; MUST explicitly include ret or reti in _naked function.
9934 \begin_inset LatexCommand \index{\_endasm}
9943 For an 8051 target, the generated simpleInterrupt looks like:
10084 whereas nakedInterrupt looks like:
10108 ; MUST explicitly include ret or reti in _naked function.
10111 The #pragma directive EXCLUDE
10112 \begin_inset LatexCommand \index{\#pragma EXCLUDE}
10116 allows a more fine grained control over pushing & popping
10117 \begin_inset LatexCommand \index{push/pop}
10124 While there is nothing preventing you from writing C code inside a _naked
10125 function, there are many ways to shoot yourself in the foot doing this,
10126 and it is recommended that you stick to inline assembler.
10127 \layout Subsubsection
10129 Use of Labels within Inline Assembler
10132 SDCC allows the use of in-line assembler with a few restriction as regards
10134 In older versions of the compiler all labels defined within inline assembler
10143 where nnnn is a number less than 100 (which implies a limit of utmost 100
10144 inline assembler labels
10158 \begin_inset LatexCommand \index{\_asm}
10188 \begin_inset LatexCommand \index{\_endasm}
10195 Inline assembler code cannot reference any C-Labels, however it can reference
10197 \begin_inset LatexCommand \index{Labels}
10201 defined by the inline assembler, e.g.:
10226 ; some assembler code
10246 /* some more c code */
10248 clabel:\SpecialChar ~
10250 /* inline assembler cannot reference this label */
10262 $0003: ;label (can be reference by inline assembler only)
10274 /* some more c code */
10279 In other words inline assembly code can access labels defined in inline
10280 assembly within the scope of the function.
10281 The same goes the other way, ie.
10282 labels defines in inline assembly can not be accessed by C statements.
10285 Interfacing with Assembler Code
10286 \begin_inset LatexCommand \index{Assembler routines}
10291 \layout Subsubsection
10293 Global Registers used for Parameter Passing
10294 \begin_inset LatexCommand \index{Parameter passing}
10301 The compiler always uses the global registers
10304 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
10309 \begin_inset LatexCommand \index{B (register)}
10318 \begin_inset LatexCommand \index{ACC}
10324 to pass the first parameter to a routine.
10325 The second parameter onwards is either allocated on the stack (for reentrant
10336 -stack-auto is used) or in data / xdata memory (depending on the memory
10339 \layout Subsubsection
10341 Assembler Routine(non-reentrant
10342 \begin_inset LatexCommand \index{reentrant}
10347 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
10354 In the following example the function c_func calls an assembler routine
10355 asm_func, which takes two parameters.
10360 extern int asm_func(unsigned char, unsigned char);
10364 int c_func (unsigned char i, unsigned char j)
10372 return asm_func(i,j);
10386 return c_func(10,9);
10391 The corresponding assembler function is:
10396 .globl _asm_func_PARM_2
10460 add a,_asm_func_PARM_2
10485 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
10502 Note here that the return values are placed in 'dpl' - One byte return value,
10503 'dpl' LSB & 'dph' MSB for two byte values.
10504 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
10505 b' & 'acc' for four byte values.
10508 The parameter naming convention is _<function_name>_PARM_<n>, where n is
10509 the parameter number starting from 1, and counting from the left.
10510 The first parameter is passed in
10511 \begin_inset Quotes eld
10515 \begin_inset Quotes erd
10518 for One bye parameter,
10519 \begin_inset Quotes eld
10523 \begin_inset Quotes erd
10527 \begin_inset Quotes eld
10531 \begin_inset Quotes erd
10534 for three bytes and
10535 \begin_inset Quotes eld
10539 \begin_inset Quotes erd
10542 for four bytes, the variable name for the second parameter will be _<function_n
10547 Assemble the assembler routine with the following command:
10554 asx8051 -losg asmfunc.asm
10561 Then compile and link the assembler routine to the C source file with the
10569 sdcc cfunc.c asmfunc.rel
10570 \layout Subsubsection
10572 Assembler Routine(reentrant
10573 \begin_inset LatexCommand \index{reentrant}
10578 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
10585 In this case the second parameter onwards will be passed on the stack, the
10586 parameters are pushed from right to left i.e.
10587 after the call the left most parameter will be on the top of the stack.
10588 Here is an example:
10593 extern int asm_func(unsigned char, unsigned char);
10597 int c_func (unsigned char i, unsigned char j) reentrant
10605 return asm_func(i,j);
10619 return c_func(10,9);
10624 The corresponding assembler routine is:
10730 The compiling and linking procedure remains the same, however note the extra
10731 entry & exit linkage required for the assembler code, _bp is the stack
10732 frame pointer and is used to compute the offset into the stack for parameters
10733 and local variables.
10737 \begin_inset LatexCommand \index{int (16 bit)}
10742 \begin_inset LatexCommand \index{long (32 bit)}
10749 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
10750 multiplication and modulus operations are implemented by support routines.
10751 These support routines are all developed in ANSI-C to facilitate porting
10752 to other MCUs, although some model specific assembler optimizations are
10754 The following files contain the described routines, all of them can be
10755 found in <installdir>/share/sdcc/lib.
10761 \begin_inset Tabular
10762 <lyxtabular version="3" rows="11" columns="2">
10764 <column alignment="center" valignment="top" leftline="true" width="0">
10765 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
10766 <row topline="true" bottomline="true">
10767 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10777 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10788 <row topline="true">
10789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10797 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10802 16 bit multiplication
10806 <row topline="true">
10807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10815 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10820 signed 16 bit division (calls _divuint)
10824 <row topline="true">
10825 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10833 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10838 unsigned 16 bit division
10842 <row topline="true">
10843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10851 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10856 signed 16 bit modulus (calls _moduint)
10860 <row topline="true">
10861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10869 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10874 unsigned 16 bit modulus
10878 <row topline="true">
10879 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10887 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10892 32 bit multiplication
10896 <row topline="true">
10897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10905 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10910 signed 32 division (calls _divulong)
10914 <row topline="true">
10915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10923 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10928 unsigned 32 division
10932 <row topline="true">
10933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10941 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10946 signed 32 bit modulus (calls _modulong)
10950 <row topline="true" bottomline="true">
10951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
10959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
10964 unsigned 32 bit modulus
10977 Since they are compiled as
10982 \begin_inset LatexCommand \index{reentrant}
10987 \begin_inset LatexCommand \index{interrupt}
10991 service routines should not do any of the above operations.
10992 If this is unavoidable then the above routines will need to be compiled
11006 \begin_inset LatexCommand \index{-\/-stack-auto}
11012 option, after which the source program will have to be compiled with
11025 \begin_inset LatexCommand \index{-\/-int-long-rent}
11032 Notice that you don't have to call this routines directly.
11033 The compiler will use them automatically every time an integer operation
11037 Floating Point Support
11038 \begin_inset LatexCommand \index{Floating point support}
11045 SDCC supports IEEE (single precision 4 bytes) floating point numbers.The
11046 floating point support routines are derived from gcc's floatlib.c and consist
11047 of the following routines:
11055 \begin_inset Tabular
11056 <lyxtabular version="3" rows="17" columns="2">
11058 <column alignment="center" valignment="top" leftline="true" width="0">
11059 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
11060 <row topline="true" bottomline="true">
11061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11078 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11087 <row topline="true">
11088 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11105 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11119 add floating point numbers
11123 <row topline="true">
11124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11141 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11155 subtract floating point numbers
11159 <row topline="true">
11160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11191 divide floating point numbers
11195 <row topline="true">
11196 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11213 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11227 multiply floating point numbers
11231 <row topline="true">
11232 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11249 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11263 convert floating point to unsigned char
11267 <row topline="true">
11268 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11285 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11299 convert floating point to signed char
11303 <row topline="true">
11304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11321 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11335 convert floating point to unsigned int
11339 <row topline="true">
11340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11357 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11371 convert floating point to signed int
11375 <row topline="true">
11376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11416 convert floating point to unsigned long
11420 <row topline="true">
11421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11438 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11452 convert floating point to signed long
11456 <row topline="true">
11457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11474 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11488 convert unsigned char to floating point
11492 <row topline="true">
11493 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11510 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11524 convert char to floating point number
11528 <row topline="true">
11529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11546 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11560 convert unsigned int to floating point
11564 <row topline="true">
11565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11582 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11596 convert int to floating point numbers
11600 <row topline="true">
11601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11618 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11632 convert unsigned long to floating point number
11636 <row topline="true" bottomline="true">
11637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
11654 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
11668 convert long to floating point number
11681 Note if all these routines are used simultaneously the data space might
11683 For serious floating point usage it is strongly recommended that the large
11685 Also notice that you don't have to call this routines directly.
11686 The compiler will use them automatically every time a floating point operation
11690 MCS51 Memory Models
11691 \begin_inset LatexCommand \index{Memory model}
11696 \begin_inset LatexCommand \index{MCS51 memory}
11703 SDCC allows two memory models for MCS51 code,
11712 Modules compiled with different memory models should
11716 be combined together or the results would be unpredictable.
11717 The library routines supplied with the compiler are compiled as both small
11719 The compiled library modules are contained in separate directories as small
11720 and large so that you can link to either set.
11724 When the large model is used all variables declared without a storage class
11725 will be allocated into the external ram, this includes all parameters and
11726 local variables (for non-reentrant
11727 \begin_inset LatexCommand \index{reentrant}
11732 When the small model is used variables without storage class are allocated
11733 in the internal ram.
11736 Judicious usage of the processor specific storage classes
11737 \begin_inset LatexCommand \index{Storage class}
11741 and the 'reentrant' function type will yield much more efficient code,
11742 than using the large model.
11743 Several optimizations are disabled when the program is compiled using the
11744 large model, it is therefore strongly recommended that the small model
11745 be used unless absolutely required.
11748 DS390 Memory Models
11749 \begin_inset LatexCommand \index{Memory model}
11754 \begin_inset LatexCommand \index{DS390 memory model}
11761 The only model supported is Flat 24
11762 \begin_inset LatexCommand \index{Flat 24 (memory model)}
11767 This generates code for the 24 bit contiguous addressing mode of the Dallas
11769 In this mode, up to four meg of external RAM or code space can be directly
11771 See the data sheets at www.dalsemi.com for further information on this part.
11775 Note that the compiler does not generate any code to place the processor
11776 into 24 bitmode (although
11780 in the ds390 libraries will do that for you).
11786 \begin_inset LatexCommand \index{Tinibios (DS390)}
11790 , the boot loader or similar code must ensure that the processor is in 24
11791 bit contiguous addressing mode before calling the SDCC startup code.
11809 option, variables will by default be placed into the XDATA segment.
11814 Segments may be placed anywhere in the 4 meg address space using the usual
11826 Note that if any segments are located above 64K, the -r flag must be passed
11827 to the linker to generate the proper segment relocations, and the Intel
11828 HEX output format must be used.
11829 The -r flag can be passed to the linker by using the option
11833 on the SDCC command line.
11834 However, currently the linker can not handle code segments > 64k.
11838 \begin_inset LatexCommand \index{Pragmas}
11845 SDCC supports the following #pragma directives.
11849 \begin_inset LatexCommand \index{\#pragma SAVE}
11853 - this will save all current options to the SAVE/RESTORE stack.
11858 \begin_inset LatexCommand \index{\#pragma RESTORE}
11862 - will restore saved options from the last save.
11863 SAVEs & RESTOREs can be nested.
11864 SDCC uses a SAVE/RESTORE stack: SAVE pushes current options to the stack,
11865 RESTORE pulls current options from the stack.
11870 \begin_inset LatexCommand \index{\#pragma NOGCSE}
11874 - will stop global common subexpression elimination.
11878 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
11882 - will stop loop induction optimizations.
11886 \begin_inset LatexCommand \index{\#pragma NOJTBOUND}
11890 - will not generate code for boundary value checking, when switch statements
11891 are turned into jump-tables (dangerous).
11892 For more details see section
11893 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
11901 \begin_inset LatexCommand \index{\#pragma NOOVERLAY}
11905 - the compiler will not overlay the parameters and local variables of a
11910 \begin_inset LatexCommand \index{\#pragma LESS\_PEDANTIC}
11914 - the compiler will not warn you anymore for obvious mistakes, you'r on
11919 \begin_inset LatexCommand \index{\#pragma NOLOOPREVERSE}
11923 - Will not do loop reversal optimization
11927 \begin_inset LatexCommand \index{\#pragma EXCLUDE}
11931 NONE | {acc[,b[,dpl[,dph]]] - The exclude pragma disables generation of
11933 \begin_inset LatexCommand \index{push/pop}
11937 instruction in ISR function (using interrupt
11938 \begin_inset LatexCommand \index{interrupt}
11943 The directive should be placed immediately before the ISR function definition
11944 and it affects ALL ISR functions following it.
11945 To enable the normal register saving for ISR functions use #pragma\SpecialChar ~
11946 EXCLUDE\SpecialChar ~
11948 \begin_inset LatexCommand \index{\#pragma EXCLUDE}
11956 \begin_inset LatexCommand \index{\#pragma NOIV}
11960 - Do not generate interrupt vector table entries for all ISR functions
11961 defined after the pragma.
11962 This is useful in cases where the interrupt vector table must be defined
11963 manually, or when there is a secondary, manually defined interrupt vector
11965 for the autovector feature of the Cypress EZ-USB FX2).
11966 More elegantly this can be achieved by obmitting the optional interrupt
11967 number after the interrupt keyword, see section
11968 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
11977 \begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
11982 \begin_inset LatexCommand \index{function prologue}
11986 function1[,function2[,function3...]] - The compiler by default uses a caller
11987 saves convention for register saving across function calls, however this
11988 can cause unnecessary register pushing & popping when calling small functions
11989 from larger functions.
11990 This option can be used to switch off the register saving convention for
11991 the function names specified.
11992 The compiler will not save registers when calling these functions, extra
11993 code need to be manually inserted at the entry & exit for these functions
11994 to save & restore the registers used by these functions, this can SUBSTANTIALLY
11995 reduce code & improve run time performance of the generated code.
11996 In the future the compiler (with inter procedural analysis) may be able
11997 to determine the appropriate scheme to use for each function call.
12008 -callee-saves command line option is used, the function names specified
12009 in #pragma\SpecialChar ~
12011 \begin_inset LatexCommand \index{\#pragma CALLEE-SAVES}
12015 is appended to the list of functions specified in the command line.
12018 The pragma's are intended to be used to turn-on or off certain optimizations
12019 which might cause the compiler to generate extra stack / data space to
12020 store compiler generated temporary variables.
12021 This usually happens in large functions.
12022 Pragma directives should be used as shown in the following example, they
12023 are used to control options & optimizations for a given function; pragmas
12024 should be placed before and/or after a function, placing pragma's inside
12025 a function body could have unpredictable results.
12031 \begin_inset LatexCommand \index{\#pragma SAVE}
12042 /* save the current settings */
12045 \begin_inset LatexCommand \index{\#pragma NOGCSE}
12054 /* turnoff global subexpression elimination */
12056 #pragma NOINDUCTION
12057 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
12061 /* turn off induction optimizations */
12084 \begin_inset LatexCommand \index{\#pragma RESTORE}
12088 /* turn the optimizations back on */
12091 The compiler will generate a warning message when extra space is allocated.
12092 It is strongly recommended that the SAVE and RESTORE pragma's be used when
12093 changing options for a function.
12096 Defines Created by the Compiler
12097 \begin_inset LatexCommand \index{Defines created by the compiler}
12104 The compiler creates the following #defines
12105 \begin_inset LatexCommand \index{\#defines}
12115 \begin_inset Tabular
12116 <lyxtabular version="3" rows="10" columns="2">
12118 <column alignment="center" valignment="top" leftline="true" width="0">
12119 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
12120 <row topline="true" bottomline="true">
12121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12131 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12142 <row topline="true">
12143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12149 \begin_inset LatexCommand \index{SDCC}
12156 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12161 this Symbol is always defined
12165 <row topline="true">
12166 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12172 \begin_inset LatexCommand \index{SDCC\_mcs51}
12177 \begin_inset LatexCommand \index{SDCC\_ds390}
12182 \begin_inset LatexCommand \index{SDCC\_z80}
12189 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12194 depending on the model used (e.g.: -mds390
12198 <row topline="true">
12199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12205 \begin_inset LatexCommand \index{\_\_mcs51}
12210 \begin_inset LatexCommand \index{\_\_ds390}
12215 \begin_inset LatexCommand \index{\_\_z80}
12222 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12227 depending on the model used (e.g.
12232 <row topline="true">
12233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12239 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
12246 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12269 <row topline="true">
12270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12276 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
12283 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12306 <row topline="true">
12307 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12313 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
12320 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12343 <row topline="true">
12344 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12350 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
12357 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12380 <row topline="true">
12381 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12387 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
12394 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12407 <row topline="true" bottomline="true">
12408 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
12414 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
12421 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
12443 Debugging with SDCDB
12444 \begin_inset LatexCommand \index{sdcdb}
12451 SDCC is distributed with a source level debugger
12452 \begin_inset LatexCommand \index{Debugger}
12457 The debugger uses a command line interface, the command repertoire of the
12458 debugger has been kept as close to gdb
12459 \begin_inset LatexCommand \index{gdb}
12463 (the GNU debugger) as possible.
12464 The configuration and build process is part of the standard compiler installati
12465 on, which also builds and installs the debugger in the target directory
12466 specified during configuration.
12467 The debugger allows you debug BOTH at the C source and at the ASM source
12469 Sdcdb is available on Unix platforms only.
12472 Compiling for Debugging
12475 The \SpecialChar \-
12477 debug option must be specified for all files for which debug information
12478 is to be generated.
12479 The complier generates a .adb file for each of these files.
12480 The linker creates the .cdb file from the .adb files and the address information.
12481 This .cdb is used by the debugger.
12484 How the Debugger Works
12497 -debug option is specified the compiler generates extra symbol information
12498 some of which are put into the assembler source and some are put into the
12500 Then the linker creates the .cdb file from the individual .adb files with
12501 the address information for the symbols.
12502 The debugger reads the symbolic information generated by the compiler &
12503 the address information generated by the linker.
12504 It uses the SIMULATOR (Daniel's S51) to execute the program, the program
12505 execution is controlled by the debugger.
12506 When a command is issued for the debugger, it translates it into appropriate
12507 commands for the simulator.
12510 Starting the Debugger
12513 The debugger can be started using the following command line.
12514 (Assume the file you are debugging has the file name foo).
12528 The debugger will look for the following files.
12531 foo.c - the source file.
12534 foo.cdb - the debugger symbol information file.
12537 foo.ihx - the Intel hex format
12538 \begin_inset LatexCommand \index{Intel hex format}
12545 Command Line Options.
12558 -directory=<source file directory> this option can used to specify the directory
12560 The debugger will look into the directory list specified for source, cdb
12562 The items in the directory list must be separated by ':', e.g.
12563 if the source files can be in the directories /home/src1 and /home/src2,
12574 -directory option should be -
12584 -directory=/home/src1:/home/src2.
12585 Note there can be no spaces in the option.
12589 -cd <directory> - change to the <directory>.
12592 -fullname - used by GUI front ends.
12595 -cpu <cpu-type> - this argument is passed to the simulator please see the
12596 simulator docs for details.
12599 -X <Clock frequency > this options is passed to the simulator please see
12600 the simulator docs for details.
12603 -s <serial port file> passed to simulator see the simulator docs for details.
12606 -S <serial in,out> passed to simulator see the simulator docs for details.
12612 As mentioned earlier the command interface for the debugger has been deliberatel
12613 y kept as close the GNU debugger gdb, as possible.
12614 This will help the integration with existing graphical user interfaces
12615 (like ddd, xxgdb or xemacs) existing for the GNU debugger.
12616 If you use a graphical user interface for the debugger you can skip the
12618 \layout Subsubsection*
12620 break [line | file:line | function | file:function]
12623 Set breakpoint at specified line or function:
12632 sdcdb>break foo.c:100
12634 sdcdb>break funcfoo
12636 sdcdb>break foo.c:funcfoo
12637 \layout Subsubsection*
12639 clear [line | file:line | function | file:function ]
12642 Clear breakpoint at specified line or function:
12651 sdcdb>clear foo.c:100
12653 sdcdb>clear funcfoo
12655 sdcdb>clear foo.c:funcfoo
12656 \layout Subsubsection*
12661 Continue program being debugged, after breakpoint.
12662 \layout Subsubsection*
12667 Execute till the end of the current function.
12668 \layout Subsubsection*
12673 Delete breakpoint number 'n'.
12674 If used without any option clear ALL user defined break points.
12675 \layout Subsubsection*
12677 info [break | stack | frame | registers ]
12680 info break - list all breakpoints
12683 info stack - show the function call stack.
12686 info frame - show information about the current execution frame.
12689 info registers - show content of all registers.
12690 \layout Subsubsection*
12695 Step program until it reaches a different source line.
12696 \layout Subsubsection*
12701 Step program, proceeding through subroutine calls.
12702 \layout Subsubsection*
12707 Start debugged program.
12708 \layout Subsubsection*
12713 Print type information of the variable.
12714 \layout Subsubsection*
12719 print value of variable.
12720 \layout Subsubsection*
12725 load the given file name.
12726 Note this is an alternate method of loading file for debugging.
12727 \layout Subsubsection*
12732 print information about current frame.
12733 \layout Subsubsection*
12738 Toggle between C source & assembly source.
12739 \layout Subsubsection*
12741 ! simulator command
12744 Send the string following '!' to the simulator, the simulator response is
12746 Note the debugger does not interpret the command being sent to the simulator,
12747 so if a command like 'go' is sent the debugger can loose its execution
12748 context and may display incorrect values.
12749 \layout Subsubsection*
12756 My name is Bobby Brown"
12759 Interfacing with XEmacs
12760 \begin_inset LatexCommand \index{XEmacs}
12765 \begin_inset LatexCommand \index{Emacs}
12772 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
12773 sdcdb.el and sdcdbsrc.el.
12774 These two files can be found in the $(prefix)/bin directory after the installat
12776 These files need to be loaded into XEmacs for the interface to work.
12777 This can be done at XEmacs startup time by inserting the following into
12778 your '.xemacs' file (which can be found in your HOME directory):
12784 (load-file sdcdbsrc.el)
12790 .xemacs is a lisp file so the () around the command is REQUIRED.
12791 The files can also be loaded dynamically while XEmacs is running, set the
12792 environment variable 'EMACSLOADPATH' to the installation bin directory
12793 (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
12794 To start the interface enter the following command:
12808 You will prompted to enter the file name to be debugged.
12813 The command line options that are passed to the simulator directly are bound
12814 to default values in the file sdcdbsrc.el.
12815 The variables are listed below, these values maybe changed as required.
12818 sdcdbsrc-cpu-type '51
12821 sdcdbsrc-frequency '11059200
12824 sdcdbsrc-serial nil
12827 The following is a list of key mapping for the debugger interface.
12835 ;; Current Listing ::
12837 ;;key\SpecialChar ~
12852 binding\SpecialChar ~
12876 ;;---\SpecialChar ~
12891 ------\SpecialChar ~
12931 sdcdb-next-from-src\SpecialChar ~
12957 sdcdb-back-from-src\SpecialChar ~
12983 sdcdb-cont-from-src\SpecialChar ~
12993 SDCDB continue command
13009 sdcdb-step-from-src\SpecialChar ~
13035 sdcdb-whatis-c-sexp\SpecialChar ~
13045 SDCDB ptypecommand for data at
13109 sdcdbsrc-delete\SpecialChar ~
13123 SDCDB Delete all breakpoints if no arg
13171 given or delete arg (C-u arg x)
13187 sdcdbsrc-frame\SpecialChar ~
13202 SDCDB Display current frame if no arg,
13251 given or display frame arg
13316 sdcdbsrc-goto-sdcdb\SpecialChar ~
13326 Goto the SDCDB output buffer
13342 sdcdb-print-c-sexp\SpecialChar ~
13353 SDCDB print command for data at
13417 sdcdbsrc-goto-sdcdb\SpecialChar ~
13427 Goto the SDCDB output buffer
13443 sdcdbsrc-mode\SpecialChar ~
13459 Toggles Sdcdbsrc mode (turns it off)
13463 ;; C-c C-f\SpecialChar ~
13471 sdcdb-finish-from-src\SpecialChar ~
13479 SDCDB finish command
13483 ;; C-x SPC\SpecialChar ~
13491 sdcdb-break\SpecialChar ~
13509 Set break for line with point
13511 ;; ESC t\SpecialChar ~
13521 sdcdbsrc-mode\SpecialChar ~
13537 Toggle Sdcdbsrc mode
13539 ;; ESC m\SpecialChar ~
13549 sdcdbsrc-srcmode\SpecialChar ~
13571 Here are a few guidelines that will help the compiler generate more efficient
13572 code, some of the tips are specific to this compiler others are generally
13573 good programming practice.
13576 Use the smallest data type to represent your data-value.
13577 If it is known in advance that the value is going to be less than 256 then
13578 use an 'unsigned char' instead of a 'short' or 'int'.
13581 Use unsigned when it is known in advance that the value is not going to
13583 This helps especially if you are doing division or multiplication.
13586 NEVER jump into a LOOP.
13589 Declare the variables to be local whenever possible, especially loop control
13590 variables (induction).
13593 Since the compiler does not always do implicit integral promotion, the programme
13594 r should do an explicit cast when integral promotion is required.
13597 Reducing the size of division, multiplication & modulus operations can reduce
13598 code size substantially.
13599 Take the following code for example.
13605 foobar(unsigned int p1, unsigned char ch)
13613 unsigned char ch1 = p1 % ch ;
13624 For the modulus operation the variable ch will be promoted to unsigned int
13625 first then the modulus operation will be performed (this will lead to a
13626 call to support routine _moduint()), and the result will be casted to a
13628 If the code is changed to
13633 foobar(unsigned int p1, unsigned char ch)
13641 unsigned char ch1 = (unsigned char)p1 % ch ;
13652 It would substantially reduce the code generated (future versions of the
13653 compiler will be smart enough to detect such optimization opportunities).
13657 Have a look at the assembly listing to get a
13658 \begin_inset Quotes sld
13662 \begin_inset Quotes srd
13665 for the code generation.
13668 Notes on MCS51 memory
13669 \begin_inset LatexCommand \index{MCS51 memory}
13676 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
13677 RAM memory which is structured as follows
13681 - Bytes 00-1F - 32 bytes to hold up to 4 banks of the registers R0 to R7,
13684 - Bytes 20-2F - 16 bytes to hold 128 bit
13685 \begin_inset LatexCommand \index{bit}
13691 - Bytes 30-7F - 80 bytes for general purpose use.
13696 Additionally some members of the MCS51 family may have up to 128 bytes of
13697 additional, indirectly addressable, internal RAM memory (
13702 \begin_inset LatexCommand \index{idata}
13707 Furthermore, some chips may have some built in external memory (
13712 \begin_inset LatexCommand \index{xdata}
13716 ) which should not be confused with the internal, directly addressable RAM
13722 \begin_inset LatexCommand \index{data}
13727 Sometimes this built in
13731 memory has to be activated before using it (you can probably find this
13732 information on the datasheet of the microcontroller your are using).
13735 Normally SDCC will only use the first bank
13736 \begin_inset LatexCommand \index{bank}
13740 of registers (register bank 0), but it is possible to specify that other
13741 banks of registers should be used in interrupt
13742 \begin_inset LatexCommand \index{interrupt}
13747 By default, the compiler will place the stack after the last byte of allocated
13748 memory for variables.
13749 For example, if the first 2 banks of registers are used, and only four
13754 variables, it will position the base of the internal stack at address 20
13756 This implies that as the stack
13757 \begin_inset LatexCommand \index{stack}
13761 grows, it will use up the remaining register banks, and the 16 bytes used
13762 by the 128 bit variables, and 80 bytes for general purpose use.
13763 If any bit variables are used, the data variables will be placed after
13764 the byte holding the last bit variable.
13765 For example, if register banks 0 and 1 are used, and there are 9 bit variables
13770 variables will be placed starting at address 0x22.
13782 \begin_inset LatexCommand \index{-\/-data-loc}
13786 to specify the start address of the
13800 -iram-size to specify the size of the total internal RAM (
13812 By default the 8051 linker will place the stack after the last byte of data
13825 \begin_inset LatexCommand \index{-\/-stack-loc}
13829 allows you to specify the start of the stack, i.e.
13830 you could start it after any data in the general purpose area.
13831 If your microcontroller has additional indirectly addressable internal
13836 ) you can place the stack on it.
13837 You may also need to use -
13848 \begin_inset LatexCommand \index{-\/-data-loc}
13852 to set the start address of the external RAM (
13867 \begin_inset LatexCommand \index{-\/-data-loc}
13871 to specify its size.
13872 Same goes for the code memory, using -
13883 \begin_inset LatexCommand \index{-\/-data-loc}
13898 \begin_inset LatexCommand \index{-\/-data-loc}
13903 If in doubt, don't specify any options and see if the resulting memory
13904 layout is appropriate, then you can adjust it.
13907 The 8051 linker generates two files with memory allocation information.
13908 The first, with extension .map shows all the variables and segments.
13909 The second with extension .mem shows the final memory layout.
13910 The linker will complaint either if memory segments overlap, there is not
13911 enough memory, or there is not enough space for stack.
13912 If you get any linking warnings and/or errors related to stack or segments
13913 allocation, take a look at either the .map or .mem files to find out what
13915 The .mem file may even suggest a solution to the problem.
13919 \begin_inset LatexCommand \index{Tools}
13923 included in the distribution
13927 \begin_inset Tabular
13928 <lyxtabular version="3" rows="12" columns="3">
13930 <column alignment="center" valignment="top" leftline="true" width="0pt">
13931 <column alignment="center" valignment="top" leftline="true" width="0pt">
13932 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
13933 <row topline="true" bottomline="true">
13934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13950 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13959 <row topline="true">
13960 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13973 Simulator for various architectures
13976 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
13985 <row topline="true">
13986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
13999 header file conversion
14002 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14007 sdcc/support/scripts
14011 <row topline="true">
14012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14025 header file conversion
14028 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14033 sdcc/support/scripts
14037 <row topline="true">
14038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14054 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14072 <row topline="true">
14073 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14107 <row topline="true">
14108 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14116 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14124 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14142 <row topline="true">
14143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14159 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14177 <row topline="true">
14178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14186 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14194 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14212 <row topline="true">
14213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14229 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14247 <row topline="true">
14248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14264 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14282 <row topline="true" bottomline="true">
14283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14299 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14326 Related open source tools
14327 \begin_inset LatexCommand \index{Related tools}
14335 \begin_inset Tabular
14336 <lyxtabular version="3" rows="8" columns="3">
14338 <column alignment="center" valignment="top" leftline="true" width="0pt">
14339 <column alignment="block" valignment="top" leftline="true" width="30line%">
14340 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
14341 <row topline="true" bottomline="true">
14342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14350 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14367 <row topline="true">
14368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14374 \begin_inset LatexCommand \index{gpsim}
14381 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14395 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
14403 <row topline="true">
14404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14412 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14420 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14426 \begin_inset LatexCommand \url{http://digilander.libero.it/fbradasc/FLP5.html}
14434 <row topline="true">
14435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14441 \begin_inset LatexCommand \index{srecord}
14448 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14453 Object file conversion, checksumming, ...
14456 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14462 \begin_inset LatexCommand \url{http://srecord.sourceforge.net/}
14470 <row topline="true">
14471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14477 \begin_inset LatexCommand \index{objdump}
14484 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14489 Object file conversion, ...
14492 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14497 Part of binutils (should be there anyway)
14501 <row topline="true">
14502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14508 \begin_inset LatexCommand \index{doxygen}
14515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14520 Source code documentation system
14523 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14529 \begin_inset LatexCommand \url{http://www.doxygen.org}
14537 <row topline="true">
14538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14544 \begin_inset LatexCommand \index{splint}
14551 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14556 Statically checks c sources
14559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14565 \begin_inset LatexCommand \url{http://www.splint.org}
14573 <row topline="true" bottomline="true">
14574 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14580 \begin_inset LatexCommand \index{ddd}
14587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14592 Debugger, serves nicely as GUI to sdcdb
14593 \begin_inset LatexCommand \index{sdcdb}
14600 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14606 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
14623 Related documentation / recommended reading
14627 \begin_inset Tabular
14628 <lyxtabular version="3" rows="5" columns="3">
14630 <column alignment="center" valignment="top" leftline="true" width="0pt">
14631 <column alignment="block" valignment="top" leftline="true" width="30line%">
14632 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
14633 <row topline="true" bottomline="true">
14634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14642 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14650 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14659 <row topline="true">
14660 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14675 Advanced Compiler Design and Implementation
14678 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14687 <row topline="true">
14688 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14711 \begin_inset LatexCommand \index{C Reference card}
14718 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14724 \begin_inset LatexCommand \url{http://www.refcards.com/about/c.html}
14732 <row topline="true">
14733 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14738 test_suite_spec.pdf
14741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14746 sdcc regression test
14747 \begin_inset LatexCommand \index{Regression test}
14754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14763 <row topline="true" bottomline="true">
14764 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14795 sdcc internal documentation
14798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14817 \begin_inset LatexCommand \index{Support}
14824 SDCC has grown to be a large project.
14825 The compiler alone (without the preprocessor, assembler and linker) is
14826 well over 100,000 lines of code (blank stripped).
14827 The open source nature of this project is a key to its continued growth
14829 You gain the benefit and support of many active software developers and
14831 Is SDCC perfect? No, that's why we need your help.
14832 The developers take pride in fixing reported bugs.
14833 You can help by reporting the bugs and helping other SDCC users.
14834 There are lots of ways to contribute, and we encourage you to take part
14835 in making SDCC a great software package.
14839 The SDCC project is hosted on the SDCC sourceforge site at
14840 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
14845 You'll find the complete set of mailing lists
14846 \begin_inset LatexCommand \index{Mailing list}
14850 , forums, bug reporting system, patch submission
14851 \begin_inset LatexCommand \index{Patch submission}
14856 \begin_inset LatexCommand \index{download}
14860 area and cvs code repository
14861 \begin_inset LatexCommand \index{cvs code repository}
14869 \begin_inset LatexCommand \index{Bugs}
14874 \begin_inset LatexCommand \index{Reporting bugs}
14881 The recommended way of reporting bugs is using the infrastructure of the
14883 You can follow the status of bug reports there and have an overview about
14887 Bug reports are automatically forwarded to the developer mailing list and
14888 will be fixed ASAP.
14889 When reporting a bug, it is very useful to include a small test program
14890 (the smaller the better) which reproduces the problem.
14891 If you can isolate the problem by looking at the generated assembly code,
14892 this can be very helpful.
14893 Compiling your program with the -
14904 \begin_inset LatexCommand \index{-\/-dumpall}
14908 option can sometimes be useful in locating optimization problems.
14909 When reporting a bug please maker sure you:
14912 Attach the code you are compiling with SDCC.
14916 Specify the exact command you use to run SDCC, or attach your Makefile.
14920 Specify the SDCC version (type "sdcc -v"), your platform, and operating
14925 Provide an exact copy of any error message or incorrect output.
14929 Put something meaningful in the subject of your message.
14932 Please attempt to include these 5 important parts, as applicable, in all
14933 requests for support or when reporting any problems or bugs with SDCC.
14934 Though this will make your message lengthy, it will greatly improve your
14935 chance that SDCC users and developers will be able to help you.
14936 Some SDCC developers are frustrated by bug reports without code provided
14937 that they can use to reproduce and ultimately fix the problem, so please
14938 be sure to provide sample code if you are reporting a bug!
14941 Please have a short check that you are using a recent version of SDCC and
14942 the bug is not yet known.
14943 This is the link for reporting bugs:
14944 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
14951 Requesting Features
14952 \begin_inset LatexCommand \label{sub:Requesting-Features}
14957 \begin_inset LatexCommand \index{Feature request}
14962 \begin_inset LatexCommand \index{Requesting features}
14969 Like bug reports feature requests are forwarded to the developer mailing
14971 This is the link for requesting features:
14972 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
14982 These links should take you directly to the
14983 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
14993 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
14994 automated messages (mid 2003)
14998 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
15002 , lists and forums are archived so if you are lucky someone already had
15007 \begin_inset LatexCommand \index{Changelog}
15014 You can follow the status of the cvs version
15015 \begin_inset LatexCommand \index{version}
15019 of SDCC by watching the file
15020 \begin_inset LatexCommand \htmlurl[ChangeLog]{http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sdcc/sdcc/ChangeLog?rev=HEAD&content-type=text/plain}
15024 in the cvs-repository.
15028 \begin_inset LatexCommand \index{Release policy}
15035 Historically there often were long delays between official releases and
15036 the sourceforge download area tends to get not updated at all.
15037 Current excuses might refer to problems with live range analysis, but if
15038 this is fixed, the next problem rising is that another excuse will have
15040 Kidding aside, we have to get better there! On the other hand there are
15041 daily snapshots available at
15042 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
15046 , and you can always built the very last version (hopefully with many bugs
15047 fixed, and features added) from the source code available at
15048 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
15056 \begin_inset LatexCommand \index{Examples}
15063 You'll find some small examples in the directory
15065 sdcc/device/examples/.
15068 More examples and libraries are available at
15070 The SDCC Open Knowledge Resource
15071 \begin_inset LatexCommand \url{http://www.qsl.net/dl9sec/SDCC_OKR.html}
15078 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
15085 I did insert a reference to Paul's web site here although it seems rather
15086 dedicated to a specific 8032 board (I think it's okay because it f.e.
15087 shows LCD/Harddisc interface and has a free 8051 monitor.
15088 Independent 8032 board vendors face hard competition of heavily subsidized
15089 development boards anyway).
15092 Maybe we should include some links to real world applications.
15093 Preferably pointer to pointers (one for each architecture) so this stays
15098 \begin_inset LatexCommand \index{Quality control}
15105 The compiler is passed through nightly compile and build checks.
15111 \begin_inset LatexCommand \index{Regression test}
15115 check that SDCC itself compiles flawlessly on several platforms and checks
15116 the quality of the code generated by SDCC by running the code through simulator
15118 There is a separate document
15121 \begin_inset LatexCommand \index{Test suite}
15130 You'll find the test code in the directory
15132 sdcc/support/regression
15135 You can run these tests manually by running
15139 in this directory (or f.e.
15144 if you don't want to run the complete tests).
15145 The test code might also be interesting if you want to look for examples
15146 \begin_inset LatexCommand \index{Examples}
15150 checking corner cases of SDCC or if you plan to submit patches
15151 \begin_inset LatexCommand \index{Patch submission}
15158 The pic port uses a different set of regression tests, you'll find them
15161 sdcc/src/regression
15166 SDCC Technical Data
15170 \begin_inset LatexCommand \index{Optimizations}
15177 SDCC performs a host of standard optimizations in addition to some MCU specific
15180 \layout Subsubsection
15182 Sub-expression Elimination
15183 \begin_inset LatexCommand \index{Subexpression elimination}
15190 The compiler does local and global common subexpression elimination, e.g.:
15201 will be translated to
15213 Some subexpressions are not as obvious as the above example, e.g.:
15223 In this case the address arithmetic a->b[i] will be computed only once;
15224 the equivalent code in C would be.
15236 The compiler will try to keep these temporary variables in registers.
15237 \layout Subsubsection
15239 Dead-Code Elimination
15240 \begin_inset LatexCommand \index{Dead-code elimination}
15261 i = 1; \SpecialChar ~
15270 global = 1;\SpecialChar ~
15283 global = 3;\SpecialChar ~
15309 \layout Subsubsection
15312 \begin_inset LatexCommand \index{Copy propagation}
15368 Note: the dead stores created by this copy propagation will be eliminated
15369 by dead-code elimination.
15370 \layout Subsubsection
15373 \begin_inset LatexCommand \index{Loop optimization}
15380 Two types of loop optimizations are done by SDCC loop invariant lifting
15381 and strength reduction of loop induction variables.
15382 In addition to the strength reduction the optimizer marks the induction
15383 variables and the register allocator tries to keep the induction variables
15384 in registers for the duration of the loop.
15385 Because of this preference of the register allocator
15386 \begin_inset LatexCommand \index{Register allocation}
15390 , loop induction optimization causes an increase in register pressure, which
15391 may cause unwanted spilling of other temporary variables into the stack
15392 \begin_inset LatexCommand \index{stack}
15397 The compiler will generate a warning message when it is forced to allocate
15398 extra space either on the stack or data space.
15399 If this extra space allocation is undesirable then induction optimization
15400 can be eliminated either for the entire source file (with -
15410 -noinduction option) or for a given function only using #pragma\SpecialChar ~
15412 \begin_inset LatexCommand \index{\#pragma NOINDUCTION}
15425 for (i = 0 ; i < 100 ; i ++)
15441 for (i = 0; i < 100; i++)
15450 As mentioned previously some loop invariants are not as apparent, all static
15451 address computations are also moved out of the loop.
15456 \begin_inset LatexCommand \index{Strength reduction}
15460 , this optimization substitutes an expression by a cheaper expression:
15465 for (i=0;i < 100; i++)
15483 for (i=0;i< 100;i++) {
15489 ar[itemp1] = itemp2;
15506 The more expensive multiplication
15507 \begin_inset LatexCommand \index{Multiplication}
15511 is changed to a less expensive addition.
15512 \layout Subsubsection
15515 \begin_inset LatexCommand \index{Loop reversing}
15522 This optimization is done to reduce the overhead of checking loop boundaries
15523 for every iteration.
15524 Some simple loops can be reversed and implemented using a
15525 \begin_inset Quotes eld
15528 decrement and jump if not zero
15529 \begin_inset Quotes erd
15533 SDCC checks for the following criterion to determine if a loop is reversible
15534 (note: more sophisticated compilers use data-dependency analysis to make
15535 this determination, SDCC uses a more simple minded analysis).
15538 The 'for' loop is of the form
15544 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
15554 The <for body> does not contain
15555 \begin_inset Quotes eld
15559 \begin_inset Quotes erd
15563 \begin_inset Quotes erd
15569 All goto's are contained within the loop.
15572 No function calls within the loop.
15575 The loop control variable <sym> is not assigned any value within the loop
15578 The loop control variable does NOT participate in any arithmetic operation
15582 There are NO switch statements in the loop.
15583 \layout Subsubsection
15585 Algebraic Simplifications
15588 SDCC does numerous algebraic simplifications, the following is a small sub-set
15589 of these optimizations.
15594 i = j + 0 ; /* changed to */ i = j;
15596 i /= 2;\SpecialChar ~
15600 /* changed to */ i >>= 1;
15602 i = j - j ; /* changed to */ i = 0;
15604 i = j / 1 ; /* changed to */ i = j;
15607 Note the subexpressions
15608 \begin_inset LatexCommand \index{Subexpression}
15612 given above are generally introduced by macro expansions or as a result
15613 of copy/constant propagation.
15614 \layout Subsubsection
15616 'switch' Statements
15617 \begin_inset LatexCommand \label{sub:'switch'-Statements}
15622 \begin_inset LatexCommand \index{switch statement}
15629 SDCC changes switch statements to jump tables
15630 \begin_inset LatexCommand \index{jump tables}
15634 when the following conditions are true.
15638 The case labels are in numerical sequence, the labels need not be in order,
15639 and the starting number need not be one or zero.
15645 switch(i) {\SpecialChar ~
15676 case 4: ...\SpecialChar ~
15708 case 5: ...\SpecialChar ~
15740 case 3: ...\SpecialChar ~
15772 case 6: ...\SpecialChar ~
15840 Both the above switch statements will be implemented using a jump-table.
15841 The example to the right side is slightly more efficient as the check for
15842 the lower boundary of the jump-table is not needed.
15846 The number of case labels is at least three, since it takes two conditional
15847 statements to handle the boundary conditions.
15850 The number of case labels is less than 84, since each label takes 3 bytes
15851 and a jump-table can be utmost 256 bytes long.
15854 Switch statements which have gaps in the numeric sequence or those that
15855 have more that 84 case labels can be split into more than one switch statement
15856 for efficient code generation, e.g.:
15906 If the above switch statement is broken down into two switch statements
15945 case 9:\SpecialChar ~
15952 case 10:\SpecialChar ~
15958 case 11:\SpecialChar ~
15964 case 12:\SpecialChar ~
15971 then both the switch statements will be implemented using jump-tables whereas
15972 the unmodified switch statement will not be.
15973 You might also consider dummy cases 0 and 5 to 8 in this example.
15976 The pragma NOJTBOUND
15977 \begin_inset LatexCommand \index{\#pragma NOJTBOUND}
15981 can be used to turn off checking the
15994 It has no effect if a default label is supplied.
15995 Use of this pragma is dangerous: if the switch argument is not matched
15996 by a case statement the processor will happily jump into Nirvana.
15997 \layout Subsubsection
15999 Bit-shifting Operations
16000 \begin_inset LatexCommand \index{Bit shifting}
16007 Bit shifting is one of the most frequently used operation in embedded programmin
16009 SDCC tries to implement bit-shift operations in the most efficient way
16025 generates the following code:
16042 In general SDCC will never setup a loop if the shift count is known.
16082 \layout Subsubsection
16085 \begin_inset LatexCommand \index{Bit rotation}
16092 A special case of the bit-shift operation is bit rotation
16093 \begin_inset LatexCommand \index{rotating bits}
16097 , SDCC recognizes the following expression to be a left bit-rotation:
16107 char i;\SpecialChar ~
16118 /* unsigned is needed for rotation */
16123 i = ((i << 1) | (i >> 7));
16132 will generate the following code:
16151 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
16152 ns of this case will also be recognized as bit-rotation, i.e.:
16157 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
16158 \layout Subsubsection
16160 Nibble and Byte Swapping
16163 Other special cases of the bit-shift operations are nibble or byte swapping
16164 \begin_inset LatexCommand \index{swapping nibbles/bytes}
16168 , SDCC recognizes the following expressions:
16191 i = ((i << 4) | (i >> 4));
16197 j = ((j << 8) | (j >> 8));
16200 and generates a swap instruction for the nibble swapping
16201 \begin_inset LatexCommand \index{Nibble swapping}
16205 or move instructions for the byte swapping
16206 \begin_inset LatexCommand \index{Byte swapping}
16212 \begin_inset Quotes sld
16216 \begin_inset Quotes srd
16219 example can be used to convert from little to big-endian or vice versa.
16220 If you want to change the endianness of a
16224 integer you have to cast to
16231 Note that SDCC stores numbers in little-endian
16237 Usually 8-bit processors don't care much about endianness.
16238 This is not the case for the standard 8051 which only has an instruction
16244 \begin_inset LatexCommand \index{DPTR}
16252 so little-endian is the more efficient byte order.
16256 \begin_inset LatexCommand \index{little-endian}
16261 \begin_inset LatexCommand \index{Endianness}
16266 lowest order first).
16267 \layout Subsubsection
16270 \begin_inset LatexCommand \index{Highest Order Bit}
16277 It is frequently required to obtain the highest order bit of an integral
16278 type (long, int, short or char types).
16279 SDCC recognizes the following expression to yield the highest order bit
16280 and generates optimized code for it, e.g.:
16302 hob = (gint >> 15) & 1;
16312 will generate the following code:
16345 000A E5*01\SpecialChar ~
16372 000C 23\SpecialChar ~
16403 000D 54 01\SpecialChar ~
16430 000F F5*02\SpecialChar ~
16458 Variations of this case however will
16463 It is a standard C expression, so I heartily recommend this be the only
16464 way to get the highest order bit, (it is portable).
16465 Of course it will be recognized even if it is embedded in other expressions,
16471 xyz = gint + ((gint >> 15) & 1);
16474 will still be recognized.
16475 \layout Subsubsection
16478 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
16483 \begin_inset LatexCommand \index{Peephole optimizer}
16490 The compiler uses a rule based, pattern matching and re-writing mechanism
16491 for peep-hole optimization.
16496 a peep-hole optimizer by Christopher W.
16497 Fraser (cwfraser@microsoft.com).
16498 A default set of rules are compiled into the compiler, additional rules
16499 may be added with the
16512 \begin_inset LatexCommand \index{-\/-peep-file}
16519 The rule language is best illustrated with examples.
16543 The above rule will change the following assembly
16544 \begin_inset LatexCommand \index{Assembler routines}
16566 Note: All occurrences of a
16570 (pattern variable) must denote the same string.
16571 With the above rule, the assembly sequence:
16581 will remain unmodified.
16585 Other special case optimizations may be added by the user (via
16601 some variants of the 8051 MCU allow only
16610 The following two rules will change all
16629 replace { lcall %1 } by { acall %1 }
16631 replace { ljmp %1 } by { ajmp %1 }
16636 inline-assembler code
16638 is also passed through the peep hole optimizer, thus the peephole optimizer
16639 can also be used as an assembly level macro expander.
16640 The rules themselves are MCU dependent whereas the rule language infra-structur
16641 e is MCU independent.
16642 Peephole optimization rules for other MCU can be easily programmed using
16647 The syntax for a rule is as follows:
16652 rule := replace [ restart ] '{' <assembly sequence> '
16690 <assembly sequence> '
16708 '}' [if <functionName> ] '
16713 <assembly sequence> := assembly instruction (each instruction including
16714 labels must be on a separate line).
16718 The optimizer will apply to the rules one by one from the top in the sequence
16719 of their appearance, it will terminate when all rules are exhausted.
16720 If the 'restart' option is specified, then the optimizer will start matching
16721 the rules again from the top, this option for a rule is expensive (performance)
16722 , it is intended to be used in situations where a transformation will trigger
16723 the same rule again.
16724 An example of this (not a good one, it has side effects) is the following
16747 Note that the replace pattern cannot be a blank, but can be a comment line.
16748 Without the 'restart' option only the inner most 'pop' 'push' pair would
16749 be eliminated, i.e.:
16779 the restart option the rule will be applied again to the resulting code
16780 and then all the pop-push pairs will be eliminated to yield:
16790 A conditional function can be attached to a rule.
16791 Attaching rules are somewhat more involved, let me illustrate this with
16818 The optimizer does a look-up of a function name table defined in function
16823 in the source file SDCCpeeph.c, with the name
16828 If it finds a corresponding entry the function is called.
16829 Note there can be no parameters specified for these functions, in this
16834 is crucial, since the function
16838 expects to find the label in that particular variable (the hash table containin
16839 g the variable bindings is passed as a parameter).
16840 If you want to code more such functions, take a close look at the function
16841 labelInRange and the calling mechanism in source file SDCCpeeph.c.
16842 Currently implemented are
16844 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
16845 24bitMode, portIsDS390, 24bitModeAndPortDS390
16854 I know this whole thing is a little kludgey, but maybe some day we will
16855 have some better means.
16856 If you are looking at this file, you will see the default rules that are
16857 compiled into the compiler, you can add your own rules in the default set
16858 there if you get tired of specifying the -
16878 <pending: this is messy and incomplete>
16883 Compiler support routines (_gptrget, _mulint etc)
16886 Stdclib functions (puts, printf, strcat etc)
16889 Math functions (sin, pow, sqrt etc)
16893 \begin_inset LatexCommand \index{Libraries}
16897 included in SDCC should have a license at least as liberal as the GNU Lesser
16898 General Public License
16899 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
16910 license statements for the libraries are missing.
16911 sdcc/device/lib/ser_ir.c
16915 come with a GPL (as opposed to LGPL) License - this will not be liberal
16916 enough for many embedded programmers.
16919 If you have ported some library or want to share experience about some code
16921 falls into any of these categories Busses (I
16922 \begin_inset Formula $^{\textrm{2}}$
16925 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
16926 cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
16927 Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list
16928 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
16933 would certainly like to hear about it.
16934 Programmers coding for embedded systems are not especially famous for being
16935 enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
16936 e these references are very valuable.
16940 \begin_inset LatexCommand \label{sub:External-Stack}
16945 \begin_inset LatexCommand \index{stack}
16950 \begin_inset LatexCommand \index{External stack}
16957 The external stack (-
16968 \begin_inset LatexCommand \index{-\/-xstack}
16972 ) is located at the start of the external ram segment, and is 256 bytes
16984 -xstack option is used to compile the program, the parameters and local
16985 variables of all reentrant functions are allocated in this area.
16986 This option is provided for programs with large stack space requirements.
16987 When used with the -
16998 \begin_inset LatexCommand \index{-\/-stack-auto}
17002 option, all parameters and local variables are allocated on the external
17003 stack (note support libraries will need to be recompiled with the same
17007 The compiler outputs the higher order address byte of the external ram segment
17008 into PORT P2, therefore when using the External Stack option, this port
17009 MAY NOT be used by the application program.
17013 \begin_inset LatexCommand \index{ANSI-compliance}
17018 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
17025 Deviations from the compliance:
17028 functions are not always reentrant.
17031 structures cannot be assigned values directly, cannot be passed as function
17032 parameters or assigned to each other and cannot be a return value from
17059 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */
17070 struct s foo1 (struct s parms) /* invalid in SDCC although allowed in ANSI
17092 return rets;/* is invalid in SDCC although allowed in ANSI */
17099 \begin_inset LatexCommand \index{long long (not supported)}
17104 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
17112 \begin_inset LatexCommand \index{double (not supported)}
17116 ' precision floating point
17117 \begin_inset LatexCommand \index{Floating point support}
17124 No support for setjmp and longjmp (for now).
17128 \begin_inset LatexCommand \index{K\&R style}
17132 function declarations are NOT allowed.
17138 foo(i,j) /* this old style of function declarations */
17140 int i,j; /* are valid in ANSI but not valid in SDCC */
17155 functions declared as pointers
17156 \begin_inset LatexCommand \index{Pointers}
17161 \begin_inset LatexCommand \index{function pointers}
17165 must be dereferenced during the call.
17176 /* has to be called like this */
17178 (*foo)(); /* ANSI standard allows calls to be made like 'foo()' */
17182 Cyclomatic Complexity
17183 \begin_inset LatexCommand \index{Cyclomatic complexity}
17190 Cyclomatic complexity of a function is defined as the number of independent
17191 paths the program can take during execution of the function.
17192 This is an important number since it defines the number test cases you
17193 have to generate to validate the function.
17194 The accepted industry standard for complexity number is 10, if the cyclomatic
17195 complexity reported by SDCC exceeds 10 you should think about simplification
17196 of the function logic.
17197 Note that the complexity level is not related to the number of lines of
17198 code in a function.
17199 Large functions can have low complexity, and small functions can have large
17205 SDCC uses the following formula to compute the complexity:
17210 complexity = (number of edges in control flow graph) - (number of nodes
17211 in control flow graph) + 2;
17215 Having said that the industry standard is 10, you should be aware that in
17216 some cases it be may unavoidable to have a complexity level of less than
17218 For example if you have switch statement with more than 10 case labels,
17219 each case label adds one to the complexity level.
17220 The complexity level is by no means an absolute measure of the algorithmic
17221 complexity of the function, it does however provide a good starting point
17222 for which functions you might look at for further optimization.
17226 \layout Subsubsection
17229 \begin_inset LatexCommand \label{sub:MCS51-variants}
17234 \begin_inset LatexCommand \index{MCS51 variants}
17241 MCS51 processors are available from many vendors and come in many different
17243 While they might differ considerably in respect to Special Function Registers
17244 the core MCS51 is usually not modified or is kept compatible.
17246 \layout Subsubsection*
17248 pdata access by SFR
17249 \begin_inset LatexCommand \index{sfr}
17256 With the upcome of devices with internal xdata and flash memory devices
17257 using port P2 as dedicated I/O port is becoming more popular.
17258 Switching the high byte for pdata
17259 \begin_inset LatexCommand \index{pdata}
17263 access which was formerly done by port P2 is then achieved by a Special
17265 In well-established MCS51 tradition the address of this
17269 is where the chip designers decided to put it.
17270 As pdata addressing is used in the startup code for the initialization
17271 of xdata variables a separate startup code should be used as described
17273 \begin_inset LatexCommand \ref{sub:Startup-Code}
17278 \layout Subsubsection*
17280 Other Features available by SFR
17283 Some MCS51 variants offer features like Double DPTR
17284 \begin_inset LatexCommand \index{DPTR}
17288 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
17289 These are currently not used for the MCS51 port.
17290 If you absolutely need them you can fall back to inline assembly or submit
17292 \layout Subsubsection
17294 The Z80 and gbz80 port
17297 SDCC can target both the Zilog
17298 \begin_inset LatexCommand \index{Z80}
17302 and the Nintendo Gameboy's Z80-like gbz80
17303 \begin_inset LatexCommand \index{GameBoy Z80}
17308 The Z80 port is passed through the same
17311 \begin_inset LatexCommand \index{Regression test}
17317 as MCS51 and DS390 ports, so floating point support, support for long variables
17318 and bitfield support is fine.
17319 See mailing lists and forums about interrupt routines and access to I/O
17323 As always, the code is the authoritative reference - see z80/ralloc.c and
17325 The stack frame is similar to that generated by the IAR Z80 compiler.
17326 IX is used as the base pointer, HL is used as a temporary register, and
17327 BC and DE are available for holding variables.
17328 IY is currently unused.
17329 Return values are stored in HL.
17330 One bad side effect of using IX as the base pointer is that a functions
17331 stack frame is limited to 127 bytes - this will be fixed in a later version.
17332 \layout Subsubsection
17337 The port to the Motorola HC08
17338 \begin_inset LatexCommand \index{HC08}
17342 family has been added in October 2003, thank you Erik!
17345 Retargetting for other MCUs.
17348 The issues for retargetting the compiler are far too numerous to be covered
17350 What follows is a brief description of each of the seven phases of the
17351 compiler and its MCU dependency.
17354 Parsing the source and building the annotated parse tree.
17355 This phase is largely MCU independent (except for the language extensions).
17356 Syntax & semantic checks are also done in this phase, along with some initial
17357 optimizations like back patching labels and the pattern matching optimizations
17358 like bit-rotation etc.
17361 The second phase involves generating an intermediate code which can be easy
17362 manipulated during the later phases.
17363 This phase is entirely MCU independent.
17364 The intermediate code generation assumes the target machine has unlimited
17365 number of registers, and designates them with the name iTemp.
17366 The compiler can be made to dump a human readable form of the code generated
17380 This phase does the bulk of the standard optimizations and is also MCU independe
17382 This phase can be broken down into several sub-phases:
17386 Break down intermediate code (iCode) into basic blocks.
17388 Do control flow & data flow analysis on the basic blocks.
17390 Do local common subexpression elimination, then global subexpression elimination
17392 Dead code elimination
17396 If loop optimizations caused any changes then do 'global subexpression eliminati
17397 on' and 'dead code elimination' again.
17400 This phase determines the live-ranges; by live range I mean those iTemp
17401 variables defined by the compiler that still survive after all the optimization
17403 Live range analysis
17404 \begin_inset LatexCommand \index{Live range analysis}
17408 is essential for register allocation, since these computation determines
17409 which of these iTemps will be assigned to registers, and for how long.
17412 Phase five is register allocation.
17413 There are two parts to this process.
17417 The first part I call 'register packing' (for lack of a better term).
17418 In this case several MCU specific expression folding is done to reduce
17423 The second part is more MCU independent and deals with allocating registers
17424 to the remaining live ranges.
17425 A lot of MCU specific code does creep into this phase because of the limited
17426 number of index registers available in the 8051.
17429 The Code generation phase is (unhappily), entirely MCU dependent and very
17430 little (if any at all) of this code can be reused for other MCU.
17431 However the scheme for allocating a homogenized assembler operand for each
17432 iCode operand may be reused.
17435 As mentioned in the optimization section the peep-hole optimizer is rule
17436 based system, which can reprogrammed for other MCUs.
17440 \begin_inset LatexCommand \index{Compiler internals}
17447 The anatomy of the compiler
17448 \begin_inset LatexCommand \label{sub:The-anatomy-of}
17457 This is an excerpt from an article published in Circuit Cellar Magazine
17459 It's a little outdated (the compiler is much more efficient now and user/develo
17460 per friendly), but pretty well exposes the guts of it all.
17466 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
17467 It is fairly easy to retarget for other 8-bit MCU.
17468 Here we take a look at some of the internals of the compiler.
17473 \begin_inset LatexCommand \index{Parsing}
17480 Parsing the input source file and creating an AST (Annotated Syntax Tree
17481 \begin_inset LatexCommand \index{Annotated syntax tree}
17486 This phase also involves propagating types (annotating each node of the
17487 parse tree with type information) and semantic analysis.
17488 There are some MCU specific parsing rules.
17489 For example the storage classes, the extended storage classes are MCU specific
17490 while there may be a xdata storage class for 8051 there is no such storage
17491 class for z80 or Atmel AVR.
17492 SDCC allows MCU specific storage class extensions, i.e.
17493 xdata will be treated as a storage class specifier when parsing 8051 C
17494 code but will be treated as a C identifier when parsing z80 or ATMEL AVR
17499 \begin_inset LatexCommand \index{iCode}
17506 Intermediate code generation.
17507 In this phase the AST is broken down into three-operand form (iCode).
17508 These three operand forms are represented as doubly linked lists.
17509 ICode is the term given to the intermediate form generated by the compiler.
17510 ICode example section shows some examples of iCode generated for some simple
17511 C source functions.
17515 \begin_inset LatexCommand \index{Optimizations}
17522 Bulk of the target independent optimizations is performed in this phase.
17523 The optimizations include constant propagation, common sub-expression eliminati
17524 on, loop invariant code movement, strength reduction of loop induction variables
17525 and dead-code elimination.
17528 Live range analysis
17529 \begin_inset LatexCommand \index{Live range analysis}
17536 During intermediate code generation phase, the compiler assumes the target
17537 machine has infinite number of registers and generates a lot of temporary
17539 The live range computation determines the lifetime of each of these compiler-ge
17540 nerated temporaries.
17541 A picture speaks a thousand words.
17542 ICode example sections show the live range annotations for each of the
17544 It is important to note here, each iCode is assigned a number in the order
17545 of its execution in the function.
17546 The live ranges are computed in terms of these numbers.
17547 The from number is the number of the iCode which first defines the operand
17548 and the to number signifies the iCode which uses this operand last.
17551 Register Allocation
17552 \begin_inset LatexCommand \index{Register allocation}
17559 The register allocation determines the type and number of registers needed
17561 In most MCUs only a few registers can be used for indirect addressing.
17562 In case of 8051 for example the registers R0 & R1 can be used to indirectly
17563 address the internal ram and DPTR to indirectly address the external ram.
17564 The compiler will try to allocate the appropriate register to pointer variables
17566 ICode example section shows the operands annotated with the registers assigned
17568 The compiler will try to keep operands in registers as much as possible;
17569 there are several schemes the compiler uses to do achieve this.
17570 When the compiler runs out of registers the compiler will check to see
17571 if there are any live operands which is not used or defined in the current
17572 basic block being processed, if there are any found then it will push that
17573 operand and use the registers in this block, the operand will then be popped
17574 at the end of the basic block.
17578 There are other MCU specific considerations in this phase.
17579 Some MCUs have an accumulator; very short-lived operands could be assigned
17580 to the accumulator instead of general-purpose register.
17586 Figure II gives a table of iCode operations supported by the compiler.
17587 The code generation involves translating these operations into corresponding
17588 assembly code for the processor.
17589 This sounds overly simple but that is the essence of code generation.
17590 Some of the iCode operations are generated on a MCU specific manner for
17591 example, the z80 port does not use registers to pass parameters so the
17592 SEND and RECV iCode operations will not be generated, and it also does
17593 not support JUMPTABLES.
17600 <Where is Figure II ?>
17604 \begin_inset LatexCommand \index{iCode}
17611 This section shows some details of iCode.
17612 The example C code does not do anything useful; it is used as an example
17613 to illustrate the intermediate code generated by the compiler.
17625 /* This function does nothing useful.
17632 for the purpose of explaining iCode */
17635 short function (data int *x)
17643 short i=10; /* dead initialization eliminated */
17648 short sum=10; /* dead initialization eliminated */
17661 while (*x) *x++ = *p++;
17675 /* compiler detects i,j to be induction variables */
17679 for (i = 0, j = 10 ; i < 10 ; i++, j
17705 mul += i * 3; /* this multiplication remains */
17711 gint += j * 3;/* this multiplication changed to addition */
17725 In addition to the operands each iCode contains information about the filename
17726 and line it corresponds to in the source file.
17727 The first field in the listing should be interpreted as follows:
17732 Filename(linenumber: iCode Execution sequence number : ICode hash table
17733 key : loop depth of the iCode).
17738 Then follows the human readable form of the ICode operation.
17739 Each operand of this triplet form can be of three basic types a) compiler
17740 generated temporary b) user defined variable c) a constant value.
17741 Note that local variables and parameters are replaced by compiler generated
17744 \begin_inset LatexCommand \index{Live range analysis}
17748 are computed only for temporaries (i.e.
17749 live ranges are not computed for global variables).
17751 \begin_inset LatexCommand \index{Register allocation}
17755 are allocated for temporaries only.
17756 Operands are formatted in the following manner:
17761 Operand Name [lr live-from : live-to ] { type information } [ registers
17767 As mentioned earlier the live ranges are computed in terms of the execution
17768 sequence number of the iCodes, for example
17770 the iTemp0 is live from (i.e.
17771 first defined in iCode with execution sequence number 3, and is last used
17772 in the iCode with sequence number 5).
17773 For induction variables such as iTemp21 the live range computation extends
17774 the lifetime from the start to the end of the loop.
17776 The register allocator used the live range information to allocate registers,
17777 the same registers may be used for different temporaries if their live
17778 ranges do not overlap, for example r0 is allocated to both iTemp6 and to
17779 iTemp17 since their live ranges do not overlap.
17780 In addition the allocator also takes into consideration the type and usage
17781 of a temporary, for example itemp6 is a pointer to near space and is used
17782 as to fetch data from (i.e.
17783 used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer registers (r0).
17784 Some short lived temporaries are allocated to special registers which have
17785 meaning to the code generator e.g.
17786 iTemp13 is allocated to a pseudo register CC which tells the back end that
17787 the temporary is used only for a conditional jump the code generation makes
17788 use of this information to optimize a compare and jump ICode.
17790 There are several loop optimizations
17791 \begin_inset LatexCommand \index{Loop optimization}
17795 performed by the compiler.
17796 It can detect induction variables iTemp21(i) and iTemp23(j).
17797 Also note the compiler does selective strength reduction
17798 \begin_inset LatexCommand \index{Strength reduction}
17803 the multiplication of an induction variable in line 18 (gint = j * 3) is
17804 changed to addition, a new temporary iTemp17 is allocated and assigned
17805 a initial value, a constant 3 is then added for each iteration of the loop.
17806 The compiler does not change the multiplication
17807 \begin_inset LatexCommand \index{Multiplication}
17811 in line 17 however since the processor does support an 8 * 8 bit multiplication.
17813 Note the dead code elimination
17814 \begin_inset LatexCommand \index{Dead-code elimination}
17818 optimization eliminated the dead assignments in line 7 & 8 to I and sum
17826 Sample.c (5:1:0:0) _entry($9) :
17831 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
17836 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv
17841 Sample.c(11:4:53:0) preHeaderLbl0($11) :
17846 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
17852 Sample.c(11:6:5:1) _whilecontinue_0($1) :
17857 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
17863 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
17868 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
17874 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
17880 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
17886 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
17892 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
17893 * int}[r0] + 0x2 {short}
17898 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
17903 Sample.c(11:17:21:0)_whilebreak_0($3) :
17908 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
17913 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
17918 Sample.c(15:20:54:0)preHeaderLbl1($13) :
17923 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
17928 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
17933 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
17938 Sample.c(15:24:26:1)_forcond_0($4) :
17943 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
17949 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
17954 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
17955 + ITemp21 [lr21:38]{short}[r4]
17960 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
17966 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
17967 + iTemp15 [lr29:30]{short}[r1]
17972 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
17978 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
17984 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
17990 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
17996 Sample.c(19:38:47:1) goto _forcond_0($4)
18001 Sample.c(19:39:48:0)_forbreak_0($7) :
18006 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
18007 + ITemp11 [lr19:40]{short}[r3]
18012 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
18017 Sample.c(20:42:51:0)_return($8) :
18022 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
18028 Finally the code generated for this function:
18069 ; ----------------------------------------------
18074 ; function function
18079 ; ----------------------------------------------
18089 ; iTemp0 [lr3:5]{_near * int}[r2] = recv
18101 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
18113 ;_whilecontinue_0($1) :
18123 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
18128 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
18187 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
18206 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
18253 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
18293 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
18319 ; iTemp6 [lr5:16]{_near * int}[r0] =
18324 ; iTemp6 [lr5:16]{_near * int}[r0] +
18341 ; goto _whilecontinue_0($1)
18353 ; _whilebreak_0($3) :
18363 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
18375 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
18387 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
18399 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
18418 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
18447 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
18452 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
18497 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] +
18502 ; iTemp21 [lr21:38]{short}[r4]
18528 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
18561 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] +
18566 ; iTemp15 [lr29:30]{short}[r1]
18585 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
18632 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
18679 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
18691 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
18705 cjne r5,#0xff,00104$
18717 ; goto _forcond_0($4)
18729 ; _forbreak_0($7) :
18739 ; ret iTemp24 [lr40:41]{short}
18782 A few words about basic block successors, predecessors and dominators
18785 Successors are basic blocks
18786 \begin_inset LatexCommand \index{Basic blocks}
18790 that might execute after this basic block.
18792 Predecessors are basic blocks that might execute before reaching this basic
18795 Dominators are basic blocks that WILL execute before reaching this basic
18829 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
18832 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
18835 c) domVect of [BB4] = BB1 ...
18836 here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
18844 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
18854 Thanks to all the other volunteer developers who have helped with coding,
18855 testing, web-page creation, distribution sets, etc.
18856 You know who you are :-)
18863 This document was initially written by Sandeep Dutta
18866 All product names mentioned herein may be trademarks
18867 \begin_inset LatexCommand \index{Trademarks}
18871 of their respective companies.
18878 To avoid confusion, the installation and building options for SDCC itself
18879 (chapter 2) are not part of the index.
18883 \begin_inset LatexCommand \printindex{}