* doc/sdccman.lyx: added note on dynamic memory heap initialization
[fw/sdcc] / doc / sdccman.lyx
index 570dcfceff98654b791d798e3c58f8a7c9bd2bf7..9d5e87c04bea2a3c255511e6e2fd109a8ab18f84 100644 (file)
@@ -7,8 +7,8 @@
   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 CPU DS390                 embedded free Freescale GPL HC08 Intel manual Maxim mcs51 Microchip microcontroller open source PIC Z80 Zilog},
+  pdfpagemode=UseOutlines,
   colorlinks=true,
   linkcolor=blue] {hyperref}
 %
@@ -82,7 +82,7 @@ SDCC Compiler User Guide
 
 
 \size normal 
-SDCC 2.5.5
+SDCC 2.6.1
 \size footnotesize 
 
 \newline 
@@ -91,7 +91,7 @@ $Date$
 $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
 
 
@@ -202,21 +202,355 @@ The peep hole optimizer uses a rule based substitution mechanism which is
 
 \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="center" 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
 
-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
+
+\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
 
-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
+
+-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.296
+\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
+
+\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
@@ -349,7 +683,12 @@ typewriter font.
 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 
@@ -487,6 +826,18 @@ bit b;
 \SpecialChar ~
 \SpecialChar ~
 b = ~b; /* equivalent to b=1 instead of toggling b */
+\begin_inset Marginal
+collapsed false
+
+\layout Standard
+
+
+\series bold 
+\SpecialChar ~
+!
+\end_inset 
+
+
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -537,7 +888,8 @@ The SDCC home page at
  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
@@ -839,7 +1191,7 @@ status Collapsed
 /
 \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
 
@@ -867,6 +1219,20 @@ status Collapsed
 /
 \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
@@ -1570,7 +1936,7 @@ status Collapsed
 /
 \end_inset 
 
--disable-device-lib-build
+-disable-device-lib
 \backslash 
 
 \newline 
@@ -1797,10 +2163,10 @@ Install paths
 \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
@@ -2924,7 +3290,7 @@ Building SDCC on Linux
 \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 
@@ -3128,7 +3494,7 @@ less ; not really needed for building SDCC, but you'll miss it sooner or
  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:
@@ -3236,7 +3602,7 @@ Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
 \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 
@@ -3269,8 +3635,8 @@ bin before running 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.
@@ -3544,22 +3910,146 @@ sdcc-x.y.z-setup.exe
 
  or a setup program for one of the snapshots 
 \emph on 
-sdcc_yyyymmdd_setup.exe
+sdcc-yyyymmdd-xxxx-setup.exe
 \emph default 
  from 
 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
 
-\end_inset 
+\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
+
+
+\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
+
+
+\family typewriter 
+cd sdcc.build
+\layout Standard
+
+
+\family typewriter 
+../sdcc/configure\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+# configure is doing all the magic!
+\layout Standard
+
 
- 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 
 
@@ -3581,7 +4071,7 @@ x).
 
 \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}
 
@@ -3750,8 +4240,16 @@ status Collapsed
 
 \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 (
@@ -4483,7 +4981,12 @@ sourcefile.
 
 \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
 
@@ -6971,7 +7474,7 @@ status Collapsed
 
 
 \series default 
- Disable peep-hole optimization.
+ Disable peep-hole optimization with built-in rules.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -8684,6 +9187,14 @@ data
  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
@@ -8692,7 +9203,7 @@ near
 
 
 \family typewriter 
-data unsigned char test_data;
+__data unsigned char test_data;
 \layout Standard
 
 Writing 0x01 to this variable generates the assembly code:
@@ -8705,7 +9216,7 @@ Writing 0x01 to this variable generates the assembly code:
 \SpecialChar ~
 mov\SpecialChar ~
 \SpecialChar ~
-_test_data,#0x01 
+_test_data,#0x01
 \layout Subsubsection
 
 xdata
@@ -8742,7 +9253,7 @@ default
 
 
 \family typewriter 
-xdata unsigned char test_xdata;
+__xdata unsigned char test_xdata;
 \layout Standard
 
 Writing 0x01 to this variable generates the assembly code:
@@ -8800,7 +9311,7 @@ Variables declared with this storage class will be allocated into the indirectly
 
 
 \family typewriter 
-idata unsigned char test_idata;
+__idata unsigned char test_idata;
 \layout Standard
 
 Writing 0x01 to this variable generates the assembly code:
@@ -8884,7 +9395,7 @@ default
 
 
 \family typewriter 
-pdata unsigned char test_pdata;
+__pdata unsigned char test_pdata;
 \layout Standard
 
 Writing 0x01 to this variable generates the assembly code:
@@ -8958,7 +9469,7 @@ code
 
 
 \family typewriter 
-code unsigned char test_code;
+__code unsigned char test_code;
 \layout Standard
 
 Read access to this variable generates the assembly code:
@@ -9003,7 +9514,7 @@ char
 
 
 \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
@@ -9063,7 +9574,7 @@ This is a data-type and a storage class specifier.
 
 
 \family typewriter 
-bit test_bit;
+__bit test_bit;
 \layout Standard
 
 Writing 1 to this variable generates the assembly code:
@@ -9175,7 +9686,7 @@ bit
 
 
 \family typewriter 
-sfr at
+__sfr __at
 \begin_inset LatexCommand \index{at}
 
 \end_inset 
@@ -9185,7 +9696,7 @@ sfr at
 
 \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 */
@@ -9193,7 +9704,7 @@ sfr at
 /* 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 
@@ -9203,9 +9714,9 @@ sfr16 at
 
 \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 
@@ -9267,40 +9778,40 @@ Pointer declaration examples:
 /* 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
  */
 \newline 
-char * xdata p;
+char * __xdata 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.
@@ -9535,6 +10046,8 @@ idata
 \emph default 
 ).
  
