pdftitle={SDCC Compiler User Guide},
pdfauthor={SDCC development team},
pdfsubject={installation, user manual},
- pdfkeywords={8032 8051 ansi c compiler CPU DS390
- embedded GPL HC08 manual mcs51 microcontroller PIC Z80},
+ pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
+ pdfpagemode=UseOutlines,
colorlinks=true,
linkcolor=blue] {hyperref}
%
\size normal
-SDCC 2.5.4
+SDCC 2.6.1
\size footnotesize
\newline
$Revision$
\layout Comment
-The above strings enclosed in $ are automatically updated by cvs
+The above strings enclosed in $ are automatically updated by Subversion
\layout Standard
, etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and
Zilog Z80 based MCUs.
- It can be retargetted for other microprocessors, support for Microchip
- PIC, Atmel AVR is under development.
+ It can be retargeted for other microprocessors, support for Microchip PIC,
+ Atmel AVR is under development.
The entire source code for the compiler is distributed under GPL.
SDCC uses ASXXXX
\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
\end_inset
-, an open source retargettable assembler & linker.
+, an open source retargetable assembler & linker.
SDCC has extensive language extensions suitable for utilizing various microcont
rollers and underlying hardware effectively.
\newline
Supported data-types are:
-\layout Itemize
+\layout Standard
-char (8 bits, 1 byte),
-\layout Itemize
-short and int (16 bits, 2 bytes),
-\layout Itemize
+\begin_inset Tabular
+<lyxtabular version="3" rows="8" columns="5">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="block" valignment="top" leftline="true" rightline="true" width="20text%">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
-long (32 bit, 4 bytes)
-\layout Itemize
+\layout Standard
+
+type
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+width
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+default
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+signed range
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+unsigned range
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+bool
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+1 bit
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+unsigned
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+-
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0, 1
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+char
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+8 bits, 1 byte
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
-float (4 byte IEEE).
-
\layout Standard
+signed
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+-128, +127
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0, +255
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+short
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+16 bits, 2 bytes
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+signed
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+-32.768, +32.767
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0, +65.535
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+int
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+16 bits, 2 bytes
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+signed
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+-32.768, +32.767
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0, +65.535
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+long
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+32 bits, 4 bytes
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+signed
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+-2.147.483.648, +2.147.483.647
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0, +4.294.967.295
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+float
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+4 bytes IEEE 754
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+signed
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+1.175494351E-38,
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+3.402823466E+38
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+pointer
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+1, 2, 3 or 4 bytes
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+generic
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\newline
The compiler also allows
\emph on
inline assembler code
\newline
SDCC also comes with a companion source level debugger SDCDB, the debugger
- currently uses ucSim a freeware simulator for 8051 and other micro-controllers.
- SDCDB and ucSim are currently not available on Win32 platforms.
-
+ currently uses ucSim a freeware simulator for 8051 and other micro-controllers.<
\newline
\newline
italic.
\layout Section
-Compatibility with previous versions
+Compatibility
+\begin_inset LatexCommand \label{sec:Compatibility-with-previous}
+
+\end_inset
+
+ with previous versions
\begin_inset LatexCommand \index{Compatibility with previous versions}
\end_inset
files are stored is now in /usr/local/share.
\layout Itemize
-char type parameters to vararg functions are casted to int unless explicitly
- casted, e.g.:
+char type parameters to vararg
+\begin_inset LatexCommand \index{vararg, va\_arg}
+
+\end_inset
+
+ functions are casted to int unless explicitly casted
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+, e.g.:
\newline
\family typewriter
\newline
\SpecialChar ~
\SpecialChar ~
-b = ~b; /* equivalent to b=1 instead of toggling b */
+b = ~
+\begin_inset LatexCommand \index{\~\/ Operator}
+
+\end_inset
+
+b; /* equivalent to b=1 instead of toggling b */
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+
\newline
\SpecialChar ~
\SpecialChar ~
Some of the other tools (simulator and assembler) included with SDCC contain
their own documentation and can be found in the source distribution.
If you want the latest unreleased software, the complete source package
- is available directly by anonymous CVS on cvs.sdcc.sourceforge.net.
+ is available directly from Subversion on https://svn.sourceforge.net/svnroot/sdcc
+/trunk/sdcc.
\layout Section
Wishes for the future
\end_inset
- or section
+ (Unix) or section
\begin_inset LatexCommand \ref{sub:Windows-Install}
\end_inset
-.
- More detailled instructions follow below.
+ (Windows).
+ More detailed instructions follow below.
\layout Section
Configure Options
/
\end_inset
--disable-device-lib-build Disables automatically building device libraries
+-disable-device-lib Disables automatically building device libraries
\layout List
\labelwidthstring 00.00.0000
/
\end_inset
+-enable-doc Build pdf, html and txt files from the lyx sources
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
-enable-libgc Use the Bohem memory allocator.
Lower runtime footprint.
\layout Standard
/
\end_inset
--disable-device-lib-build
+-disable-device-lib
\backslash
\newline
/
\end_inset
--disable-ucsim
+-host=i586-mingw32msvc
\backslash
\newline
/
\end_inset
--host=i586-mingw32msvc -
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash
-/
-\end_inset
-
-build=unknown-unknown-linux-gnu
\layout Standard
./configure -C
\backslash
-\newline
-CFLAGS=
-\begin_inset Quotes srd
-\end_inset
-
--mno-cygwin -O2
-\begin_inset Quotes srd
-\end_inset
-
-
-\backslash
-
-\newline
-LDFLAGS=
-\begin_inset Quotes srd
-\end_inset
-
--mno-cygwin
-\begin_inset Quotes srd
-\end_inset
-
-
-\backslash
-
\newline
-
\begin_inset ERT
\backslash
\newline
--
-\begin_inset ERT
-status Collapsed
+CC=
+\begin_inset Quotes srd
+\end_inset
-\layout Standard
+gcc -mno-cygwin
+\begin_inset Quotes srd
+\end_inset
+
\backslash
-/
+
+\newline
+CXX=
+\begin_inset Quotes srd
+\end_inset
+
+g++ -mno-cygwin
+\begin_inset Quotes srd
\end_inset
--disable-ucsim
+
\layout Standard
'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
\begin_inset Tabular
<lyxtabular version="3" rows="5" columns="4">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\series medium
Download the source package
\series default
- either from the SDCC CVS repository or from the nightly snapshots
+ either from the SDCC Subversion repository or from the nightly snapshots
\series medium
, it will be named something like sdcc
\series default
See section 'Configure Options'.
\layout Subsection
-Building SDCC on Windows
-\layout Standard
-
-With the exception of Cygwin the SDCC binaries uCsim and sdcdb can't be
- built on Windows.
- They use Unix-sockets, which are not available on Win32.
-\layout Subsection
-
Building SDCC using Cygwin and Mingw32
\layout Standard
later
\layout Itemize
-cvs ; only if you use CVS access
+svn ; only if you use Subversion access
\layout Standard
If you want to develop something you'll need:
\series medium
Download the source package
\series default
- either from the SDCC CVS repository or from the
+ either from the SDCC Subversion repository or from the
\begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
\end_inset
\series default
SDCC is distributed with all the projects, workspaces, and files you need
- to build it using Visual C++ 6.0/NET (except for sdcdb.exe which currently
- doesn't build under MSVC).
+ to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
The workspace name is 'sdcc.dsw'.
Please note that as it is now, all the executables are created in a folder
called sdcc
\newline
WARNING: Visual studio is very picky with line terminations; it expects
the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
- When using the CVS repository it's easiest to configure the cvs client
- to convert automatically for you.
+ When using the Subversion repository it's easiest to configure the svn
+ client to convert automatically for you.
If however you are getting a message such as "This makefile was not generated
by Developer Studio etc.
etc.
From the sdcc directory, run the command "make -f Makefile.bcc".
This should regenerate all the .exe files in the bin directory except for
- sdcdb.exe (which currently doesn't build under Borland C++).
+ SDCDB and ucSim.
\layout Enumerate
If you modify any source files and need to rebuild, be aware that the dependenci
directory or start sdcc using the full path.
\layout Subsection
-Windows Install Using the Setup Program
-\begin_inset LatexCommand \label{sub:Windows-Install}
+Windows Install Using the Setup Program
+\begin_inset LatexCommand \label{sub:Windows-Install}
+
+\end_inset
+
+
+\layout Standard
+
+Download the setup program
+\emph on
+sdcc-x.y.z-setup.exe
+\emph default
+ for an official release from
+\newline
+
+\begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
+
+\end_inset
+
+ or a setup program for one of the snapshots
+\emph on
+sdcc-yyyymmdd-xxxx-setup.exe
+\emph default
+ from
+\begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
+
+\end_inset
+
+ and execute it.
+ A windows typical installer will guide you through the installation process.
+\layout Subsection
+
+VPATH
+\begin_inset LatexCommand \index{VPATH}
+
+\end_inset
+
+ feature
+\layout Standard
+
+SDCC supports the VPATH feature provided by configure and make.
+ It allows to separate the source and build trees.
+ Here's an example:
+\layout Standard
+
+
+\family typewriter
+cd ~\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+# cd $HOME
+\layout Standard
+
-\end_inset
+\family typewriter
+tar -xzf sdcc.src.tar.gz\SpecialChar ~
+# extract source to directory sdcc
+\layout Standard
+\family typewriter
+mkdir sdcc.build\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+# put output in sdcc.build
\layout Standard
-Download the setup program
-\emph on
-sdcc-x.y.z-setup.exe
-\emph default
- for an official release from
-\newline
-\begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
+\family typewriter
+cd sdcc.build
+\layout Standard
-\end_inset
- or a setup program for one of the snapshots
-\emph on
-sdcc_yyyymmdd_setup.exe
-\emph default
- from
-\begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
+\family typewriter
+../sdcc/configure\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+# configure is doing all the magic!
+\layout Standard
-\end_inset
- and execute it.
- A windows typical installer will guide you through the installation process.
+\family typewriter
+make
+\layout Standard
+\noindent
+That's it!
+\series bold
+configure
+\series default
+ will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
+ It automagically computes the variables srcdir, top_srcdir and top_buildir
+ for each directory.
+ After running
+\series bold
+make
+\series default
+ the generated files will be in ~/sdcc.build, while the source files stay
+ in ~/sdcc.
+\newline
+This is not only usefull for building different binaries, e.g.
+ when cross compiling.
+ It also gives you a much better overview in the source tree when all the
+ generated files are not scattered between the source files.
+ And the best thing is: if you want to change a file you can leave the original
+ file untouched in the source directory.
+ Simply copy it to the build directory, edit it, enter `make clean`, `rm
+ Makefile.dep` and `make`.
+
+\series bold
+make
+\series default
+ will do the rest for you!
\layout Section
Building the Documentation
\layout Standard
-If the necessary tools (LyX, LaTeX, LaTeX2HTML) are installed it is as easy
- as changing into the doc directory and typing
+Add -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-enable-doc to the configure arguments to build the documentation together
+ with all the other stuff.
+ You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
+ dvips and makeindex) to get the job done.
+ Another possibility is to change to the doc directory and to type
\family sans
\series bold
\end_inset
- as editor this is straightforward.
+ as editor is straightforward.
Prebuilt documentation in html and pdf format is available from
\begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
\layout Section
Reading the Documentation
+\begin_inset LatexCommand \index{Documentation}
+
+\end_inset
+
+
\layout Standard
Currently reading the document in pdf format is recommended, as for unknown
a
\emph default
rray
-\begin_inset LatexCommand \index{fpga (field programmable gate array)}
+\begin_inset LatexCommand \index{FPGA (field programmable gate array)}
+
+\end_inset
+
+
+\begin_inset Quotes srd
+\end_inset
+
+ or
+\begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
\end_inset
+
+\begin_inset Quotes sld
+\end_inset
+have you ever heard of an open source compiler that compiles a subset of
+ C for an FPGA?
\begin_inset Quotes srd
\end_inset
\family default
\series default
- at the prompt, and the program should run and tell you the version.
- If it doesn't run, or gives a message about not finding sdcc program, then
+ at the prompt, and the program should run and output its version like:
+
+\newline
+
+\family typewriter
+SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
+ (UNIX)
+\layout Standard
+
+If it doesn't run, or gives a message about not finding sdcc program, then
you need to check over your installation.
Make sure that the sdcc bin directory is in your executable search path
defined by the PATH environment setting (
\layout Itemize
s51 - The ucSim 8051 simulator.
- Not available on Win32 platforms.
\layout Itemize
sdcdb - The source debugger.
- Not available on Win32 platforms.
\layout Itemize
packihx - A tool to pack (compress) Intel hex files.
.
It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
XA51 family.
- S51 is currently not available on Win32 platfors.
\layout Subsection
sdcdb - Source Level Debugger
\layout Standard
-Sdcdb
-\begin_inset LatexCommand \index{sdcdb (debugger)}
+SDCDB
+\begin_inset LatexCommand \index{SDCDB (debugger)}
\end_inset
is the companion source level debugger.
- More about sdcdb in section
+ More about SDCDB in section
\begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
\end_inset
\end_inset
, but can be easily changed to use other simulators.
- Sdcdb is currently not available on Win32 platfors.
\layout Chapter
Using SDCC
- An intermediate file containing debug information needed to create the
.cdb file (with -
\begin_inset ERT
-status Open
+status Collapsed
\layout Standard
\end_inset
- file containing debug information (generated with option -
+
+\begin_inset LatexCommand \label{OMF file}
+
+\end_inset
+
+file containing debug information (generated with option -
\begin_inset ERT
status Collapsed
).
\layout Subsection
+Postprocessing the Intel Hex
+\begin_inset LatexCommand \index{Intel hex format}
+
+\end_inset
+
+ file
+\layout Standard
+
+The Intel Hex file
+\begin_inset LatexCommand \index{<file>.ihx}
+
+\end_inset
+
+ which is generated by SDCC might include lines of varying length and the
+ addresses within the file are not guaranteed to be strictly ascending.
+ If your toolchain or a bootloader does not like this you can use the tool
+
+\family typewriter
+packihx
+\family default
+
+\begin_inset LatexCommand \index{packihx (tool)}
+
+\end_inset
+
+ which is part of the SDCC distribution:
+\newline
+
+\newline
+
+\family sans
+\series bold
+ packihx sourcefile.ihx >sourcefile.hex
+\family default
+\series default
+
+\newline
+
+\newline
+The separately available
+\emph on
+ srecord
+\emph default
+
+\begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
+
+\end_inset
+
+ package additionally allows to set undefined locations to a predefined
+ value, to insert checksums of various flavours (crc, add, xor) and to perform
+ other manipulations (convert, split, crop, offset, ...).
+
+\newline
+
+\newline
+
+\family sans
+\series bold
+srec_cat\SpecialChar ~
+\SpecialChar ~
+sourcefile.ihx -intel\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+-fill 0xff 0x0000 0x8000\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+-o sourcefile.hex -intel
+\newline
+
+\newline
+
+\family default
+\series default
+The srecord package is available at
+\begin_inset LatexCommand \url{http://sf.net/projects/srecord}
+
+\end_inset
+
+ .
+\layout Subsection
+
Projects with Multiple Source Files
\layout Standard
\newline
\layout Standard
-
+\added_space_bottom bigskip
If the source files are compiled using -
\begin_inset ERT
-status Open
+status Collapsed
\layout Standard
processor (Not maintained, not complete).
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
Like `-dD' except that the macro arguments and contents are omitted.
Only `#define name' is included in the output.
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
\labelwidthstring 00.00.0000
+\series bold
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-xstack-loc
+\series default
+
+\begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
+
+\end_inset
+
+\SpecialChar ~
+<Value> By default the external stack
+\begin_inset LatexCommand \index{xstack}
+
+\end_inset
+
+ is placed after the pdata
+\begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
+
+\end_inset
+
+ segment.
+ Using this option the xstack can be placed anywhere in the external memory
+ space of the 8051.
+ The value entered can be in Hexadecimal or Decimal format, e.g.
+ -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-xstack-loc 0x8000 or -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-stack-loc 32768.
+ The provided value should not overlap any other memory areas such as the
+ pdata or xdata segment and with enough space for the current application.
+\layout List
+\labelwidthstring 00.00.0000
+
+
\series bold
-
\begin_inset ERT
\end_inset
+\begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
+
+\end_inset
+
+
\bar under
\series default
\end_inset
.
- (Currently only supported for the HC08 processors)
+ (Currently only supported for the HC08
+\begin_inset LatexCommand \index{HC08}
+
+\end_inset
+
+ processors)
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
...
Pass the linkOption to the linker.
- See file sdcc/as/doc/asxhtm.html for more on linker options.
+ If a bootloader is used an option like
+\begin_inset Quotes sld
+\end_inset
+
+-Wl\SpecialChar ~
+-bCSEG=0x1000
+\begin_inset Quotes srd
+\end_inset
+
+ would be typical to set the start of the code segment.
+ See also #pragma constseg and #pragma codeseg in section
+\begin_inset LatexCommand \ref{sec:Pragmas}
+
+\end_inset
+
+ .
+ File sdcc/as/doc/asxhtm.html has more on linker options.
\layout Subsection
MCS51 Options
\series default
- Uses a pseudo stack in the first 256 bytes in the external ram for allocating
- variables and passing parameters.
+ Uses a pseudo stack in the pdata
+\begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
+
+\end_inset
+
+ area (usually the first 256 bytes in the external ram) for allocating variables
+ and passing parameters.
See section
\begin_inset LatexCommand \ref{sub:External-Stack}
data, idata and stack together.
This is the default now.
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
\end_inset
-\begin_inset LatexCommand \index{DS390 options}
+\begin_inset LatexCommand \index{DS390}
\end_inset
-model-flat24
\series default
-\begin_inset LatexCommand \index{-\/-model-flat24}
+\begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
\end_inset
\end_inset
-protect-sp-update
-\begin_inset LatexCommand \index{-\/-protect-sp-update}
+\begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
\end_inset
-stack-10bit
\series default
-\begin_inset LatexCommand \index{-\/-stack-10bit}
+\begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
\end_inset
\end_inset
-stack-probe
-\begin_inset LatexCommand \index{-\/-stack-probe}
+\begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
\end_inset
\end_inset
-tini-libid
-\begin_inset LatexCommand \index{-\/-tini-libid}
+\begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
\end_inset
<nnnn> LibraryID used in -mTININative.
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
\end_inset
-use-accelerator
-\begin_inset LatexCommand \index{-\/-use-accelerator}
+\begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
\end_inset
\end_inset
-\begin_inset LatexCommand \index{Z80 options}
+\begin_inset LatexCommand \index{Z80}
\end_inset
-callee-saves-bc
\series default
-\begin_inset LatexCommand \index{-\/-callee-saves-bc}
+\begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
\end_inset
\emph default
Force a called function to always save BC.
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
-no-std-crt0
\series default
-\begin_inset LatexCommand \index{-\/-no-std-crt0}
+\begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
\end_inset
\series default
- Disable peep-hole optimization.
+ Disable peep-hole optimization with built-in rules.
\layout List
\labelwidthstring 00.00.0000
The compiler will optimize code generation towards fast code, possibly
at the expense of code size.
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
\series default
This option can be used if the code generated is called by a monitor program
or if the main routine includes an endless loop.
- This option might result in slightly smaller code and save two bytes of
- stack space.
+ This option results in slightly smaller code and saves two bytes of stack
+ space.
The return from the 'main'
\begin_inset LatexCommand \index{main return}
\series default
Display errors and warnings using MSVC style, so you can use SDCC with
visual studio.
+ With SDCC both offering a GCC-like (the default) and a MSVC-like output
+ style, integration into most programming editors should be straightforward.
\layout List
\labelwidthstring 00.00.0000
Can be used for instance when using bank switching to put the const data
in a bank.
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
\series default
Will create a dump of the live ranges of iTemp's
\layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
\series bold
Redirecting output on Windows Shells
\layout Standard
-
+\added_space_bottom bigskip
By default SDCC writes it's error messages to
\begin_inset Quotes sld
\end_inset
..
\layout Standard
-
+\added_space_bottom bigskip
There are some more environment variables recognized by SDCC, but these
are solely used for debugging purposes.
They can change or disappear very quickly, and will never be documented.
and
\emph on
near
+\emph default
+ or the more ANSI-C compliant forms
+\emph on
+__data
+\emph default
+ and
+\emph on
+__near
\emph default
can be used synonymously).
Variables declared with this storage class will be allocated in the directly
\family typewriter
-data unsigned char test_data;
+__data unsigned char test_data;
\layout Standard
Writing 0x01 to this variable generates the assembly code:
\SpecialChar ~
mov\SpecialChar ~
\SpecialChar ~
-_test_data,#0x01
+_test_data,#0x01
\layout Subsubsection
xdata
\family typewriter
-xdata unsigned char test_xdata;
+__xdata unsigned char test_xdata;
\layout Standard
Writing 0x01 to this variable generates the assembly code:
\family typewriter
-idata unsigned char test_idata;
+__idata unsigned char test_idata;
\layout Standard
Writing 0x01 to this variable generates the assembly code:
\family typewriter
-pdata unsigned char test_pdata;
+__pdata unsigned char test_pdata;
\layout Standard
Writing 0x01 to this variable generates the assembly code:
\family typewriter
-code unsigned char test_code;
+__code unsigned char test_code;
\layout Standard
Read access to this variable generates the assembly code:
\family typewriter
-code char test_array[] = {'c','h','e','a','p'};
+__code char test_array[] = {'c','h','e','a','p'};
\layout Standard
Read access to this array using an 8-bit unsigned index generates the assembly
\family typewriter
-bit test_bit;
+__bit test_bit;
\layout Standard
Writing 1 to this variable generates the assembly code:
\end_inset
+\begin_inset LatexCommand \index{sbit}
+
+\end_inset
+
+
\layout Standard
Like the bit keyword,
\family typewriter
-sfr at
+__sfr __at
\begin_inset LatexCommand \index{at}
\end_inset
\end_inset
- 0x80 P0;\SpecialChar ~
+ (0x80) P0;\SpecialChar ~
/* special function register P0 at location 0x80 */
\newline
/* 16 bit special function register combination for timer 0 */
/* with the high byte at location 0x8C and the low byte at location 0x8A
*/
\newline
-sfr16 at
+__sfr16 __at
\begin_inset LatexCommand \index{at}
\end_inset
\end_inset
- 0x8C8A TMR0;
+ (0x8C8A) TMR0;
\newline
-sbit at 0xd7 CY; /* CY (Carry Flag
+__sbit __at (0xd7) CY; /* CY (Carry Flag
\begin_inset LatexCommand \index{Flags}
\end_inset
\emph default
Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
this is not guaranteed.
+\newline
+
+\layout Standard
+
+Please note, if you use a header file which was written for another compiler
+ then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
+ likely be
+\emph on
+not
+\emph default
+compatible.
+ Specifically the syntax
+\family typewriter
+\SpecialChar ~
+sfr P0 = 0x80;\SpecialChar ~
+
+\family default
+ is compiled
+\emph on
+without warning
+\emph default
+ by SDCC to an assignment of 0x80 to a variable called P0
+\family typewriter
+
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+.
+
+\family default
+Nevertheless it is possible to write header files
+\begin_inset LatexCommand \index{Header files}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{Include files}
+
+\end_inset
+
+ which can be shared among different compilers (see section
+\begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
+
+\end_inset
+
+).
+
\layout Subsubsection
Pointers
/* pointer physically in internal ram pointing to object in external ram
*/
\newline
-xdata unsigned char * data p;
+__xdata unsigned char * __data p;
\newline
\newline
/* pointer physically in external ram pointing to object in internal ram
*/
\newline
-data unsigned char * xdata p;
+__data unsigned char * __xdata p;
\newline
\newline
/* pointer physically in code rom pointing to data in xdata space */
\newline
-xdata unsigned char * code p;
+__xdata unsigned char * __code p;
\newline
\newline
/* pointer physically in code space pointing to data in code space */
\newline
-code unsigned char * code p;
+__code unsigned char * __code p;
\newline
\newline
-/* the following is a generic pointer physically located in xdata space
- */
+/* generic pointer physically located in xdata space */
+\newline
+unsigned char * __xdata p;
+\newline
+
\newline
-char * xdata p;
+/* generic pointer physically located in default memory space */
+\newline
+unsigned char * p;
\newline
\newline
/* the following is a function pointer physically located in data space
*/
\newline
-char (* data fp)(void);
+char (* __data fp)(void);
\layout Standard
Well you get the idea.
\emph default
).
+\newline
+
\layout Standard
By default the 8051 linker will place the stack after the last byte of (i)data
If in doubt, don't specify any options and see if the resulting memory
layout is appropriate, then you can adjust it.
\layout Standard
-
+\added_space_bottom bigskip
The linker generates two files with memory allocation information.
The first, with extension .map
\begin_inset LatexCommand \index{<file>.map}
\layout Subsection
Z80/Z180 Storage Class
-\begin_inset LatexCommand \index{Storage class}
+\begin_inset LatexCommand \index{Z80!Storage class}
\end_inset
I/O memory
\begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
+\end_inset
+
+
+\begin_inset LatexCommand \index{Z80!I/O memory}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{Z180!I/O memory}
+
\end_inset
is accessed with special instructions, e.g.:
\end_inset
/HD64180
-\begin_inset LatexCommand \index{HD64180}
+\begin_inset LatexCommand \index{HD64180 (see Z180)}
\end_inset
)
\layout Standard
-
+\added_space_bottom bigskip
The compiler option -
\begin_inset ERT
status Collapsed
/
\end_inset
--portmode=180 (80) and a compiler #pragma\SpecialChar ~
+-portmode
+\begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
+
+\end_inset
+
+=180 (80) and a compiler #pragma\SpecialChar ~
portmode
-\begin_inset LatexCommand \index{\#pragma portmode}
+\begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
\end_inset
\layout Subsection
HC08 Storage Class
-\begin_inset LatexCommand \index{Storage class}
+\begin_inset LatexCommand \index{HC08!Storage class}
\end_inset
The data storage class declares a variable that resides in the first 256
bytes of memory (the direct page).
- The HC08 is most efficient at accessing variables (especially pointers)
- stored here.
+ The HC08
+\begin_inset LatexCommand \index{HC08}
+
+\end_inset
+
+ is most efficient at accessing variables (especially pointers) stored here.
\layout Subsubsection
xdata
\layout Standard
-
+\added_space_bottom bigskip
The xdata storage class declares a variable that can reside anywhere in
memory.
This is the default if no storage class is specified.
0x7ffe unsigned int chksum;
\layout Standard
+or, better conforming to ISO/IEC 9899 C:
+\layout Verse
+
+
+\family typewriter
+__xdata __at (0x7ffe) unsigned int chksum;
+\layout Standard
+
In the above example the variable chksum will be located at 0x7ffe and 0x7fff
of the external ram.
The compiler does
\emph on
not
\emph default
- reserve any space for variables declared in this way (they are implemented
- with an equate in the assembler).
+ reserve any space for variables declared in this way
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+ (they are implemented with an equate in the assembler).
Thus it is left to the programmer to make sure there are no overlaps with
other variables that are declared without the absolute address.
The assembler listing file (.lst
Variables with an absolute address are
\emph on
not
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+
\emph default
initialized
\begin_inset LatexCommand \index{Variable initialization}
\end_inset
- xdata
+ __xdata
\begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
\end_inset
- at
+ __at
\begin_inset LatexCommand \index{at}
\end_inset
- 0x8000 unsigned char PORTA_8255;
+ (0x8000) unsigned char PORTA_8255;
\layout Standard
For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
\family typewriter
-bit
+__bit
\begin_inset LatexCommand \index{bit}
\end_inset
- at
+ __at
\begin_inset LatexCommand \index{at}
\end_inset
- 0x02 bvar;
+ (0x02) bvar;
\layout Standard
The above example will allocate the variable at offset 0x02 in the bit-addressab
\end_inset
- bit MOSI;\SpecialChar ~
+ __bit MOSI;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* master out, slave in */
\newline
-extern volatile bit MISO;\SpecialChar ~
+extern volatile __bit MISO;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* master in, slave out */
\newline
-extern volatile bit MCLK;\SpecialChar ~
+extern volatile __bit MCLK;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\family typewriter
-bit at
+__bit __at
\begin_inset LatexCommand \index{at}
\end_inset
\end_inset
- 0x80 MOSI;\SpecialChar ~
+ (0x80) MOSI;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 0, bit 0 */
\newline
-bit at 0x81 MISO;\SpecialChar ~
+__bit __at (0x81) MISO;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 0, bit 1 */
\newline
-bit at 0x82 MCLK;\SpecialChar ~
+__bit __at (0x82) MCLK;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\family typewriter
-bit at 0x83 MOSI;\SpecialChar ~
+__bit __at (0x83) MOSI;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 0, bit 3 */
\newline
-bit at 0x91 MISO;\SpecialChar ~
+__bit __at (0x91) MISO;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 1, bit 1 */
\newline
-bit
+__bit
\begin_inset LatexCommand \index{bit}
\end_inset
- at 0x92 MCLK;\SpecialChar ~
+ __at (0x92) MCLK;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 1, bit 2 */
\layout Standard
-
+\added_space_bottom bigskip
and you can use the same hardware dependent routine without changes, as
for example in a library.
This is somehow similar to sbit, but only one absolute address has to be
\family typewriter
-unsigned char foo(char i) reentrant
+unsigned char foo(char i) __reentrant
\newline
{
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-xdata unsigned char i;
+__xdata unsigned char i;
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-bit bvar;
+__bit bvar;
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-data at
+__data __at
\begin_inset LatexCommand \index{at}
\end_inset
- 0x31 unsigned char j;
+ (0x31) unsigned char j;
\newline
\SpecialChar ~
\SpecialChar ~
It is however allowed to use bit parameters in reentrant functions and also
non-static local bit variables are supported.
Efficient use is limited to 8 semi-bitregisters in bit space.
- They are pushed and popped to stack as a single byte just like the normal
- registers.
+ They are pushed and popped to stack
+\begin_inset LatexCommand \index{stack}
+
+\end_inset
+
+ as a single byte just like the normal registers.
\layout Section
Overlaying
Note that the compiler (not the linkage editor) makes the decision for overlayin
g the data items.
- Functions that are called from an interrupt service routine should be preceded
- by a #pragma\SpecialChar ~
+ Functions that are called from an interrupt service routine
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+!
+\end_inset
+
+ should be preceded by a #pragma\SpecialChar ~
nooverlay
\begin_inset LatexCommand \index{\#pragma nooverlay}
\newline
\newline
-void some_isr () interrupt
+void some_isr () __interrupt
\begin_inset LatexCommand \index{interrupt}
\end_inset
- 2
+ (2)
\newline
{
\newline
\newline
}
\layout Standard
-
+\added_space_bottom bigskip
In the above example the parameter
\emph on
errcd
\family typewriter
-void timer_isr (void) interrupt 1 using 1
+void timer_isr (void) __interrupt (1) __using (1)
\newline
{
\newline
main
\emph default
.
- The optional
+ The optional (8051 specific) keyword
\emph on
using
\begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
\emph default
- keyword can be used to tell the compiler to use the specified register
- bank (8051 specific) when generating code for this function.
+ can be used to tell the compiler to use the specified register bank when
+ generating code for this function.
\newline
+Interrupt service routines open the door for some very interesting bugs:
+\layout Subsubsection
+
+
+\begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
+\end_inset
+
+Common interrupt pitfall: variable not declared
+\emph on
+volatile
\layout Standard
-Interrupt service routines open the door for some very interesting bugs:
-\newline
If an interrupt service routine changes variables which are accessed by
other functions these variables have to be declared
\emph on
\end_inset
.
-
+ See
+\begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
+
+\end_inset
+
+ .
+\layout Subsubsection
+
+
+\begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
+
+\end_inset
+
+Common interrupt pitfall:
+\emph on
+non-atomic access
\layout Standard
If the access to these variables is not
the processor needs more than one instruction for the access and could
be interrupted while accessing the variable) the interrupt must be disabled
during the access to avoid inconsistent data.
- Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
- and should be protected by disabling interrupts.
+
+\newline
+Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs and
+ should be protected by disabling interrupts.
You're not automatically on the safe side if you use 8 bit variables though.
We need an example here: f.e.
on the 8051 the harmless looking
counter
\family default
is located in data memory.
- Bugs like these are hard to reproduce and can cause a lot of trouble.
+\newline
+Bugs like these are hard to reproduce and can cause a lot of trouble.
+\layout Subsubsection
+
+
+\begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
+
+\end_inset
+
+Common interrupt pitfall:
+\emph on
+stack overflow
\layout Standard
The return address and the registers used in the interrupt service routine
subroutine when the stack is already in use for f.e.
many return addresses.
+\layout Subsubsection
+
+
+\begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
+
+\end_inset
+
+Common interrupt pitfall:
+\emph on
+use of non-reentrant functions
\layout Standard
A special note here, int (16 bit) and long (32 bit) integer division
\end_inset
- operations are implemented using external support routines developed in
- ANSI-C.
+ operations are implemented using external support routines.
If an interrupt service routine needs to do any of these operations then
the support routines (as mentioned in a following section) will have to
be recompiled using the
\end_inset
compiler option.
+
+\newline
+Note, the type promotion
+\begin_inset LatexCommand \index{type promotion}
+
+\end_inset
+
+ required by ANSI C can cause 16 bit routines to be used
+\begin_inset Marginal
+collapsed true
+
\layout Standard
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+ without the programmer being aware of it.
+ See f.e.
+ the cast
+\family typewriter
+(unsigned char)(tail-1)
+\family default
+ within the if clause in section
+\begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
+
+\end_inset
+
+.
+\layout Standard
+\added_space_bottom bigskip
Calling other functions from an interrupt service routine is not recommended,
avoid it if possible.
Note that when some function is called from an interrupt service routine
if it is not reentrant.
Furthermore nonreentrant functions should not be called from the main program
while the interrupt service routine might be active.
-
-\newline
-
+ They also must not be called from low priority interrupt service routines
+ while a high priority interrupt service routine might be active.
+ You could use semaphores or make the function
+\emph on
+ critical
+\emph default
+ if all parameters are passed in registers.
\newline
-Also see section
+ Also see section
\begin_inset LatexCommand \ref{sub:Overlaying}
\end_inset
\align center
\begin_inset Tabular
-<lyxtabular version="3" rows="7" columns="3">
+<lyxtabular version="3" rows="9" columns="3">
<features>
<column alignment="center" valignment="top" leftline="true" width="0in">
-<column alignment="center" valignment="top" leftline="true" width="0in">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0in">
+<column alignment="left" valignment="top" leftline="true" width="0in">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-0x000B
+0x000b
\end_inset
</cell>
</row>
\layout Standard
-0x001B
+0x001b
\end_inset
</cell>
</row>
\end_inset
</cell>
</row>
-<row topline="true" bottomline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+<row topline="true">
+<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
\layout Standard
-0x002B
+0x002b
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+...
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+...
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+n
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0x0003 + 8*n
\end_inset
</cell>
</row>
This scheme may be advantageous for small interrupt service routines which
have low register usage.
\layout Standard
-
+\added_space_bottom bigskip
If the interrupt service routine is defined to be using a specific register
bank then only
\emph on
\emph default
& psw are saved and restored, if such an interrupt service routine calls
another function (using another register bank) then the entire register
- bank of the called function will be saved on the stack.
+ bank of the called function will be saved on the stack
+\begin_inset LatexCommand \index{stack}
+
+\end_inset
+
+.
This scheme is recommended for larger interrupt service routines.
\layout Subsection
-HC08 Interrupt Service Routines
+HC08
+\begin_inset LatexCommand \index{HC08}
+
+\end_inset
+
+ Interrupt Service Routines
\layout Standard
+\added_space_bottom bigskip
+Since the number of interrupts
+\begin_inset LatexCommand \index{HC08!interrupt}
+
+\end_inset
-Since the number of interrupts available is chip specific and the interrupt
- vector table always ends at the last byte of memory, the interrupt numbers
- corresponds to the interrupt vectors in reverse order of address.
+ available is chip specific and the interrupt vector table always ends at
+ the last byte of memory, the interrupt numbers corresponds to the interrupt
+ vectors in reverse order of address.
For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
2 will use the interrupt vector at 0xfffa, and so on.
However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
Z80 Interrupt Service Routines
\layout Standard
-The Z80 uses several different methods for determining the correct interrupt
+The Z80
+\begin_inset LatexCommand \index{Z80}
+
+\end_inset
+
+ uses several different methods for determining the correct interrupt
+\begin_inset LatexCommand \index{Z80!interrupt}
+
+\end_inset
+
vector depending on the hardware implementation.
Therefore, SDCC ignores the optional interrupt number and does not attempt
to generate an interrupt vector table.
\layout Standard
-By default, SDCC generates code for a maskable interrupt, which uses an
- RETI instruction to return from the interrupt.
+By default, SDCC generates code for a maskable interrupt, which uses a RETI
+ instruction to return from the interrupt.
To write an interrupt handler for the non-maskable interrupt, which needs
- an RETN instruction instead, add the
+ a RETN instruction instead, add the
\emph on
critical
\emph default
\newline
}
+\layout Standard
+\added_space_bottom bigskip
+However if you need to create a non-interruptable interrupt service routine
+ you would also require the
+\emph on
+critical
+\emph default
+ keyword.
+ To distinguish between this and an nmi_isr you must provide an interrupt
+ number.
\layout Section
Enabling and Disabling Interrupts
\family typewriter
-int foo () critical
+int foo () __critical
\begin_inset LatexCommand \index{critical}
\end_inset
\family typewriter
-critical{ i++; }
+__critical{ i++; }
\layout Standard
More than one statement could have been included in the block.
\end_inset
- (HC08):
+ (HC08
+\begin_inset LatexCommand \index{HC08!interrupt}
+
+\end_inset
+
+):
\layout Verse
\newline
\emph on
-(pending: I don't think this has been done yet)
+(pending: Note, nowadays the
+\emph default
+using
+\emph on
+ attribute has an effect on
+\emph default
+
+\emph on
+the generated code for a
+\emph default
+non-interrupt
+\emph on
+ function
+\emph default
+.
+\emph on
+)
\layout Standard
An
own: I suggest using the default bank zero and taking the small performance
hit.
\layout Standard
-
+\added_space_bottom bigskip
It is most efficient if your ISR calls no other functions.
If your ISR must call other functions, it is most efficient if those functions
use the same bank as the ISR (see note 1 below); the next best is if the
\end_inset
memory has to be explicitly enabled before it can be accessed or if the
- watchdog needs to be disabled, this is the place to do it.
+ watchdog
+\begin_inset LatexCommand \index{watchdog}
+
+\end_inset
+
+ needs to be disabled, this is the place to do it.
The startup code clears all internal data memory, 256 bytes by default,
but from 0 to n-1 if
\emph on
is used.
(recommended for Chipcon CC1010).
\layout Standard
-
-See also the compiler option
+\added_space_bottom bigskip
+See also the compiler options
\emph on
-
\begin_inset ERT
\end_inset
- and section
+,
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-main-return
+\emph default
+
+\begin_inset LatexCommand \index{-\/-main-return}
+
+\end_inset
+
+and section
\begin_inset LatexCommand \ref{sub:MCS51-variants}
\end_inset
HC08 Startup Code
\layout Standard
+\added_space_bottom bigskip
+The HC08
+\begin_inset LatexCommand \index{HC08}
+
+\end_inset
-The HC08 startup code follows the same scheme as the MCS51 startup code.
+ startup code follows the same scheme as the MCS51 startup code.
\layout Subsection
Z80 Startup Code
\layout Standard
+\added_space_bottom bigskip
+On the Z80
+\begin_inset LatexCommand \index{Z80}
-On the Z80 the startup code is inserted by linking with crt0.o which is generated
- from sdcc/device/lib/z80/crt0.s.
+\end_inset
+
+ the startup code is inserted by linking with crt0.o which is generated from
+ sdcc/device/lib/z80/crt0.s.
If you need a different startup code you can use the compiler option
\emph on
-
\family typewriter
\size footnotesize
-unsigned char far
+unsigned char __far
\begin_inset LatexCommand \index{far (storage class)}
\end_inset
\end_inset
- at
+ __at
\begin_inset LatexCommand \index{at}
\end_inset
\end_inset
- 0x7f00 buf[0x100];
+(0x7f00) buf[0x100];
\begin_inset LatexCommand \index{Aligned array}
\end_inset
\newline
-unsigned char head,tail;
+unsigned char head, tail;\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* if interrupts
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset
+
+ are involved see
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+section
+\begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
+
+\end_inset
+
+ about
+\series bold
+ volatile
+\series default
+ */
\newline
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-if( head != tail-1 )
+if( head != (unsigned char)(tail-1) )\SpecialChar ~
+/* cast
+\series bold
+needed
+\series default
+ to avoid promotion
+\begin_inset LatexCommand \index{promotion to signed int}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{type promotion}
+
+\end_inset
+
+ to integer */
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
/* access to a 256 byte aligned array */
\newline
}
\SpecialChar ~
r2,dpl
\newline
-;buffer.c if( head != tail-1 )
+;buffer.c if( head != (unsigned char)(tail-1) ) \SpecialChar ~
+/* cast
+\series bold
+needed
+\series default
+ to avoid promotion
+\begin_inset LatexCommand \index{promotion to signed int}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{type promotion}
+
+\end_inset
+
+ to integer */
\newline
\SpecialChar ~
\SpecialChar ~
\family typewriter
\size footnotesize
-unsigned char far at 0x7f00 buf[0x100];
+unsigned char __far __at(0x7f00) buf[0x100];
\newline
-unsigned char head,tail;
+unsigned char head, tail;
\newline
#define USE_ASSEMBLY (1)
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-if( head != tail-1 )
+if( head != (unsigned char)(tail-1) )
\newline
\SpecialChar ~
\SpecialChar ~
; If we were still using r2,r3 we would have to push them here.
\newline
-; if( head != tail-1 )
+; if( head != (unsigned char)(tail-1) )
\newline
\SpecialChar ~
\SpecialChar ~
\layout Standard
The inline assembler code can contain any valid code understood by the assembler
-, this includes any assembler directives and comment lines
-\begin_inset Foot
-collapsed false
-
-\layout Standard
-
-The assembler does not like some characters like ':' or ''' in comments.
+, this includes any assembler directives and comment lines.
+ The assembler does not like some characters like ':' or ''' in comments.
You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
\end_inset
+ or online at
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
\end_inset
+\SpecialChar ~
.
- The compiler does not do any validation of the code within the
+\layout Standard
+
+The compiler does not do any validation of the code within the
\family typewriter
_asm
\begin_inset LatexCommand \index{\_asm}
\newline
\newline
-void simpleInterrupt(void) interrupt
+void simpleInterrupt(void) __interrupt
\begin_inset LatexCommand \index{interrupt}
\end_inset
\end_inset
- 1
+ (1)
\newline
{
\newline
\newline
\newline
-void nakedInterrupt(void) interrupt 2 _naked
+void nakedInterrupt(void) __interrupt (2) __naked
\newline
{
\newline
\family typewriter
+Note, this is an
+\emph on
+outdated
+\emph default
+ example, recent versions of SDCC generate
+\newline
+the
+\emph on
+same
+\emph default
+ code for simpleInterrupt() and nakedInterrupt()!
+\newline
+
+\newline
_simpleInterrupt:
\newline
\SpecialChar ~
\SpecialChar ~
ret
\layout Standard
-
+\added_space_bottom bigskip
The compiling and linking procedure remains the same, however note the extra
entry & exit linkage required for the assembler code, _bp is the stack
frame pointer and is used to compute the offset into the stack for parameters
\begin_inset Tabular
<lyxtabular version="3" rows="11" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-SDCC supports IEEE (single precision 4 bytes) floating point numbers.The
- floating point support routines are derived from gcc's floatlib.c and consist
- of the following routines:
+SDCC supports IEEE (single precision 4 bytes) floating point numbers.
+ The floating point support routines are derived from gcc's floatlib.c and
+ consist of the following routines:
\newline
\layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="17" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\newline
\layout Standard
-
+\added_space_bottom bigskip
These support routines are developed in ANSI-C so there is room for space
and speed improvement
\begin_inset Foot
\layout Standard
-The floating point routines for the mcs51 are implemented in assembler
+These floating point routines (
+\emph on
+not
+\emph default
+ sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
+
\end_inset
.
routines.
SDCC does not know whether the system connects to a serial line with or
without handshake, LCD, keyboard or other device.
+ And whether a
+\family typewriter
+lf
+\family default
+ to
+\family typewriter
+crlf
+\family default
+ conversion within
+\family typewriter
+putchar()
+\family default
+ is intended.
You'll find examples for serial routines f.e.
in sdcc/device/lib.
\layout Standard
on the command line.
Use
\emph on
--
+ -
\begin_inset ERT
status Collapsed
\family default
- and
+ (subset of printf using less than 270 bytes) and
\family typewriter
printf_fast()
\begin_inset LatexCommand \index{printf\_fast() (mcs51)}
\end_inset
-
-\family default
-and
-\family typewriter
- printf_fast_f()
-\begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
+
+\family default
+and
+\family typewriter
+ printf_fast_f()
+\begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
+
+\end_inset
+
+
+\family default
+ (floating-point aware version of printf_fast) which should fit the requirements
+ of many embedded systems (printf_fast() can be customized by unsetting
+ #defines to
+\emph on
+not
+\emph default
+ support long variables and field widths).
+\layout Subsubsection
+
+<malloc.h>
+\begin_inset LatexCommand \index{malloc.h}
+
+\end_inset
+
+
+\layout Standard
+
+Before using dynamic
+\begin_inset LatexCommand \index{dynamic}
+
+\end_inset
+
+ memory allocation with SDCC, you have to provide heap
+\begin_inset LatexCommand \index{heap}
+
+\end_inset
+
+ space for malloc to allocate memory from
+\family typewriter
+.
+
+\family default
+You can acomplish this by including the following code into your source:
+\layout Verse
+
+
+\family typewriter
+#include <malloc.h>
+\begin_inset LatexCommand \index{malloc.h}
+
+\end_inset
+
+ /* calloc
+\begin_inset LatexCommand \index{calloc}
+
+\end_inset
+
+, malloc
+\begin_inset LatexCommand \index{malloc}
+
+\end_inset
+
+, realloc
+\begin_inset LatexCommand \index{realloc}
\end_inset
+, and free
+\begin_inset LatexCommand \index{free}
+
+\end_inset
+
+ */
+\newline
+
+\newline
+#define HEAPSIZE 0x1000 /* Adjust depending on available memory */
+\newline
+unsigned char xdata myheap[HEAPSIZE]; /* The actual heap for dynamic memory
+ */
+\newline
+
+\newline
+void main (void)
+\newline
+{
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* Your variable declarations come here*/
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+init_dynamic_memory((MEMHEADER xdata *)myheap, HEAPSIZE);
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+ /* Rest of your code*/
+\newline
+}
+\newline
-\family default
- which should fit the requirements of many embedded systems (printf_fast()
- can be customized by unsetting #defines to
-\emph on
-not
-\emph default
- support long variables and field widths).
\layout Subsection
-Math functions (sin, pow, sqrt etc.)
+Math functions (sinf, powf, sqrtf etc.)
+\layout Subsubsection
+
+<math.h>
+\layout Standard
+
+See definitions in file <math.h>.
\layout Subsection
Other libraries
\SpecialChar ~
would certainly like to hear about it.
- Programmers coding for embedded systems are not especially famous for being
+\layout Standard
+\added_space_bottom bigskip
+Programmers coding for embedded systems are not especially famous for being
enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
e these references are very valuable.
Let's help to create a climate where information is shared.
\layout Section
Pragmas
+\begin_inset LatexCommand \label{sec:Pragmas}
+
+\end_inset
+
+
\begin_inset LatexCommand \index{Pragmas}
\end_inset
SDCC supports the following #pragma directives:
\layout Itemize
+
+\series bold
save
+\series default
+
\begin_inset LatexCommand \index{\#pragma save}
\end_inset
- - this will save all current options to the save/restore stack.
+ - this will save most current options to the save/restore stack.
See #pragma\SpecialChar ~
restore.
\layout Itemize
+
+\series bold
restore
+\series default
+
\begin_inset LatexCommand \index{\#pragma restore}
\end_inset
\layout Itemize
+
+\series bold
callee_saves
+\series default
+
\begin_inset LatexCommand \index{\#pragma callee\_saves}
\end_inset
is appended to the list of functions specified in the command line.
\layout Itemize
+
+\series bold
exclude
+\series default
+
\begin_inset LatexCommand \index{\#pragma exclude}
\end_inset
.
\layout Itemize
+
+\series bold
less_pedantic
+\series default
+
\begin_inset LatexCommand \index{\#pragma less\_pedantic}
\end_inset
your own now ;-(
\layout Itemize
-disable_warning <nnnn>
+
+\series bold
+disable_warning
+\series default
+ <nnnn>
\begin_inset LatexCommand \index{\#pragma disable\_warning}
\end_inset
- the compiler will not warn you anymore about warning number <nnnn>.
\layout Itemize
+
+\series bold
nogcse
+\series default
+
\begin_inset LatexCommand \index{\#pragma nogcse}
\end_inset
- will stop global common subexpression elimination.
\layout Itemize
+
+\series bold
noinduction
+\series default
+
\begin_inset LatexCommand \index{\#pragma noinduction}
\end_inset
- will stop loop induction optimizations.
\layout Itemize
+
+\series bold
noinvariant
+\series default
+
\begin_inset LatexCommand \index{\#pragma noinvariant}
\end_inset
.
\layout Itemize
+
+\series bold
noiv
+\series default
+
\begin_inset LatexCommand \index{\#pragma noiv}
\end_inset
about interrupts.
\layout Itemize
+
+\series bold
nojtbound
+\series default
+
\begin_inset LatexCommand \index{\#pragma nojtbound}
\end_inset
.
\layout Itemize
+
+\series bold
noloopreverse
+\series default
+
\begin_inset LatexCommand \index{\#pragma noloopreverse}
\end_inset
- Will not do loop reversal optimization
\layout Itemize
+
+\series bold
nooverlay
+\series default
+
\begin_inset LatexCommand \index{\#pragma nooverlay}
\end_inset
function.
\layout Itemize
+
+\series bold
stackauto
+\series default
+
\begin_inset LatexCommand \index{\#pragma stackauto}
\end_inset
Parameters and Local Variables.
\layout Itemize
-opt_code_speed
+
+\series bold
+opt_code_speed
+\series default
+
\begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
\end_inset
- The compiler will optimize code generation towards fast code, possibly
at the expense of code size.
+ Currently this has little effect.
\layout Itemize
-opt_code_size
+
+\series bold
+opt_code_size
+\series default
+
\begin_inset LatexCommand \index{\#pragma opt\_code\_size}
\end_inset
- The compiler will optimize code generation towards compact code, possibly
at the expense of code speed.
+ Currently this has little effect.
\layout Itemize
-opt_code_balanced
+
+\series bold
+opt_code_balanced
+\series default
+
\begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
\end_inset
\layout Itemize
-std_sdcc89
+
+\series bold
+std_sdcc89
+\series default
+
\begin_inset LatexCommand \index{\#pragma std\_sdcc89}
\end_inset
with the standard (default).
\layout Itemize
-std_c89
+
+\series bold
+std_c89
+\series default
+
\begin_inset LatexCommand \index{\#pragma std\_c89}
\end_inset
standard.
\layout Itemize
-std_sdcc99
+
+\series bold
+std_sdcc99
+\series default
+
\begin_inset LatexCommand \index{\#pragma std\_sdcc99}
\end_inset
with the standard (incomplete support).
\layout Itemize
-std_c99
+
+\series bold
+std_c99
+\series default
+
\begin_inset LatexCommand \index{\#pragma std\_c99}
\end_inset
standard (incomplete support).
\layout Itemize
-codeseg <name>
+
+\series bold
+codeseg
+\series default
+ <name>
\begin_inset LatexCommand \index{\#pragma codeseg}
\end_inset
- Use this name (max.
8 characters) for the code segment.
+ See option -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-codeseg.
\layout Itemize
-constseg <name>
+
+\series bold
+constseg
+\series default
+ <name>
\begin_inset LatexCommand \index{\#pragma constseg}
\end_inset
- Use this name (max.
8 characters) for the const segment.
+ See option -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-constseg.
\layout Standard
-SDCPP supports the following #pragma directives:
+The preprocessor SDCPP
+\begin_inset LatexCommand \index{sdcpp (preprocessor)}
+
+\end_inset
+
+ supports the following #pragma directives:
\layout Itemize
+
+\series bold
preproc_asm
+\series default
+
\begin_inset LatexCommand \index{\#pragma preproc\_asm}
\end_inset
(+ | -) - switch _asm _endasm block preprocessing on / off.
Default is on.
+ You use this prama to define multilines of assembly code.
+ This will prevent the preprocessor from changing the formating required
+ by assembly code.
+ Below is an example on how to use this pragma.
+\layout Verse
+
+
+\family typewriter
+#pragma preproc_asm -
+\begin_inset LatexCommand \index{\#pragma preproc\_asm}
+
+\end_inset
+
+
+\newline
+#define MYDELAY _asm
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+nop ;my assembly comment...
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+nop
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+nop
+\newline
+_endasm
+\newline
+#pragma preproc_asm +
+\newline
+
+\newline
+void foo (void)
+\newline
+{
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ ...
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ MYDELAY;
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ ...
+
+\newline
+}
+\newline
+
\layout Standard
The pragma's are intended to be used to turn-on or off certain optimizations
The compiler will generate a warning message when extra space is allocated.
It is strongly recommended that the save and restore pragma's be used when
changing options for a function.
+\newline
+
+\newline
+
+\newline
+
\layout Section
Defines Created by the Compiler
\begin_inset Tabular
<lyxtabular version="3" rows="11" columns="2">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="3in">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-this Symbol is always defined
+Always defined.
+ Since version 2.5.6 the version number as an int (ex.
+ 256)
\end_inset
</cell>
</row>
\end_inset
-, etc
+, etc.
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-depending on the model used (e.g.: -mds390
+depending on the model used (e.g.: -mds390)
\end_inset
</cell>
</row>
\family typewriter
-sfr at 0x92 _XPAGE; /* Cypress EZ-USB family */
+__sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family */
\layout Verse
\family typewriter
-sfr at 0xaf _XPAGE; /* some Silicon Labs (Cygnal) chips */
+__sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips */
\layout Verse
\family typewriter
-sfr at 0xaa _XPAGE; /* some Silicon Labs (Cygnal) chips */
+__sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips */
\layout Standard
For more exotic implementations further customizations may be needed.
Other Features available by SFR
\layout Standard
-
+\added_space_bottom bigskip
Some MCS51 variants offer features like Double DPTR
\begin_inset LatexCommand \index{DPTR}
DS400 port
\layout Standard
+\added_space_bottom bigskip
+The DS80C400
+\begin_inset LatexCommand \index{DS80C400}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{DS400}
+
+\end_inset
-The DS80C400 microcontroller has a rich set of peripherals.
+ microcontroller has a rich set of peripherals.
In its built-in ROM library it includes functions to access some of the
features, among them is a TCP stack with IP4 and IP6 support.
Library headers (currently in beta status) and other files are provided
The Z80 and gbz80 port
\layout Standard
-SDCC can target both the Zilog
+SDCC can target both the Zilog Z80
\begin_inset LatexCommand \index{Z80}
\end_inset
variables and bitfield support is fine.
See mailing lists and forums about interrupt routines.
\layout Standard
-
+\added_space_bottom bigskip
As always, the code is the authoritative reference - see z80/ralloc.c and
z80/gen.c.
The stack
-\begin_inset LatexCommand \index{stack}
+\begin_inset LatexCommand \index{Z80!stack}
\end_inset
IX is used as the base pointer, HL and IY are used as a temporary registers,
and BC and DE are available for holding variables.
Return values
-\begin_inset LatexCommand \index{return value}
+\begin_inset LatexCommand \index{Z80!return value}
\end_inset
The HC08 port
\layout Standard
-
+\added_space_bottom bigskip
The port to the Motorola HC08
\begin_inset LatexCommand \index{HC08}
unoptimized.
Some of the SDCC's standard C library functions have embedded non-HC08
inline assembly and so are not yet usable.
-\newline
-
-\newline
-
\layout Section
-
+\pagebreak_top
The PIC14 port
\layout Standard
Creating a device include file
\layout Standard
-For generating a device include file use the support perl script inc2h.pl
- kept in directory support/script.
+For generating a device include file
+\begin_inset LatexCommand \index{PIC14!Header files}
+
+\end_inset
+
+ use the support perl script inc2h.pl kept in directory support/script.
\layout Subsection
Interrupt code
\layout Standard
For the interrupt function, use the keyword 'interrupt'
-\begin_inset LatexCommand \index{interrupt}
+\begin_inset LatexCommand \index{PIC14!interrupt}
\end_inset
/
\end_inset
--debug-extra emit debug info in assembly output
+-debug-extra
+\begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
+
+\end_inset
+
+ emit debug info in assembly output
\layout List
\labelwidthstring 00.00.0000
/
\end_inset
--no-pcode-opt disable (slightly faulty) optimization on pCode
+-no-pcode-opt
+\begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
+
+\end_inset
+
+ disable (slightly faulty) optimization on pCode
\layout Subsection
The library
\layout Standard
This warning can usually be ignored due to the very good compatibility amongst
- 14 bit PIC devices.
+ 14 bit PIC
+\begin_inset LatexCommand \index{PIC14}
+
+\end_inset
+
+ devices.
\layout Standard
You might also consider recompiling the library for your specific device
not
\series default
be initialized.
-\layout Section
+\family typewriter
+\size footnotesize
+
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+\layout Section
+\pagebreak_top
The PIC16
\begin_inset LatexCommand \index{PIC16}
/
\end_inset
--callee-saves See -
+-callee-saves
+\begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
+
+\end_inset
+
+ See -
\begin_inset ERT
status Collapsed
/
\end_inset
--all-callee-saves All function arguments are passed on stack by default.
+-all-callee-saves
+\begin_inset LatexCommand \index{PIC16!Options!-\/-all-callee-saves}
+
+\end_inset
+
+ All function arguments are passed on stack by default.
\emph on
There is no need to specify this in the command line.
/
\end_inset
--fommit-frame-pointer Frame pointer will be omitted when the function uses
- no local variables.
+-fommit-frame-pointer
+\begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
+
+\end_inset
+
+ Frame pointer will be omitted when the function uses no local variables.
\layout Subsection
Port Specific Options
/
\end_inset
--mplab-comp MPLAB compatibility option.
+-mplab-comp MPLAB
+\begin_inset LatexCommand \index{PIC16!MPLAB}
+
+\end_inset
+
+ compatibility option.
Currently only suppresses special gpasm directives.
\layout Subsubsection
Preprocessor Macros
\layout Standard
-PIC16 port defines the following preprocessor macros while translating a
- source.
+PIC16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset
+
+ port defines the following preprocessor macros while translating a source.
\layout Standard
\align center
\layout Standard
-PIC16 port currently supports the following pragmas:
+PIC16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset
+
+ port currently supports the following pragmas:
\layout List
\labelwidthstring 00.00.0000
-stack pragma stack forces the code generator to initialize the stack & frame
- pointers at a specific address.
+stack
+\begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
+
+\end_inset
+
+ pragma stack
+\begin_inset LatexCommand \index{PIC16!stack}
+
+\end_inset
+
+ forces the code generator to initialize the stack & frame pointers at a
+ specific address.
This is an adhoc solution for cases where no STACK directive is available
in the linker script or gplink is not instructed to create a stack section.
\newline
\layout List
\labelwidthstring 00.00.0000
-code place a function symbol at static FLASH address
+code
+\begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
+
+\end_inset
+
+ place a function symbol at static FLASH address
\layout LyX-Code
Example:
\layout Standard
-There is one main header file that can be included to the source files using
- the pic16 port.
+There is one main header file
+\begin_inset LatexCommand \index{PIC16!Header files}
+
+\end_inset
+
+ that can be included to the source files using the pic16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset
+
+ port.
That file is the
\series bold
pic18fregs.h
Libraries
\layout Standard
-The libraries that PIC16
+The libraries
+\begin_inset LatexCommand \index{PIC16!Libraries}
+
+\end_inset
+
+ that PIC16
\begin_inset LatexCommand \index{PIC16}
\end_inset
Stack
\layout Standard
-The stack implementation for the PIC16 port uses two indirect registers,
- FSR1 and FSR2.
+The stack
+\begin_inset LatexCommand \index{PIC16!stack}
+
+\end_inset
+
+ implementation for the PIC16 port uses two indirect registers, FSR1 and
+ FSR2.
\layout List
\labelwidthstring 00.00.0000
Functions
\layout Standard
-In addition to the standard SDCC function keywords, PIC16 port makes available
- two more:
+In addition to the standard SDCC function keywords, PIC16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset
+
+ port makes available two more:
\layout List
\labelwidthstring 00.00.0000
-wparam Use the WREG to pass one byte of the first function argument.
+wparam
+\begin_inset LatexCommand \index{PIC16!wparam}
+
+\end_inset
+
+ Use the WREG to pass one byte of the first function argument.
This improves speed but you may not use this for functions with arguments
that are called via function pointers, otherwise the first byte of the
first parameter will get lost.
\layout List
\labelwidthstring 00.00.0000
-shadowregs When entering/exiting an ISR, it is possible to take advantage
- of the PIC18F hardware shadow registers which hold the values of WREG,
- STATUS and BSR registers.
+shadowregs
+\begin_inset LatexCommand \index{PIC16!shadowregs}
+
+\end_inset
+
+ When entering/exiting an ISR, it is possible to take advantage of the PIC18F
+ hardware shadow registers which hold the values of WREG, STATUS and BSR
+ registers.
This can be done by adding the keyword
\emph on
shadowregs
Interrupts
\layout Standard
-An interrupt servive routine (ISR) is declared using the
+An interrupt
+\begin_inset LatexCommand \index{PIC16!interrupt}
+
+\end_inset
+
+ service routine (ISR) is declared using the
\emph on
interrupt
\emph default
\layout Standard
-descrption
+description
\end_inset
</cell>
</row>
{
\layout LyX-Code
- stdout = STREAM_USER; /* this is not necessery, since stdout points
+ stdout = STREAM_USER; /* this is not necessary, since stdout points
\layout LyX-Code
* by default to STREAM_USER */
Stack size
\layout Standard
-The default stack size (that is 64 bytes) probably is enough for many programs.
+The default stack
+\begin_inset LatexCommand \index{PIC16!stack}
+
+\end_inset
+
+ size (that is 64 bytes) probably is enough for many programs.
One must take care that when there are many levels of function nesting,
or there is excessive usage of stack, its size should be extended.
An example of such a case is the printf/sprintf family of functions.
Other ways to reduce stack usage may exist.
\layout Chapter
+Debugging
+\layout Standard
+
+There are several approaches to debugging your code.
+ This chapter is meant to show your options and to give detail on some of
+ them:
+\newline
+
+\newline
+When writing your code:
+\layout Itemize
+
+write your code with debugging in mind (avoid duplicating code, put conceptually
+ similar variables into structs, use structured code, have strategic points
+ within your code where all variables are consistent, ...)
+\layout Itemize
+
+run a syntax-checking tool like splint
+\begin_inset LatexCommand \index{splint (syntax checking tool)}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{lint (syntax checking tool)}
+
+\end_inset
+
+ (see -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-more-pedantic
+\begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
+
+\end_inset
+
+) over the code.
+\layout Itemize
+
+for the high level code use a C-compiler (like f.e.
+ GCC) to compile run and debug the code on your host.
+ See (see -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-more-pedantic
+\begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
+
+\end_inset
+
+ ) on howto handle syntax extensions like __xdata, __at(), ...
+
+\layout Itemize
+
+use another C-compiler to compile code for your target.
+ Always an option but not recommended:) And not very likely to help you.
+ If you seriously consider walking this path you should at least occasionally
+ check portability of your code.
+ Most commercial compiler vendors will offer an evaluation version so you
+ can test compile your code or snippets of your code.
+\layout Standard
+
+Debugging on a simulator:
+\layout Itemize
+
+there is a separate section about SDCDB (section
+\begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
+
+\end_inset
+
+) below.
+\layout Itemize
+
+or (8051 specific) use a freeware/commercial simulator which interfaces
+ to the AOMF
+\begin_inset LatexCommand \index{AOMF, AOMF51}
+
+\end_inset
+
+ file (see
+\begin_inset LatexCommand \ref{OMF file}
+
+\end_inset
+
+) optionally generated by SDCC.
+\layout Standard
+
+Debugging On-target:
+\layout Itemize
+
+use a MCU port pin to serially output debug data to the RS232 port of your
+ host.
+ You'll probably want some level shifting device typically involving a MAX232
+ or similar IC.
+ If the hardware serial port of the MCU is not available search for 'Software
+ UART' in your favourite search machine.
+\layout Itemize
+
+use an on-target monitor.
+ In this context a monitor is a small program which usually accepts commands
+ via a serial line and allows to set program counter, to single step through
+ a program and read/write memory locations.
+ For the 8051 good examples of monitors are paulmon and cmon51 (see section
+
+\begin_inset LatexCommand \ref{sec:Related-open-source-tools}
+
+\end_inset
+
+).
+\layout Itemize
+
+toggle MCU port pins at strategic points within your code and use an oscilloscop
+e.
+ A
+\emph on
+digital oscilloscope
+\emph default
+
+\begin_inset LatexCommand \index{Oscilloscope}
+
+\end_inset
+
+ with deep trace memory is really helpful especially if you have to debug
+ a realtime application.
+ If you need to monitor more pins than your oscilloscope provides you can
+ sometimes get away with a small R-2R network.
+ On a single channel oscilloscope you could f.e.
+ monitor 2 push-pull driven pins by connecting one via a 10\SpecialChar ~
+k
+\begin_inset Formula $\Omega$
+\end_inset
+
+ resistor and the other one by a 5\SpecialChar ~
+k
+\begin_inset Formula $\Omega$
+\end_inset
+
+ resistor to the oscilloscope probe (check output drive capability of the
+ pins you want to monitor).
+ If you need to monitor many more pins a
+\emph on
+logic analyzer
+\emph default
+ will be handy.
+\layout Itemize
+
+use an ICE (
+\emph on
+i
+\emph default
+n
+\emph on
+c
+\emph default
+ircuit
+\emph on
+e
+\emph default
+mulator
+\begin_inset LatexCommand \index{ICE (in circuit emulator)}
+
+\end_inset
+
+).
+ Usually very expensive.
+ And very nice to have too.
+ And usually locks you (for years...) to the devices the ICE can emulate.
+
+\layout Itemize
+
+use a remote debugger.
+ In most 8-bit systems the symbol information is not available on the target,
+ and a complete debugger is too bulky for the target system.
+ Therefore usually a debugger on the host system connects to an on-target
+ debugging stub which accepts only primitive commands.
+
+\newline
+Terms to enter into your favourite search engine could be 'remote debugging',
+ 'gdb stub' or 'inferior debugger'.
+ (is there one?)
+\layout Itemize
+
+use an on target hardware debugger.
+ Some of the more modern MCUs include hardware support for setting break
+ points and monitoring/changing variables by using dedicated hardware pins.
+ This facility doesn't require additional code to run on the target and
+
+\emph on
+usually
+\emph default
+ doesn't affect runtime behaviour until a breakpoint is hit.
+ For the mcs51 most hardware debuggers use the AOMF
+\begin_inset LatexCommand \index{AOMF, AOMF51}
+
+\end_inset
+
+ file (see
+\begin_inset LatexCommand \ref{OMF file}
+
+\end_inset
+
+) as input file.
+
+\layout Standard
+
+Last not least:
+\layout Itemize
+
+if you are not familiar with any of the following terms you're likely to
+ run into problems rather sooner than later:
+\emph on
+volatile
+\emph default
+,
+\emph on
+atomic
+\emph default
+,
+\emph on
+memory map
+\emph default
+,
+\emph on
+overlay
+\emph default
+.
+ As an embedded programmer you
+\emph on
+have
+\emph default
+ to know them so why not look them up
+\emph on
+before
+\emph default
+ you have problems?)
+\layout Itemize
+
+tell someone else about your problem (actually this is a surprisingly effective
+ means to hunt down the bug even if the listener is not familiar with your
+ environment).
+ As 'failure to communicate' is probably one of the job-induced deformations
+ of an embedded programmer this is highly encouraged.
+\layout Section
+
Debugging with SDCDB
\begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
\end_inset
-\begin_inset LatexCommand \index{sdcdb (debugger)}
+\begin_inset LatexCommand \index{SDCDB (debugger)}
\end_inset
specified during configuration.
The debugger allows you debug BOTH at the C source and at the ASM source
level.
- Sdcdb is currently not available on Win32 platforms.
-\layout Section
+\layout Subsection
Compiling for Debugging
\layout Standard
option must be specified for all files for which debug information is to
be generated.
- The complier generates a .adb file for each of these files.
+ The compiler generates a .adb file for each of these files.
The linker creates the .cdb
\begin_inset LatexCommand \index{<file>.cdb}
files and the address information.
This .cdb is used by the debugger.
-\layout Section
+\layout Subsection
How the Debugger Works
\layout Standard
-debug option is specified the compiler generates extra symbol information
some of which are put into the assembler source and some are put into the
.adb file.
- Then the linker creates the .cdb file from the individual .adb files with
+ Then the linker creates the .cdb file from the individual .adb files with
the address information for the symbols.
The debugger reads the symbolic information generated by the compiler &
the address information generated by the linker.
execution is controlled by the debugger.
When a command is issued for the debugger, it translates it into appropriate
commands for the simulator.
-\layout Section
+ (Currently SDCDM only connects to the simulator but
+\emph on
+newcdb
+\emph default
+ at
+\begin_inset LatexCommand \url{http://ec2drv.sf.net/}
+
+\end_inset
+
+ is an effort to connect directly to the hardware.)
+\layout Subsection
-Starting the Debugger
+Starting the Debugger SDCDB
\layout Standard
The debugger can be started using the following command line.
\end_inset
object file.
-\layout Section
+\layout Subsection
-Command Line Options
+SDCDB Command Line Options
\layout Itemize
-
\layout Itemize
-k <port number> passed to simulator see the simulator docs for details.
-\layout Section
+\layout Subsection
-Debugger Commands
+SDCDB Debugger Commands
\layout Standard
As mentioned earlier the command interface for the debugger has been deliberatel
"Watch me now.
Iam going Down.
My name is Bobby Brown"
-\layout Section
+\layout Subsection
-Interfacing with DDD
+Interfacing SDCDB with DDD
\layout Comment
The screenshot was converted from png to eps with:
\layout Comment
The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
- as this broke the build system on Sourceforge (pdf-file was broken).
+ as this broke the build system on Sourceforge (pdf-file was broken.
+ pdflatex does not accept eps files).
\layout Standard
-The .eps File
+The
+\emph on
+p
+\emph default
+ortable
+\emph on
+n
+\emph default
+etwork
+\emph on
+g
+\emph default
+raphics File
\size footnotesize
-\begin_inset LatexCommand \url{http://cvs.sourceforge.net/viewcvs.py/*checkout*/sdcc/sdcc/doc/figures/ddd_example.eps}
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
\end_inset
\newline
ddd -debugger 'sdcdb -cpu 8032 ddd_example'
-\layout Section
+\layout Subsection
-Interfacing with XEmacs
+Interfacing SDCDB with XEmacs
\begin_inset LatexCommand \index{XEmacs}
\end_inset
If it is known in advance that the value is going to be less than 256 then
use an 'unsigned char' instead of a 'short' or 'int'.
Please note, that ANSI C requires both signed and unsigned chars to be
- promoted to 'signed int' before doing any operation.
+ promoted to 'signed int'
+\begin_inset LatexCommand \index{promotion to signed int}
+
+\end_inset
+
+
+\begin_inset Marginal
+collapsed true
+
+\layout Standard
+
+
+\series bold
+\SpecialChar ~
+!
+\end_inset
+
+ before doing any operation.
This promotion
\begin_inset LatexCommand \index{type promotion}
+\end_inset
+
+
+\begin_inset LatexCommand \label{type promotion}
+
\end_inset
can be omitted, if the result is the same.
:
\layout Quote
+
+\emph on
If well-defined overflow characteristics are important and negative values
are not, or if you want to steer clear of sign-extension problems when
manipulating bits or bytes, use one of the corresponding unsigned types.
for the code generation.
\layout Section
+Porting code from or to other compilers
+\begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
+
+\end_inset
+
+
+\layout Itemize
+
+check whether endianness of the compilers differs and adapt where needed.
+\layout Itemize
+
+check the device specific header files
+\begin_inset LatexCommand \index{Header files}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{Include files}
+
+\end_inset
+
+ for compiler specific syntax.
+ Eventually include the file <compiler.h
+\begin_inset LatexCommand \index{compiler.h (include file)}
+
+\end_inset
+
+> to allow using common header files.
+ (see f.e.
+ cc2510fx.h
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/P89c51RD2.h?view=markup}
+
+\end_inset
+
+).
+\layout Itemize
+
+check whether the startup code contains the correct initialization (watchdog,
+ peripherals).
+\layout Itemize
+
+check whether the sizes of short, int, long match.
+\layout Itemize
+
+check if some 16 or 32 bit hardware registers require a specific addressing
+ order (least significant or most significant byte first) and adapt if needed
+ (
+\emph on
+first
+\emph default
+ and
+\emph on
+last
+\emph default
+ relate to time and not to lower/upper memory location here, so this is
+
+\emph on
+not
+\emph default
+ the same as endianness).
+\layout Itemize
+
+check whether the keyword
+\emph on
+volatile
+\emph default
+ is used where needed.
+ The compilers might differ in their optimization characteristics (as different
+ versions of the same compiler might also use more clever optimizations
+ this is good idea anyway).
+ See section
+\begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
+
+\end_inset
+
+.
+\layout Itemize
+
+check that the compilers are not told to supress warnings.
+\layout Itemize
+
+check and convert compiler specific extensions (interrupts, memory areas,
+ pragmas etc.).
+\layout Itemize
+
+check for differences in type promotion.
+ Especially check for math operations on
+\family typewriter
+char
+\family default
+ or
+\family typewriter
+unsigned char
+\family default
+ variables.
+ For the sake of C99 compatibility SDCC will probably promote these to
+\family typewriter
+int
+\family default
+ more often than other compilers.
+ Eventually insert explicit casts to
+\family typewriter
+(char)
+\family default
+or
+\family typewriter
+ (unsigned char)
+\family default
+.
+ Also check that the ~\SpecialChar ~
+operator
+\begin_inset LatexCommand \index{\~\/ Operator}
+
+\end_inset
+
+ is not used on
+\family typewriter
+bit
+\begin_inset LatexCommand \index{bit}
+
+\end_inset
+
+
+\family default
+ variables, use the !\SpecialChar ~
+operator instead.
+ See sections
+\begin_inset LatexCommand \ref{type promotion}
+
+\end_inset
+
+ and
+\begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
+
+\end_inset
+
+.
+\layout Itemize
+
+check the assembly code generated for interrupt routines (f.e.
+ for calls to possibly non-reentrant library functions).
+\layout Itemize
+
+check whether timing loops result in proper timing (or preferably consider
+ a rewrite of the code with timer based delays instead).
+\layout Itemize
+
+check for differences in printf parameters (some compilers push (va_arg
+\begin_inset LatexCommand \index{vararg, va\_arg}
+
+\end_inset
+
+) char variables as
+\family typewriter
+int
+\family default
+ others push them as
+\family typewriter
+char
+\family default
+.
+ See section
+\begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
+
+\end_inset
+
+).
+\layout Itemize
+
+check the resulting memory map
+\begin_inset LatexCommand \index{Memory map}
+
+\end_inset
+
+.
+ Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
+ly idata, pdata, xdata).
+ Eventually check if unexpected library functions are included.
+\layout Section
+
Tools
\begin_inset LatexCommand \index{Tools}
included in the distribution
\layout Standard
-\align center
+\align left
\begin_inset Tabular
<lyxtabular version="3" rows="12" columns="3">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0pt">
-<column alignment="center" valignment="top" leftline="true" width="0pt">
+<column alignment="left" valignment="top" leftline="true" width="0pt">
+<column alignment="left" valignment="top" leftline="true" width="0pt">
<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Name
+Name
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Purpose
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Directory
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ucSsim
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Simulator for various architectures
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+sdcc/sim/ucsim
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+keil2sdcc.pl
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+header file
+\begin_inset LatexCommand \index{Header files}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{Include files}
+
+\end_inset
+
+ conversion
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+sdcc/support/scripts
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+mh2h.c
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+header file conversion
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+sdcc/support/scripts
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+as-gbz80
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Purpose
+Assembler
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-Directory
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
\end_inset
</cell>
</row>
\layout Standard
-uCsim
+as-z80
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Simulator for various architectures
+Assembler
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-sdcc/sim/ucsim
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
\end_inset
</cell>
</row>
\layout Standard
-keil2sdcc.pl
+asx8051
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-header file conversion
+Assembler
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-sdcc/support/scripts
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
\end_inset
</cell>
</row>
\layout Standard
-mh2h.c
+SDCDB
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-header file conversion
+Simulator
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-sdcc/support/scripts
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
\end_inset
</cell>
</row>
\layout Standard
-as-gbz80
+aslink
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Assembler
+Linker
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-as-z80
+link-z80
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Assembler
+Linker
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-asx8051
+link-gbz80
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Assembler
+Linker
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\end_inset
</cell>
</row>
-<row topline="true">
+<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-sdcdb
+packihx
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Simulator
+Intel Hex packer
+\begin_inset LatexCommand \index{packihx (tool)}
+
+\end_inset
+
+
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\end_inset
</cell>
</row>
-<row topline="true">
+</lyxtabular>
+
+\end_inset
+
+
+\newline
+
+\layout Section
+
+Documentation
+\begin_inset LatexCommand \index{Documentation}
+
+\end_inset
+
+ included in the distribution
+\layout Standard
+\align left
+
+\begin_inset Tabular
+<lyxtabular version="3" rows="10" columns="2">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
+<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-aslink
+Subject / Title
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Where to get / filename
\end_inset
</cell>
+</row>
+<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Linker
+SDCC Compiler User Guide
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
+You're reading it right now
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
-\family roman
-\series medium
-\shape up
-\size normal
-\emph off
-\bar no
-\noun off
-\color none
-sdcc/bin
+\layout Standard
+
+Changelog of SDCC
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+sdcc/Changelog
\end_inset
</cell>
</row>
\layout Standard
-link-z80
+ASXXXX
+\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{Assembler documentation}
+
+\end_inset
+
+ Assemblers and ASLINK
+\begin_inset LatexCommand \index{aslink}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{Linker documentation}
+
+\end_inset
+
+ Relocating Linker
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+sdcc/as/doc/asxhtm.html
\end_inset
</cell>
+</row>
+<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Linker
+SDCC regression test
+\begin_inset LatexCommand \index{Regression test}
+
+\end_inset
+
+
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
+sdcc/doc/test_suite_spec.pdf
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Various notes
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
-\family roman
-\series medium
-\shape up
-\size normal
-\emph off
-\bar no
-\noun off
-\color none
-sdcc/bin
+\layout Standard
+
+sdcc/doc/*
\end_inset
</cell>
</row>
\layout Standard
-link-gbz80
+Notes on debugging with SDCDB
+\begin_inset LatexCommand \index{SDCDB (debugger)}
+
+\end_inset
+
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+sdcc/debugger/README
\end_inset
</cell>
+</row>
+<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Linker
+Software simulator for microcontrollers
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\family roman
-\series medium
-\shape up
-\size normal
-\emph off
-\bar no
-\noun off
-\color none
-sdcc/bin
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/sim/ucsim/doc
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color default
+/index.html
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Temporary notes on the pic16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset
+
+ port
\end_inset
</cell>
-</row>
-<row topline="true" bottomline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
-packihx
+sdcc/src/pic16/NOTES
\end_inset
</cell>
+</row>
+<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-ihx packer
+SDCC internal documentation (debugging file format)
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-
+sdcc/doc/
\family roman
\series medium
\shape up
\bar no
\noun off
\color none
-sdcc/bin
+cdbfileformat.pd
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color default
+f
\end_inset
</cell>
</row>
\layout Section
-Documentation
-\begin_inset LatexCommand \index{Documentation}
+Related open source tools
+\begin_inset LatexCommand \label{sec:Related-open-source-tools}
\end_inset
- included in the distribution
+
+\begin_inset LatexCommand \index{Related tools}
+
+\end_inset
+
+
\layout Standard
-\align center
+\align left
\begin_inset Tabular
-<lyxtabular version="3" rows="10" columns="2">
+<lyxtabular version="3" rows="14" columns="3">
<features>
-<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0pt">
+<column alignment="block" valignment="top" leftline="true" width="30line%">
<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Subject / Title
+Name
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Purpose
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-Where to get / filename
+Where to get
\end_inset
</cell>
</row>
\layout Standard
-SDCC Compiler User Guide
+gpsim
+\begin_inset LatexCommand \index{gpsim (pic simulator)}
+
\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-\layout Standard
-You're reading it right now
\end_inset
</cell>
-</row>
-<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Changelog of SDCC
+PIC simulator
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-sdcc/Changelog
+
+\begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-ASXXXX
-\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
+gputils
+\begin_inset LatexCommand \index{gputils (pic tools)}
\end_inset
-\begin_inset LatexCommand \index{Assembler documentation}
-
\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
- Assemblers and ASLINK
-\begin_inset LatexCommand \index{aslink}
+\layout Standard
+GNU PIC utilities
\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+\layout Standard
-\begin_inset LatexCommand \index{Linker documentation}
-\end_inset
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
- Relocating Linker
\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-\layout Standard
-sdcc/as/doc/asxhtm.html
\end_inset
</cell>
</row>
\layout Standard
-SDCC regression test
-\begin_inset LatexCommand \index{Regression test}
-
+flP5
\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+\layout Standard
+PIC programmer
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-sdcc/doc/test_suite_spec.pdf
+
+\begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-Various notes
+ec2drv/newcdb
\end_inset
</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-sdcc/doc/*
+Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
+ (Unix only)
\end_inset
</cell>
-</row>
-<row topline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
-Notes on debugging with sdcdb
-\begin_inset LatexCommand \index{sdcdb (debugger)}
+
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
\end_inset
\end_inset
</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-sdcc/debugger/README
+indent
+\begin_inset LatexCommand \index{indent (source formatting tool)}
+
+\end_inset
+
+
\end_inset
</cell>
-</row>
-<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Software simulator for microcontrollers
+Formats C source - Master of the white spaces
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\family roman
-\series medium
-\shape up
-\size normal
-\emph off
-\bar no
-\noun off
-\color none
-sdcc/sim/ucsim/doc
-\family default
-\series default
-\shape default
-\size default
-\emph default
-\bar default
-\noun default
-\color default
-/index.html
+\begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-Temporary notes on the pic16
-\begin_inset LatexCommand \index{PIC16}
-
-\end_inset
+srecord
+\begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
- port
\end_inset
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-\layout Standard
-sdcc/src/pic16/NOTES
\end_inset
</cell>
-</row>
-<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-SDCC internal documentation (debugging file format)
+Object file conversion, checksumming, ...
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-sdcc/doc/
-\family roman
-\series medium
-\shape up
-\size normal
-\emph off
-\bar no
-\noun off
-\color none
-cdbfileformat.pd
-\family default
-\series default
-\shape default
-\size default
-\emph default
-\bar default
-\noun default
-\color default
-f
+
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
+
\end_inset
-</cell>
-</row>
-</lyxtabular>
+
\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+\layout Standard
-\newline
+objdump
+\begin_inset LatexCommand \index{objdump (tool)}
-\layout Section
+\end_inset
-Related open source tools
-\begin_inset LatexCommand \index{Related tools}
\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+Object file conversion, ...
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
\layout Standard
-\align center
-\begin_inset Tabular
-<lyxtabular version="3" rows="11" columns="3">
-<features>
-<column alignment="center" valignment="top" leftline="true" width="0pt">
-<column alignment="block" valignment="top" leftline="true" width="30line%">
-<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
-<row topline="true" bottomline="true">
+Part of binutils (should be there anyway)
+\end_inset
+</cell>
+</row>
+<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Name
+cmon51
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Purpose
+8051 monitor (hex up-/download, single step, disassemble)
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-Where to get
+
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-gpsim
-\begin_inset LatexCommand \index{gpsim (pic simulator)}
+doxygen
+\begin_inset LatexCommand \index{doxygen (source documentation tool)}
\end_inset
\layout Standard
-PIC simulator
+Source code documentation system
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
+\begin_inset LatexCommand \url{http://www.doxygen.org}
\end_inset
\layout Standard
-gputils
-\begin_inset LatexCommand \index{gputils (pic tools)}
-
-\end_inset
-
-
+kdevelop
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-GNU PIC utilities
+IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
+\begin_inset LatexCommand \url{http://www.kdevelop.org}
\end_inset
\layout Standard
-flP5
+paulmon
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-PIC programmer
+8051 monitor (hex up-/download, single step, disassemble)
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
+\begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
\end_inset
\layout Standard
-indent
-\begin_inset LatexCommand \index{indent (source formatting tool)}
+splint
+\begin_inset LatexCommand \index{splint (syntax checking tool)}
\end_inset
\layout Standard
-Formats C source - Master of the white spaces
+Statically checks c sources (see
+\begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
+
+\end_inset
+
+)
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
+\begin_inset LatexCommand \url{http://www.splint.org}
\end_inset
\end_inset
</cell>
</row>
-<row topline="true">
+<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-srecord
-\begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
+ddd
+\begin_inset LatexCommand \index{ddd (debugger)}
\end_inset
\layout Standard
-Object file conversion, checksumming, ...
+Debugger, serves nicely as GUI to SDCDB
+\begin_inset LatexCommand \index{SDCDB (debugger)}
+
+\end_inset
+
+ (Unix only)
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
+\begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
\end_inset
\end_inset
</cell>
</row>
-<row topline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
+</lyxtabular>
-\layout Standard
+\end_inset
-objdump
-\begin_inset LatexCommand \index{objdump (tool)}
-\end_inset
+\newline
+
+\layout Section
+
+Related documentation / recommended reading
+\layout Standard
+\align left
+
+\begin_inset Tabular
+<lyxtabular version="3" rows="8" columns="3">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0pt">
+<column alignment="block" valignment="top" leftline="true" width="30line%">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+\layout Standard
+Name
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Object file conversion, ...
+Subject / Title
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-Part of binutils (should be there anyway)
+Where to get
\end_inset
</cell>
</row>
\layout Standard
-doxygen
-\begin_inset LatexCommand \index{doxygen (source documentation tool)}
-
-\end_inset
-
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+c-refcard.pdf
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Source code documentation system
+C Reference Card
+\begin_inset LatexCommand \index{C Reference card}
+
+\end_inset
+
+, 2 pages
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://www.doxygen.org}
+\begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
\end_inset
\layout Standard
-kdevelop
+c-faq
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-IDE (has anyone tried integrating SDCC & sdcdb? Unix only)
+C-FAQ-list
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://www.kdevelop.org}
+\begin_inset LatexCommand \url{http://www.eskimo.com/~scs/C-faq/top.html}
\end_inset
\layout Standard
-splint
-\begin_inset LatexCommand \index{splint (syntax checking tool)}
+ISO/IEC 9899:TC2
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset Quotes sld
+\end_inset
+
+C-Standard
+\begin_inset Quotes srd
+\end_inset
+
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
\end_inset
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ISO/IEC DTR 18037
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Statically checks c sources (see
-\begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
+\begin_inset Quotes sld
\end_inset
-)
+Extensions for Embedded C
+\begin_inset Quotes srd
+\end_inset
+
+
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://www.splint.org}
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
\end_inset
\end_inset
</cell>
</row>
-<row topline="true" bottomline="true">
+<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-ddd
-\begin_inset LatexCommand \index{ddd (debugger)}
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+Latest datasheet of the target CPU
\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+\layout Standard
+vendor
\end_inset
</cell>
+</row>
+<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Debugger, serves nicely as GUI to sdcdb
-\begin_inset LatexCommand \index{sdcdb (debugger)}
-
\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
- (Unix only)
+\layout Standard
+
+Revision history of datasheet
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
+vendor
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
-\begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
+S.
+ S.
+ Muchnick
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+\layout Standard
+
+Advanced Compiler Design and Implementation
\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+\layout Standard
+bookstore (very dedicated, probably read other books first)
\end_inset
</cell>
</row>
\layout Section
-Related documentation / recommended reading
+Application notes specifically for SDCC
\layout Standard
-\align center
+
+SDCC makes no claims about the completeness of this list and about up-to-datenes
+s or correctness of the application notes
+\begin_inset LatexCommand \index{Application notes}
+
+\end_inset
+
+.
+\layout Standard
+\align left
+
+\size footnotesize
\begin_inset Tabular
-<lyxtabular version="3" rows="6" columns="3">
+<lyxtabular version="3" rows="7" columns="3">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0pt">
-<column alignment="block" valignment="top" leftline="true" width="30line%">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
+<column alignment="block" valignment="top" leftline="true" width="17col%">
+<column alignment="block" valignment="top" leftline="true" width="27col%">
+<column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-Name
+
+\size footnotesize
+Vendor
+\end_inset
+</cell>
+<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize
+Subject / Title
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize
+Where to get
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize
+Maxim / Dallas
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
-\layout Standard
+\layout Standard
+
+
+\size footnotesize
+Using the SDCC Compiler for the DS80C400
+\begin_inset LatexCommand \index{DS80C400}
+
+\end_inset
+
-Subject / Title
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-Where to get
+
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-\family roman
-\series medium
-\shape up
-\size normal
-\emph off
-\bar no
-\noun off
-\color none
-c-refcard.pdf
+\size footnotesize
+Maxim / Dallas
\end_inset
</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+<cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
\begin_inset Text
\layout Standard
-C Reference Card
-\begin_inset LatexCommand \index{C Reference card}
+
+\size footnotesize
+Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
+\begin_inset LatexCommand \index{DS89C4x0}
\end_inset
-, 2 pages
+ Family of Microcontrollers
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
\end_inset
\layout Standard
-c-faq
+
+\size footnotesize
+Silicon Laboratories / Cygnal
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-C-FAQ-list
+
+\size footnotesize
+Integrating SDCC 8051 Tools Into The Silicon Labs IDE
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-\begin_inset LatexCommand \url{http://www.eskimo.com/~scs/C-faq/top.html}
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
\end_inset
\layout Standard
+
+\size footnotesize
+Ramtron / Goal Semiconductor
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Latest datasheet of the target CPU
+
+\size footnotesize
+Interfacing SDCC to Syn and Textpad
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-vendor
+
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
+
+\size footnotesize
+Ramtron / Goal Semiconductor
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Revision history of datasheet
+
+\size footnotesize
+Installing and Configuring SDCC and Crimson Editor
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-vendor
+
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-S.
- S.
- Muchnick
+
+\size footnotesize
+Texas Instruments
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
-Advanced Compiler Design and Implementation
+
+\size footnotesize
+MSC12xx Programming with SDCC
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\layout Standard
-bookstore (very dedicated, probably read other books first)
+
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\end_inset
-\newline
-
\layout Section
Some Questions
SDCC has grown to be a large project.
The compiler alone (without the preprocessor, assembler and linker) is
- well over 100,000 lines of code (blank stripped).
+ well over 150,000 lines of code (blank stripped).
The open source nature of this project is a key to its continued growth
and support.
You gain the benefit and support of many active software developers and
\end_inset
- area and cvs code repository
-\begin_inset LatexCommand \index{cvs code repository}
+ area and Subversion code repository
+\begin_inset LatexCommand \index{Subversion code repository}
\end_inset
\end_inset
option can sometimes be useful in locating optimization problems.
- When reporting a bug please maker sure you:
+ When reporting a bug please make sure you:
\layout Enumerate
Attach the code you are compiling with SDCC.
\end_inset
+.
+ With SDCC on average having more than 200 downloads
+\begin_inset LatexCommand \index{download}
+
+\end_inset
+
+ on sourceforge per day
+\begin_inset Foot
+collapsed false
+
+\layout Standard
+
+220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
+ between 2002 and 2005.
+ This does not include other methods of distribution.
+\end_inset
+
+ there must be some users.
+ So it's not exactly easy to find a new bug.
+ If you find one we need it:
+\emph on
+reporting bugs is good
+\emph default
.
\layout Section
ChangeLog
\layout Standard
-You can follow the status of the cvs version
+You can follow the status of the Subversion version
\begin_inset LatexCommand \index{version}
\end_inset
\end_inset
- in the cvs-repository
-\newline
-
+ in the Subversion repository
\size footnotesize
-
-\begin_inset LatexCommand \htmlurl{http://cvs.sf.net/cgi-bin/viewcvs.cgi/*checkout*/sdcc/sdcc/ChangeLog?rev=HEAD&content-type=text/plain}
+
+\begin_inset LatexCommand \htmlurl{http://svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
\end_inset
.
\layout Section
+Subversion Source Code Repository
+\layout Standard
+
+The output of
+\family sans
+\series bold
+sdcc --version
+\family default
+\series default
+ or the filenames of the snapshot versions of SDCC include date and its
+ Subversion
+\begin_inset LatexCommand \index{Subversion code repository}
+
+\end_inset
+
+ number.
+ Subversion allows to download the source of recent or previous versions
+
+\begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
+
+\end_inset
+
+ (by number or by date).
+ An on-line source code browser and detailled instructions are also available
+ there.
+ SDCC versions starting from 1999 up to now are available (currently the
+ versions prior to the conversion from cvs
+\begin_inset LatexCommand \index{cvs (see Subversion)}
+
+\end_inset
+
+ to Subversion (April 2006) are either by accessible by Subversion or by
+ cvs).
+\layout Section
+
Release policy
\begin_inset LatexCommand \index{Release policy}
sdcc/src/regression
\shape default
.
+\layout Section
+
+Use of SDCC in Education
+\layout Standard
+
+In short:
+\emph on
+highly
+\emph default
+ encouraged
+\begin_inset Foot
+collapsed false
+
+\layout Standard
+
+the phrase "use in education" might evoke the association "
+\emph on
+only
+\emph default
+ fit for use in education".
+ This connotation is not intended but nevertheless risked as the licensing
+ of SDCC makes it difficult to offer educational discounts
+\end_inset
+
+.
+ If your rationales are to:
+\layout Enumerate
+
+give students a chance to understand the
+\emph on
+complete
+\emph default
+ steps of code generation
+\layout Enumerate
+
+have a curriculum that can be extended for years.
+ Then you could use an fpga board as target and your curriculum will seamlessly
+ extend from logic synthesis (
+\begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
+
+\end_inset
+
+,
+\begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
+
+\end_inset
+
+), over assembly programming, to C to FPGA compilers (
+\begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
+
+\end_inset
+
+) and to C.
+\layout Enumerate
+
+be able to insert excursions about skills like using a revision control
+ system, submitting/applying patches, using a type-setting (as opposed to
+ word-processing) engine LyX/LaTeX, using
+\begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
+
+\end_inset
+
+, following some
+\begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
+
+\end_inset
+
+, understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
+ Source Software, CPU simulation, compiler regression tests
+\begin_inset LatexCommand \index{Regression test}
+
+\end_inset
+
+.
+
+\newline
+And if there should be a shortage of ideas then you can always point students
+ to the ever-growing feature request list
+\begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
+
+\end_inset
+
+.
+\layout Enumerate
+
+not tie students to a specific host platform and instead allow them to use
+ a host platform of
+\emph on
+their
+\emph default
+ choice (among them Alpha, i386, i386_64, MacOs, Mips, Sparc, Windows and
+ eventually
+\begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
+
+\end_inset
+
+)
+\layout Enumerate
+
+not encourage students to use illegal copies of educational software
+\layout Enumerate
+
+be immune to licensing/availability/price changes of the chosen tool chain
+\layout Enumerate
+
+be able to change to a new target platform without having to adopt a new
+ tool chain
+\layout Enumerate
+
+have complete control over and insight into the tool chain
+\layout Enumerate
+
+make your students aware about the pros and cons of open source software
+ development
+\layout Enumerate
+
+give back to the public as you are probably at least partially publically
+ funded
+\layout Enumerate
+
+give students a chance to publically prove their skills and to possibly
+ see a world wide impact
+\layout Standard
+
+then SDCC is probably among the first choices.
+ Well, probably SDCC might be the only choice.
\layout Chapter
\pagebreak_top
SDCC Technical Data
\end_inset
+\layout Standard
+
+The latest publically available version of the standard
+\emph on
+ISO/IEC 9899 - Programming languages - C
+\emph default
+ should be available at:
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
+
+\end_inset
+
+.
+\newline
+
\layout Standard
Deviations from the compliance:
command line option is specified.
\layout Itemize
-structures and unions cannot be assigned values directly, cannot be passed
- as function parameters or assigned to each other and cannot be a return
- value from a function, e.g.:
+structures
+\begin_inset LatexCommand \index{struct}
+
+\end_inset
+
+ and unions
+\begin_inset LatexCommand \index{union}
+
+\end_inset
+
+ cannot be assigned values directly, cannot be passed as function parameters
+ or assigned to each other and cannot be a return value
+\begin_inset LatexCommand \index{return value}
+
+\end_inset
+
+ from a function, e.g.:
\begin_deeper
\layout Verse
\newline
}
\newline
-struct s foo1 (struct s parms) /* invalid in SDCC although allowed in ANSI
- */
+
+\series bold
+struct
+\series default
+ s foo1 (
+\series bold
+struct
+\series default
+ s parms) /* invalid in SDCC although allowed in ANSI */
\newline
{
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-return rets;/* is invalid in SDCC although allowed in ANSI */
+return rets; /* is invalid in SDCC although allowed in ANSI */
\newline
}
\end_deeper
\family typewriter
-struct s { char x } a[] = {1, 2}; /* invalid in SDCC */
+struct s { char x } a[] = {1, 2};\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* invalid in SDCC */
\newline
struct s { char x } a[] = {{1}, {2}}; /* OK */
\end_deeper
not supported.
\layout Itemize
-No support for setjmp
-\begin_inset LatexCommand \index{setjmp (not supported)}
-
-\end_inset
-
- and longjmp
-\begin_inset LatexCommand \index{longjmp (not supported)}
-
-\end_inset
-
- (for now).
-\layout Itemize
-
Old K&R style
\begin_inset LatexCommand \index{K\&R style}
\end_deeper
\layout Itemize
+Most enhancements in C99 are not supported, f.e.:
+\begin_deeper
+\layout Verse
+
+
+\family typewriter
+\series bold
+inline
+\begin_inset LatexCommand \index{inline (not supported)}
+
+\end_inset
+
+
+\series default
+ int increment (int a) { return a+1; } /* is invalid in SDCC although allowed
+ in C99.
+ An empty define
+\emph on
+#define inline
+\emph default
+ can be used as a work around */
+\newline
+
+\newline
+for (
+\series bold
+int
+\series default
+ i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
+\end_deeper
+\layout Itemize
+
Certain words that are valid identifiers in the standard may be reserved
words in SDCC unless the
\series bold