+\newline 
+
 \layout Standard
 
 By default the 8051 linker will place the stack after the last byte of (i)data
@@ -9933,7 +10446,15 @@ xdata
 
 \end_inset 
 
- 0x7ffe unsigned int chksum;
+ (0x7ffe) unsigned int chksum;
+\layout Standard
+
+or
+\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
@@ -9942,8 +10463,19 @@ In the above example the variable chksum will be located at 0x7ffe and 0x7fff
 \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
@@ -9965,6 +10497,18 @@ not
  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}
@@ -9988,17 +10532,17 @@ volatile
 
 \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
@@ -10031,17 +10575,17 @@ Absolute addresses can be specified for variables in all storage classes,
 
 
 \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
@@ -10061,19 +10605,19 @@ extern volatile
 
 \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 ~
@@ -10209,7 +10753,7 @@ Then, someplace in the code for the first hardware you would use
 
 
 \family typewriter 
-bit at
+__bit __at
 \begin_inset LatexCommand \index{at}
 
 \end_inset 
@@ -10219,19 +10763,19 @@ bit at
 
 \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 ~
@@ -10243,24 +10787,24 @@ Similarly, for the second hardware you would use
 
 
 \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 ~
@@ -10367,7 +10911,7 @@ reentrant
 
 
 \family typewriter 
-unsigned char foo(char i) reentrant 
+unsigned char foo(char i) __reentrant 
 \newline 
 { 
 \newline 
@@ -10437,24 +10981,24 @@ unsigned char foo()
 \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 ~
@@ -10568,8 +11112,18 @@ no other function calls and the function is non-reentrant and the memory
 
 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}
 
@@ -10628,12 +11182,12 @@ P3 = errcd;
 \newline 
 
 \newline 
-void some_isr () interrupt
+void some_isr () __interrupt
 \begin_inset LatexCommand \index{interrupt}
 
 \end_inset 
 
- 2
+ (2)
 \newline 
 {
 \newline 
@@ -10704,7 +11258,7 @@ outines to be coded in C, with some extended keywords.
 
 
 \family typewriter 
-void timer_isr (void) interrupt 1 using 1 
+void timer_isr (void) __interrupt (1) __using (1) 
 \newline 
 { 
 \newline 
@@ -10947,6 +11501,14 @@ status Collapsed
 \end_inset 
 
  compiler option.
+ Note, the type promotion
+\begin_inset LatexCommand \index{type promotion}
+
+\end_inset 
+
+ required by ANSI C can cause 16 bit routines to be used without the programmer
+ being aware of it.
 \layout Standard
 
 Calling other functions from an interrupt service routine is not recommended,
@@ -10999,11 +11561,11 @@ Interrupt numbers and the corresponding address & descriptions for the Standard
 \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
@@ -11078,7 +11640,7 @@ Timer 0
 
 \layout Standard
 
-0x000B
+0x000b
 \end_inset 
 </cell>
 </row>
@@ -11130,7 +11692,7 @@ Timer 1
 
 \layout Standard
 
-0x001B
+0x001b
 \end_inset 
 </cell>
 </row>
@@ -11160,8 +11722,8 @@ Serial
 \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
@@ -11182,7 +11744,57 @@ Timer 2 (8052)
 
 \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>
@@ -11258,10 +11870,10 @@ The Z80 uses several different methods for determining the correct interrupt
  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 
@@ -11282,6 +11894,16 @@ void nmi_isr (void) critical interrupt
  
 \newline 
 }
+\layout Standard
+
+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
@@ -11313,7 +11935,7 @@ critical
 
 
 \family typewriter 
-int foo () critical
+int foo () __critical
 \begin_inset LatexCommand \index{critical}
 
 \end_inset 
@@ -11359,7 +11981,7 @@ critical
 
 
 \family typewriter 
-critical{ i++; }
+__critical{ i++; }
 \layout Standard
 
 More than one statement could have been included in the block.
@@ -12019,7 +12641,7 @@ Starting from a small snippet of c-code this example shows for the MCS51
 
 \family typewriter 
 \size footnotesize 
-unsigned char far
+unsigned char __far
 \begin_inset LatexCommand \index{far (storage class)}
 
 \end_inset 
@@ -12029,7 +12651,7 @@ unsigned char far
 
 \end_inset 
 
- at
__at
 \begin_inset LatexCommand \index{at}
 
 \end_inset 
@@ -12039,14 +12661,14 @@ unsigned char far
 
 \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;
 \newline 
 
 \newline 
@@ -12058,7 +12680,34 @@ void to_buffer( unsigned char c )
 \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 false
+
+\layout Standard
+
+
+\series bold 
+\SpecialChar ~
+!
+\end_inset 
+
+
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -12072,6 +12721,18 @@ buf[ head++ ] = c;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
 /* access to a 256 byte aligned array */
 \newline 
 } 
@@ -12142,7 +12803,7 @@ mov\SpecialChar ~
 \SpecialChar ~
 r2,dpl 
 \newline 
-;buffer.c if( head != tail-1 ) 
+;buffer.c if( head != (unsigned char)(tail-1) ) 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -12279,9 +12940,9 @@ The new file buffer.c should compile with only one warning about the unreference
 
 \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 
@@ -12299,7 +12960,7 @@ void to_buffer( unsigned char c )
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-if( head != tail-1 )
+if( head != (unsigned char)(tail-1) )
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -12367,7 +13028,7 @@ _asm
 ; 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 ~
@@ -12710,7 +13371,7 @@ volatile
 \newline 
 
 \newline 
-void simpleInterrupt(void) interrupt
+void simpleInterrupt(void) __interrupt
 \begin_inset LatexCommand \index{interrupt}
 
 \end_inset 
@@ -12720,7 +13381,7 @@ void simpleInterrupt(void) interrupt
 
 \end_inset 
 
- 1
+ (1)
 \newline 
 {
 \newline 
@@ -12734,7 +13395,7 @@ counter++;
 \newline 
 
 \newline 
-void nakedInterrupt(void) interrupt 2 _naked
+void nakedInterrupt(void) __interrupt (2) __naked
 \newline 
 {
 \newline 
@@ -12803,6 +13464,16 @@ For an 8051 target, the generated simpleInterrupt looks like:
 
 
 \family typewriter 
+Note, this is an 
+\series bold 
+outdated
+\series default 
+ example, recent versions of SDCC generate
+\newline 
+the same code for simpleInterrupt() and nakedInterrupt()!
+\newline 
+
+\newline 
 _simpleInterrupt:
 \newline 
 \SpecialChar ~
@@ -13677,8 +14348,8 @@ For signed & unsigned int (16 bit) and long (32 bit) variables, division,
 \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
@@ -13971,8 +14642,8 @@ SDCC supports IEEE (single precision 4 bytes) floating point numbers.The
 \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
@@ -14601,7 +15272,12 @@ collapsed false
 
 \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 
 
 .
@@ -14664,6 +15340,19 @@ putchar()
  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
@@ -14704,7 +15393,7 @@ DUSE_FLOATS=1
  on the command line.
  Use
 \emph on 
--
+ -
 \begin_inset ERT
 status Collapsed
 
@@ -14750,34 +15439,135 @@ printf_tiny()
 \end_inset 
 
 
-\family default 
- and 
-\family typewriter 
-printf_fast()
-\begin_inset LatexCommand \index{printf\_fast() (mcs51)}
+\family default 
+ (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)}
+
+\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 
 
-\family default 
-and
-\family typewriter 
- printf_fast_f()
-\begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
+, 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
@@ -15419,6 +16209,17 @@ codeseg <name>
 
 - 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>
@@ -15428,6 +16229,17 @@ constseg <name>
 
 - 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:
@@ -15542,8 +16354,8 @@ The compiler creates the following #defines
 \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
@@ -15585,7 +16397,9 @@ SDCC
 
 \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>
@@ -20107,6 +20921,262 @@ status Collapsed
  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}
 
@@ -20139,7 +21209,7 @@ on, which also builds and installs the debugger in the target directory
  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
@@ -20161,7 +21231,7 @@ status Collapsed
 
  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}
 
@@ -20174,7 +21244,7 @@ status Collapsed
 
  files and the address information.
  This .cdb is used by the debugger.
-\layout Section
+\layout Subsection
 
 How the Debugger Works
 \layout Standard
@@ -20192,7 +21262,7 @@ status Collapsed
 -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.
@@ -20200,9 +21270,19 @@ status Collapsed
  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 sdcdb only connects to the simulator but 
+\emph on 
+newcdb
+\emph default 
+ at 
+\begin_inset LatexCommand \url{http://ec2drv.sf.net/}
+
+\end_inset 
 
-Starting the Debugger
+ is an effort to connect directly to the hardware.) 
+\layout Subsection
+
+Starting the Debugger SDCDB
 \layout Standard
 
 The debugger can be started using the following command line.
@@ -20235,9 +21315,9 @@ foo.ihx - the Intel hex format
 \end_inset 
 
  object file.
-\layout Section
+\layout Subsection
 
-Command Line Options
+SDCDB Command Line Options
 \layout Itemize
 
 -
@@ -20302,9 +21382,9 @@ status Collapsed
 \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
@@ -20453,9 +21533,9 @@ quit
 "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: 
@@ -20477,7 +21557,7 @@ The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
 The .eps 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.eps}
 
 \end_inset 
 
@@ -20538,9 +21618,9 @@ and DDD was invoked with
 
 \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 
@@ -21398,10 +22478,20 @@ Use the smallest data type to represent your data-value.
  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 
+
+ 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.
@@ -21582,6 +22672,98 @@ feeling
  for the code generation.
 \layout Section
 
+Porting code from or to other compilers
+\layout Itemize
+
+check whether endianness of the compilers differs and adapt where needed.
+\layout Itemize
+
+check the device specific header files 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.
+\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).
+\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 char variables and for the use of the ~\SpecialChar ~
+operator on bit variables.
+ See 
+\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{va\_arg}
+
+\end_inset 
+
+) char variables as integers others as char).
+\layout Itemize
+
+check the resulting memory layout.
+\layout Section
+
 Tools
 \begin_inset LatexCommand \index{Tools}
 
@@ -21594,8 +22776,8 @@ Tools
 \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 Section
 
 Related open source tools
+\begin_inset LatexCommand \label{sec:Related-open-source-tools}
+
+\end_inset 
+
+
 \begin_inset LatexCommand \index{Related tools}
 
 \end_inset 
@@ -22274,9 +23461,9 @@ Related open source tools
 \align center 
 
 \begin_inset  Tabular
-<lyxtabular version="3" rows="11" columns="3">
+<lyxtabular version="3" rows="14" columns="3">
 <features>
-<column alignment="center" valignment="top" leftline="true" width="0pt">
+<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">
@@ -22405,6 +23592,38 @@ PIC programmer
 \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
+
+ec2drv/newcdb
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Tools for Silicon Laboratories JTAG debug adapter, partly based on sdcdb
+ (Unix only)
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -22517,6 +23736,37 @@ Part of binutils (should be there anyway)
 
 \layout Standard
 
+cmon51
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+8051 monitor (hex up-/download, single step, disassemble)
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
+
+\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
+
 doxygen
 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
 
@@ -22575,6 +23825,37 @@ IDE (has anyone tried integrating SDCC & sdcdb? Unix only)
 \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
+
+paulmon
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+8051 monitor (hex up-/download, single step, disassemble)
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -22674,11 +23955,11 @@ Related documentation / recommended reading
 \align center 
 
 \begin_inset  Tabular
-<lyxtabular version="3" rows="6" columns="3">
+<lyxtabular version="3" rows="8" columns="3">
 <features>
-<column alignment="center" valignment="top" leftline="true" width="0pt">
+<column alignment="left" 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="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
@@ -22778,6 +24059,88 @@ C-FAQ-list
 \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 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">
+\begin_inset Text
+
+\layout Standard
+
+
+\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">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -22972,8 +24335,8 @@ The SDCC project is hosted on the SDCC sourceforge site at
 
 \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 
 
@@ -23190,7 +24553,7 @@ Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
 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 
@@ -23200,18 +24563,46 @@ You can follow the status of the cvs version
 
 \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}
+
+\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 to Subversion (April 2006) are
+ either by accessible by Subversion or by cvs).
+\layout Section
+
 Release policy
 \begin_inset LatexCommand \index{Release policy}
 
@@ -26431,6 +27822,20 @@ ANSI-Compliance
 \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: