* src/SDCC.lex, src/SDCCmain.c, sdc/SDCCglobl.h, doc/sdccman.lyx:
[fw/sdcc] / doc / sdccman.lyx
index 4ebec3462c849c47be4609927bd45de00927d469..eb16337ed11ee2e862c4ece108fe103efdf91ed1 100644 (file)
@@ -7,7 +7,7 @@
   pdftitle={SDCC Compiler User Guide},
   pdfauthor={SDCC development team},
   pdfsubject={installation, user manual},
-  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},
+  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}
@@ -82,7 +82,7 @@ SDCC Compiler User Guide
 
 
 \size normal 
-SDCC 2.5.6
+SDCC 2.6.4
 \size footnotesize 
 
 \newline 
@@ -142,8 +142,8 @@ Sandeep Dutta
 
 , 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)}
@@ -155,7 +155,7 @@ Sandeep Dutta
 
 \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.
  
@@ -212,7 +212,7 @@ Supported data-types are:
 <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="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
@@ -461,7 +461,7 @@ signed
 
 \layout Standard
 
-0, +4.294.967.296
+0, +4.294.967.295
 \end_inset 
 </cell>
 </row>
@@ -502,6 +502,16 @@ signed
 
 \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>
@@ -578,9 +588,7 @@ status Collapsed
 
 \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 
@@ -723,8 +731,24 @@ the default directory for gcc-builds where include, library and documentation
  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 
@@ -825,7 +849,12 @@ bit b;
 \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
 
@@ -833,6 +862,7 @@ collapsed true
 
 
 \series bold 
+\SpecialChar ~
 !
 \end_inset 
 
@@ -953,13 +983,13 @@ For most users it is sufficient to skip to either section
 
 \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
@@ -1032,18 +1062,42 @@ status Collapsed
 \layout List
 \labelwidthstring 00.00.0000
 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-datarootdir see table below
+\newline 
+
+\layout List
+\labelwidthstring 00.00.0000
+
+\SpecialChar ~
+\SpecialChar ~
 docdir environment variable, see table below
 \layout List
 \labelwidthstring 00.00.0000
 
+\SpecialChar ~
+\SpecialChar ~
 include_dir_suffix environment variable, see table below
 \layout List
 \labelwidthstring 00.00.0000
 
+\SpecialChar ~
+\SpecialChar ~
 lib_dir_suffix environment variable, see table below
 \layout List
 \labelwidthstring 00.00.0000
 
+\SpecialChar ~
+\SpecialChar ~
 sdccconf_h_dir_separator environment variable, either / or 
 \backslash 
 
@@ -1051,6 +1105,8 @@ sdccconf_h_dir_separator environment variable, either / or
  makes sense here.
  This character will only be used in sdccconf.h; don't forget it's a C-header,
  therefore a double-backslash is needed there.
+\newline 
+
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -1205,6 +1261,8 @@ status Collapsed
 \end_inset 
 
 -disable-packihx Disables building packihx
+\newline 
+
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -1307,7 +1365,7 @@ These defaults are:
 \align center 
 
 \begin_inset  Tabular
-<lyxtabular version="3" rows="8" columns="3">
+<lyxtabular version="3" rows="9" columns="3">
 <features>
 <column alignment="block" valignment="top" leftline="true" width="0in">
 <column alignment="block" valignment="top" leftline="true" width="0in">
@@ -1418,7 +1476,7 @@ BINDIR
 
 
 \emph on 
-$EXECPREFIX
+$EXEC_PREFIX
 \emph default 
 /bin
 \end_inset 
@@ -1430,7 +1488,7 @@ $EXECPREFIX
 
 
 \emph on 
-$EXECPREFIX
+$EXEC_PREFIX
 \emph default 
 
 \backslash 
@@ -1455,6 +1513,38 @@ DATADIR
 \layout Standard
 
 
+\emph on 
+$DATAROOTDIR
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+$DATAROOTDIR
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+DATAROOTDIR
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
 \emph on 
 $PREFIX
 \emph default 
@@ -1490,7 +1580,7 @@ DOCDIR
 
 
 \emph on 
-$DATADIR
+$DATAROOTDIR
 \emph default 
 /sdcc/doc
 \end_inset 
@@ -1502,7 +1592,7 @@ $DATADIR
 
 
 \emph on 
-$DATADIR
+$DATAROOTDIR
 \emph default 
 
 \backslash 
@@ -1740,7 +1830,7 @@ status Collapsed
 /
 \end_inset 
 
--datadir=
+-datarootdir=
 \begin_inset Quotes srd
 \end_inset 
 
@@ -1857,7 +1947,7 @@ status Collapsed
 /
 \end_inset 
 
--datadir=
+-datarootdir=
 \begin_inset Quotes srd
 \end_inset 
 
@@ -1873,7 +1963,9 @@ docdir=
 \begin_inset Quotes srd
 \end_inset 
 
-/sdcc/doc
+
+\backslash 
+${datarootdir}/doc
 \begin_inset Quotes srd
 \end_inset 
 
@@ -1949,7 +2041,7 @@ status Collapsed
 /
 \end_inset 
 
--disable-ucsim
+-host=i586-mingw32msvc
 \backslash 
 
 \newline 
@@ -1963,16 +2055,6 @@ status Collapsed
 /
 \end_inset 
 
--host=i586-mingw32msvc -
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
 -build=unknown-unknown-linux-gnu
 \layout Standard
 
@@ -1991,30 +2073,6 @@ compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
 ./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
@@ -2048,7 +2106,7 @@ status Collapsed
 /
 \end_inset 
 
--datadir=
+-datarootdir=
 \begin_inset Quotes srd
 \end_inset 
 
@@ -2064,7 +2122,9 @@ docdir=
 \begin_inset Quotes srd
 \end_inset 
 
-/sdcc/doc
+
+\backslash 
+${datarootdir}/doc
 \begin_inset Quotes srd
 \end_inset 
 
@@ -2116,17 +2176,27 @@ sdccconf_h_dir_separator=
 \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).
@@ -3409,14 +3479,6 @@ With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
  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
 
@@ -3616,8 +3678,7 @@ Download the source package
 
 \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
@@ -3817,7 +3878,7 @@ Building SDCC Using Borland
 
 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
@@ -4080,6 +4141,11 @@ x).
 \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
@@ -4637,11 +4703,9 @@ link-gbz80 - The Z80 and GameBoy Z80 linkers.
 \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.
@@ -4685,7 +4749,17 @@ The preprocessor
 
 \end_inset 
 
- is a modified version of the GNU preprocessor.
+ is a modified version of the GNU cpp
+\begin_inset LatexCommand \index{cpp|see{sdcpp}}
+
+\end_inset 
+
+ preprocessor 
+\begin_inset LatexCommand \url{http://gcc.gnu.org/}
+
+\end_inset 
+
+.
  The C preprocessor is used to pull in #include sources, process #ifdef
  statements, #defines and so on.
 \layout Subsection
@@ -4725,19 +4799,18 @@ S51
 .
  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 
@@ -4749,7 +4822,6 @@ Sdcdb
 \end_inset 
 
 , but can be easily changed to use other simulators.
- Sdcdb is currently not available on Win32 platfors.
 \layout Chapter
 
 Using SDCC
@@ -4934,7 +5006,7 @@ sourcefile.adb
  - An intermediate file containing debug information needed to create the
  .cdb file (with -
 \begin_inset ERT
-status Open
+status Collapsed
 
 \layout Standard
 
@@ -5058,6 +5130,137 @@ Anatomy of the compiler
 ).
 \layout Subsection
 
+Postprocessing the Intel Hex
+\begin_inset LatexCommand \index{Intel hex format}
+
+\end_inset 
+
+ file
+\layout Standard
+
+In most cases this won't be needed but 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
+\begin_inset LatexCommand \index{checksum}
+
+\end_inset 
+
+ 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 ~
+-o sourcefile.hex -intel
+\newline 
+
+\newline 
+
+\family default 
+\series default 
+An example for a more complex command line
+\begin_inset Foot
+collapsed false
+
+\layout Standard
+
+the command backfills
+\begin_inset LatexCommand \index{backfill unused memory}
+
+\end_inset 
+
+ unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
+ block is zero.
+ If the program counter on an mcs51 runs wild the backfill pattern 0x12
+ will be interpreted as an 
+\family typewriter 
+lcall
+\family default 
+ to address 
+\family typewriter 
+0x1212
+\family default 
+ (where an emergency routine could sit).
+\end_inset 
+
+ could look like:
+\newline 
+
+\newline 
+
+\family sans 
+\series bold 
+\size footnotesize 
+srec_cat\SpecialChar ~
+sourcefile.ihx -intel\SpecialChar ~
+\SpecialChar ~
+-fill 0x12 0x0000 0xfffe\SpecialChar ~
+-little-endian-checksum-nega
+tive 0xfffe 0x02 0x02\SpecialChar ~
+\SpecialChar ~
+-o sourcefile.hex -intel
+\size default 
+
+\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
 
@@ -5506,10 +5709,10 @@ __mulint
 \newline 
 
 \layout Standard
-
+\added_space_bottom bigskip 
 If the source files are compiled using -
 \begin_inset ERT
-status Open
+status Collapsed
 
 \layout Standard
 
@@ -5681,7 +5884,7 @@ Processor Selection Options
 
 \end_inset 
 
- processor (In development, not complete).
+ processor (Not maintained, not complete).
  AVR users should probably have a look at winavr 
 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
 
@@ -5753,7 +5956,7 @@ p16f627 p16f628 p16f84 p16f873 p16f877?
 
  processor (Not maintained, not complete).
 \layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
 
 
 \series bold 
@@ -5972,6 +6175,33 @@ Like `-dD' except that the macro arguments and contents are omitted.
 \labelwidthstring 00.00.0000
 
 
+\series bold 
+-pedantic-parse-number
+\begin_inset LatexCommand \index{-pedantic-parse-number}
+
+\end_inset 
+
+
+\size large 
+\bar under 
+\series default 
+\size default 
+\bar default 
+Pedentic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
+ and the macro LO_B(3) gets expanded.
+ See also #pragma pedantic_parse_number in section
+\begin_inset LatexCommand \ref{sec:Pragmas}
+
+\end_inset 
+
+\emph on 
+Note: this functionality is not in conformance with standard!
+\layout List
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
+
+
 \series bold 
 -Wp\SpecialChar ~
 preprocessorOption[,preprocessorOption]
@@ -5992,9 +6222,29 @@ sdcpp
 \end_inset 
 
 .
- SDCC uses an adapted version of the preprocessor cpp of the GNU Compiler
- Collection (gcc), if you need more dedicated options please refer to the
- documentation at 
+ SDCC uses an adapted version of the preprocessor 
+\emph on 
+cpp
+\emph default 
+ of the GNU Compiler Collection
+\begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
+
+\end_inset 
+
+ (
+\emph on 
+gcc
+\emph default 
+\begin_inset LatexCommand \url{http://gcc.gnu.org/}
+
+\end_inset 
+
+), if you need more dedicated options please refer to the GCC\SpecialChar ~
+4.1.1\SpecialChar ~
+CPP\SpecialChar ~
+Manual
+ at 
 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
 
 \end_inset 
@@ -6135,8 +6385,12 @@ status Collapsed
 \end_inset 
 
  segment, default value 0.
- Note when this option is used the interrupt vector table is also relocated
- to the given address.
+ Note when this option is used the interrupt vector table
+\begin_inset LatexCommand \index{interrupt vector table}
+
+\end_inset 
+
+ is also relocated to the given address.
  The value entered can be in Hexadecimal or Decimal format, e.g.: -
 \begin_inset ERT
 status Collapsed
@@ -6286,7 +6540,12 @@ status Collapsed
 
 \end_inset 
 
- is placed after the pdata segment.
+ 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.
@@ -6551,6 +6810,11 @@ status Collapsed
 \end_inset 
 
 
+\begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
+
+\end_inset 
+
+
 \bar under 
  
 \series default 
@@ -6561,9 +6825,14 @@ The linker output (final object code) is in ELF format
 \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 
@@ -6577,7 +6846,23 @@ linkOption[,linkOption]
 
 ...
  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
@@ -6697,8 +6982,13 @@ status Collapsed
 
 
 \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}
 
@@ -6832,7 +7122,7 @@ status Collapsed
  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 
@@ -6863,7 +7153,7 @@ DS390 / DS400 Options
 \end_inset 
 
 
-\begin_inset LatexCommand \index{DS390 options}
+\begin_inset LatexCommand \index{DS390}
 
 \end_inset 
 
@@ -6886,7 +7176,7 @@ status Collapsed
 -model-flat24
 \series default 
 
-\begin_inset LatexCommand \index{-\/-model-flat24}
+\begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
 
 \end_inset 
 
@@ -6920,7 +7210,7 @@ status Collapsed
 \end_inset 
 
 -protect-sp-update
-\begin_inset LatexCommand \index{-\/-protect-sp-update}
+\begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
 
 \end_inset 
 
@@ -6945,7 +7235,7 @@ status Collapsed
 -stack-10bit
 \series default 
 
-\begin_inset LatexCommand \index{-\/-stack-10bit}
+\begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
 
 \end_inset 
 
@@ -7040,7 +7330,7 @@ status Collapsed
 \end_inset 
 
 -stack-probe
-\begin_inset LatexCommand \index{-\/-stack-probe}
+\begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
 
 \end_inset 
 
@@ -7063,7 +7353,7 @@ status Collapsed
 \end_inset 
 
 -tini-libid
-\begin_inset LatexCommand \index{-\/-tini-libid}
+\begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
 
 \end_inset 
 
@@ -7072,7 +7362,7 @@ status Collapsed
  <nnnn> LibraryID used in -mTININative.
  
 \layout List
-\labelwidthstring 00.00.0000
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
 
 
 \series bold 
@@ -7087,7 +7377,7 @@ status Collapsed
 \end_inset 
 
 -use-accelerator
-\begin_inset LatexCommand \index{-\/-use-accelerator}
+\begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
 
 \end_inset 
 
@@ -7103,7 +7393,7 @@ Z80 Options
 \end_inset 
 
 
-\begin_inset LatexCommand \index{Z80 options}
+\begin_inset LatexCommand \index{Z80}
 
 \end_inset 
 
@@ -7126,7 +7416,7 @@ status Collapsed
 -callee-saves-bc
 \series default 
 
-\begin_inset LatexCommand \index{-\/-callee-saves-bc}
+\begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
 
 \end_inset 
 
@@ -7138,7 +7428,7 @@ status Collapsed
 \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 
@@ -7155,7 +7445,7 @@ status Collapsed
 -no-std-crt0
 \series default 
 
-\begin_inset LatexCommand \index{-\/-no-std-crt0}
+\begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
 
 \end_inset 
 
@@ -7562,7 +7852,7 @@ status Collapsed
  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 
@@ -7985,8 +8275,8 @@ status Collapsed
 \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}
 
@@ -8256,7 +8546,19 @@ status Collapsed
 
 \series default 
  Display errors and warnings using MSVC style, so you can use SDCC with
- visual studio.
+ the visual studio IDE
+\begin_inset LatexCommand \index{IDE}
+
+\end_inset 
+
+.
+ With SDCC both offering a GCC-like (the default) and a MSVC-like
+\begin_inset LatexCommand \index{MSVC output style}
+
+\end_inset 
+
+ output style, integration into most programming editors should be straightforwa
+rd.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -8474,6 +8776,29 @@ status Collapsed
 \labelwidthstring 00.00.0000
 
 
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-fdollars-in-identifiers
+\begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
+
+\end_inset 
+
+
+\series default 
+ Permit '$' as an identifier character
+\layout List
+\added_space_bottom bigskip \labelwidthstring 00.00.0000
+
+
 \series bold 
 more-pedantic
 \series default 
@@ -8857,7 +9182,7 @@ status Collapsed
 \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 
@@ -8888,7 +9213,7 @@ Will cause all the above mentioned dumps to be created.
 
 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 
@@ -9131,7 +9456,7 @@ Search Paths
 
 ..
 \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.
@@ -9573,7 +9898,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:
@@ -9653,6 +9978,11 @@ sfr
 \end_inset 
 
 
+\begin_inset LatexCommand \index{sbit}
+
+\end_inset 
+
+
 \layout Standard
 
 Like the bit keyword, 
@@ -9698,12 +10028,19 @@ __sfr __at
  (0x80) P0;\SpecialChar ~
  /* special function register P0 at location 0x80 */
 \newline 
-/* 16 bit special function register combination for timer 0 */
+
 \newline 
-/* with the high byte at location 0x8C and the low byte at location 0x8A
- */
+/* 16 bit special function register combination for timer 0
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+ with the high byte at location 0x8C and the low byte at location 0x8A */
+\newline 
+__sfr16 __at (0x8C8A) TMR0;
+\newline 
+
 \newline 
-__sfr16 __at
+__sbit __at
 \begin_inset LatexCommand \index{at}
 
 \end_inset 
@@ -9713,9 +10050,8 @@ __sfr16 __at
 
 \end_inset 
 
- (0x8C8A) TMR0;
-\newline 
-__sbit __at (0xd7) CY; /* CY (Carry Flag
+ (0xd7) CY;\SpecialChar ~
+ /* CY (Carry Flag
 \begin_inset LatexCommand \index{Flags}
 
 \end_inset 
@@ -9747,6 +10083,61 @@ sfr32.
 \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
@@ -9800,15 +10191,24 @@ __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 
-char * __xdata p;
+unsigned char * __xdata p;
 \newline 
 
 \newline 
-/* the following is a function pointer physically located in data space
- */
+/* generic pointer physically located in default memory space */
+\newline 
+unsigned char * p;
+\newline 
+
+\newline 
+/* the following is a function pointer
+\begin_inset LatexCommand \index{function pointer}
+
+\end_inset 
+
+ physically located in data space */
 \newline 
 char (* __data fp)(void);
 \layout Standard
@@ -9848,8 +10248,12 @@ generic
 \end_inset 
 
  routines.
- Explicitly specifying the pointer type will generate the most efficient
- code.
+ Explicitly specifying the pointer
+\begin_inset LatexCommand \index{pointer}
+
+\end_inset 
+
+ type will generate the most efficient code.
 \layout Subsubsection
 
 Notes on MCS51 memory
@@ -10143,7 +10547,7 @@ status Collapsed
  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}
@@ -10166,7 +10570,7 @@ The linker generates two files with memory allocation information.
 \layout Subsection
 
 Z80/Z180 Storage Class
-\begin_inset LatexCommand \index{Storage class}
+\begin_inset LatexCommand \index{Z80!Storage class}
 
 \end_inset 
 
@@ -10203,6 +10607,16 @@ utput memory.
  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.:
@@ -10316,13 +10730,13 @@ sfr
 \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
@@ -10333,13 +10747,18 @@ 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 
 
-=z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
+ z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
 ns 
 \family typewriter 
 in0/out0
@@ -10353,7 +10772,7 @@ in/out
 \layout Subsection
 
 HC08 Storage Class
-\begin_inset LatexCommand \index{Storage class}
+\begin_inset LatexCommand \index{HC08!Storage class}
 
 \end_inset 
 
@@ -10375,8 +10794,12 @@ data
 
 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
@@ -10391,7 +10814,7 @@ 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.
@@ -10445,10 +10868,10 @@ xdata
 
 \end_inset 
 
(0x7ffe) unsigned int chksum;
0x7ffe unsigned int chksum;
 \layout Standard
 
-or
+or, better conforming to ISO/IEC 9899 C:
 \layout Verse
 
 
@@ -10470,6 +10893,7 @@ collapsed true
 
 
 \series bold 
+\SpecialChar ~
 !
 \end_inset 
 
@@ -10502,6 +10926,7 @@ collapsed true
 
 
 \series bold 
+\SpecialChar ~
 !
 \end_inset 
 
@@ -10572,7 +10997,7 @@ Absolute addresses can be specified for variables in all storage classes,
 
 
 \family typewriter 
-bit
+__bit
 \begin_inset LatexCommand \index{bit}
 
 \end_inset 
@@ -10602,19 +11027,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 ~
@@ -10750,7 +11175,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 
@@ -10766,13 +11191,13 @@ bit __at
 \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 ~
@@ -10784,19 +11209,19 @@ 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 
@@ -10807,7 +11232,7 @@ bit
 \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
@@ -10978,19 +11403,19 @@ 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 
@@ -11058,8 +11483,12 @@ Parameters
 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
@@ -11209,7 +11638,7 @@ set_error(10);
 \newline 
 }
 \layout Standard
-
+\added_space_bottom bigskip 
 In the above example the parameter 
 \emph on 
 errcd
@@ -11285,7 +11714,12 @@ interrupt
 \emph default 
  keyword is the interrupt number this routine will service.
  When present, the compiler will insert a call to this routine in the interrupt
- vector table for the interrupt number specified.
+ vector table
+\begin_inset LatexCommand \index{interrupt vector table}
+
+\end_inset 
+
+ for the interrupt number specified.
  If you have multiple source files in your project, interrupt service routines
  can be present in any of them, but a prototype of the isr MUST be present
  or included in the file that contains the function 
@@ -11293,7 +11727,7 @@ interrupt
 main
 \emph default 
 .
- The optional 
+ The optional (8051 specific) keyword 
 \emph on 
 using
 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
@@ -11307,15 +11741,23 @@ using
 
 
 \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 
@@ -11327,7 +11769,22 @@ volatile
 \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 
@@ -11343,8 +11800,10 @@ atomic
  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 
@@ -11401,8 +11860,19 @@ counter\SpecialChar ~
 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
@@ -11433,6 +11903,16 @@ deepest
 
  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
@@ -11455,8 +11935,7 @@ 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
@@ -11498,22 +11977,45 @@ status Collapsed
 \end_inset 
 
  compiler option.
- Note, the type promotion
+\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 without the programmer
- being aware of it.
+ required by ANSI C can cause 16 bit routines to be used
+\begin_inset Marginal
+collapsed true
+
 \layout Standard
 
-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
- it should be preceded by a #pragma\SpecialChar ~
-nooverlay
-\begin_inset LatexCommand \index{\#pragma nooverlay}
+
+\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
+ it should be preceded by a #pragma\SpecialChar ~
+nooverlay
+\begin_inset LatexCommand \index{\#pragma nooverlay}
 
 \end_inset 
 
@@ -11528,9 +12030,7 @@ nooverlay
 \emph default 
  if all parameters are passed in registers.
 \newline 
-
-\newline 
-Also see section 
+ Also see section 
 \begin_inset LatexCommand \ref{sub:Overlaying}
 
 \end_inset 
@@ -11548,10 +12048,19 @@ about Functions using private register banks.
 MCS51/DS390 Interrupt Service Routines
 \layout Standard
 
-Interrupt numbers and the corresponding address & descriptions for the Standard
- 8051/8052 are listed below.
- SDCC will automatically adjust the interrupt vector table to the maximum
- interrupt number specified.
+Interrupt
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset 
+
+ numbers and the corresponding address & descriptions for the Standard 8051/8052
+ are listed below.
+ SDCC will automatically adjust the 
+\begin_inset LatexCommand \index{interrupt vector table}
+
+\end_inset 
+
+ to the maximum interrupt number specified.
 \newline 
 
 \layout Standard
@@ -11829,7 +12338,7 @@ using
  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 
@@ -11837,16 +12346,31 @@ a, b, dptr
 \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}
 
-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.
+\end_inset 
+
+ 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
@@ -11861,7 +12385,16 @@ Since the number of interrupts available is chip specific and the interrupt
 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.
@@ -11892,7 +12425,7 @@ void nmi_isr (void) critical interrupt
 \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 
@@ -12133,7 +12666,12 @@ On other architectures which have seperate opcodes for enabling and disabling
 
 \end_inset 
 
- (HC08):
+ (HC08
+\begin_inset LatexCommand \index{HC08!interrupt}
+
+\end_inset 
+
+):
 \layout Verse
 
 
@@ -12407,7 +12945,23 @@ possible exception: if a function is called ONLY from 'interrupt' functions
 \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 
@@ -12447,7 +13001,7 @@ used
  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
@@ -12515,7 +13069,12 @@ _sdcc_external_startup()
 \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
@@ -12561,6 +13120,25 @@ opt
 
 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
 
+\end_inset 
+
+, 
+\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 
@@ -12568,21 +13146,30 @@ opt
 
 \end_inset 
 
-\SpecialChar ~
-about MCS51-variants.
+ about MCS51-variants.
 \layout Subsection
 
 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}
+
+\end_inset 
 
-On the Z80 the startup code is inserted by linking with crt0.o which is generated
from sdcc/device/lib/z80/crt0.s.
+ 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 
 -
@@ -12638,7 +13225,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 
@@ -12665,7 +13252,85 @@ unsigned char far
 
 
 \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 
@@ -12694,12 +13359,13 @@ needed
 
  to integer */
 \begin_inset Marginal
-collapsed false
+collapsed true
 
 \layout Standard
 
 
 \series bold 
+\SpecialChar ~
 !
 \end_inset 
 
@@ -12799,7 +13465,22 @@ mov\SpecialChar ~
 \SpecialChar ~
 r2,dpl 
 \newline 
-;buffer.c if( head != (unsigned char)(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 ~
@@ -12936,7 +13617,7 @@ 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;
 \newline 
@@ -13201,13 +13882,8 @@ _endasm
 \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)}
 
@@ -13218,11 +13894,16 @@ The assembler does not like some characters like ':' or ''' in comments.
 
 \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}
@@ -13461,12 +14142,16 @@ For an 8051 target, the generated simpleInterrupt looks like:
 
 \family typewriter 
 Note, this is an 
-\series bold 
+\emph on 
 outdated
-\series default 
+\emph default 
  example, recent versions of SDCC generate
 \newline 
-the same code for simpleInterrupt() and nakedInterrupt()!
+the 
+\emph on 
+same
+\emph default 
+ code for simpleInterrupt() and nakedInterrupt()!
 \newline 
 
 \newline 
@@ -14309,7 +14994,7 @@ pop  _bp
 \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
@@ -14625,9 +15310,9 @@ Floating Point Support
 
 \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
@@ -15260,7 +15945,7 @@ convert long to floating point number
 \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
@@ -15461,6 +16146,48 @@ and
 not
 \emph default 
  support long variables and field widths).
+\layout Subsubsection
+
+<malloc.h>
+\begin_inset LatexCommand \index{malloc.h}
+
+\end_inset 
+
+
+\layout Standard
+
+As of SDCC 2.6.2 you no longer need to call an initialization routine before
+ using dynamic memory allocation
+\begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
+
+\end_inset 
+
+ and a default heap
+\begin_inset LatexCommand \index{heap (malloc)}
+
+\end_inset 
+
+ space of 1024 bytes is provided for malloc to allocate memory from.
+ If you need a different heap size you need to recompile _heap.c with the
+ required size defined in HEAP_SIZE.
+ It is recommended to make a copy of this file into your project directory
+ and compile it there with:
+\layout Verse
+
+
+\family typewriter 
+sdcc -c _heap.c -D HEAD_SIZE=2048
+\newline 
+
+\family default 
+And then link it with:
+\layout Verse
+
+
+\family typewriter 
+sdcc main.rel _heap.rel
+\newline 
+
 \layout Subsection
 
 Math functions (sinf, powf, sqrtf etc.)
@@ -15517,7 +16244,9 @@ C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
 
 \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.
@@ -15774,6 +16503,11 @@ status Collapsed
 \layout Section
 
 Pragmas
+\begin_inset LatexCommand \label{sec:Pragmas}
+
+\end_inset 
+
+
 \begin_inset LatexCommand \index{Pragmas}
 
 \end_inset 
@@ -15784,17 +16518,25 @@ Pragmas
 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 
@@ -15809,7 +16551,11 @@ save.
 
 \layout Itemize
 
+
+\series bold 
 callee_saves
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma callee\_saves}
 
 \end_inset 
@@ -15855,7 +16601,11 @@ callee_saves
  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 
@@ -15907,7 +16657,11 @@ none
 .
 \layout Itemize
 
+
+\series bold 
 less_pedantic
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
 
 \end_inset 
@@ -15916,7 +16670,11 @@ less_pedantic
  your own now ;-(
 \layout Itemize
 
-disable_warning <nnnn>
+
+\series bold 
+disable_warning
+\series default 
+ <nnnn>
 \begin_inset LatexCommand \index{\#pragma disable\_warning}
 
 \end_inset 
@@ -15924,7 +16682,11 @@ disable_warning <nnnn>
  - 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 
@@ -15932,7 +16694,11 @@ nogcse
  - will stop global common subexpression elimination.
 \layout Itemize
 
+
+\series bold 
 noinduction
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma noinduction}
 
 \end_inset 
@@ -15940,7 +16706,11 @@ noinduction
  - will stop loop induction optimizations.
 \layout Itemize
 
+
+\series bold 
 noinvariant
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma noinvariant}
 
 \end_inset 
@@ -15954,7 +16724,11 @@ noinvariant
 .
 \layout Itemize
 
+
+\series bold 
 noiv
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma noiv}
 
 \end_inset 
@@ -15964,7 +16738,12 @@ noiv
 
 \end_inset 
 
- vector table entries for all ISR functions defined after the pragma.
+ vector table
+\begin_inset LatexCommand \index{interrupt vector table}
+
+\end_inset 
+
+ entries for all ISR functions defined after the pragma.
  This is useful in cases where the interrupt vector table must be defined
  manually, or when there is a secondary, manually defined interrupt vector
  table (e.g.
@@ -15979,7 +16758,11 @@ noiv
 about interrupts.
 \layout Itemize
 
+
+\series bold 
 nojtbound
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma nojtbound}
 
 \end_inset 
@@ -15994,7 +16777,11 @@ nojtbound
 .
 \layout Itemize
 
+
+\series bold 
 noloopreverse
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma noloopreverse}
 
 \end_inset 
@@ -16002,7 +16789,11 @@ noloopreverse
  - Will not do loop reversal optimization
 \layout Itemize
 
+
+\series bold 
 nooverlay
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma nooverlay}
 
 \end_inset 
@@ -16011,7 +16802,11 @@ nooverlay
  function.
 \layout Itemize
 
+
+\series bold 
 stackauto
+\series default 
+
 \begin_inset LatexCommand \index{\#pragma stackauto}
 
 \end_inset 
@@ -16039,25 +16834,39 @@ status Collapsed
  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 
@@ -16068,7 +16877,11 @@ opt_code_balanced
  
 \layout Itemize
 
-std_sdcc89 
+
+\series bold 
+std_sdcc89
+\series default 
 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
 
 \end_inset 
@@ -16077,7 +16890,11 @@ std_sdcc89
  with the standard (default).
 \layout Itemize
 
-std_c89 
+
+\series bold 
+std_c89
+\series default 
 \begin_inset LatexCommand \index{\#pragma std\_c89}
 
 \end_inset 
@@ -16086,7 +16903,11 @@ std_c89
  standard.
 \layout Itemize
 
-std_sdcc99 
+
+\series bold 
+std_sdcc99
+\series default 
 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
 
 \end_inset 
@@ -16095,7 +16916,11 @@ std_sdcc99
  with the standard (incomplete support).
 \layout Itemize
 
-std_c99 
+
+\series bold 
+std_c99
+\series default 
 \begin_inset LatexCommand \index{\#pragma std\_c99}
 
 \end_inset 
@@ -16104,7 +16929,11 @@ std_c99
  standard (incomplete support).
 \layout Itemize
 
-codeseg <name>
+
+\series bold 
+codeseg
+\series default 
+ <name>
 \begin_inset LatexCommand \index{\#pragma codeseg}
 
 \end_inset 
@@ -16124,7 +16953,11 @@ status Collapsed
 -codeseg.
 \layout Itemize
 
-constseg <name>
+
+\series bold 
+constseg
+\series default 
+ <name>
 \begin_inset LatexCommand \index{\#pragma constseg}
 
 \end_inset 
@@ -16144,16 +16977,213 @@ status Collapsed
 -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 
+pedantic_parse_number
+\series default 
+
+\begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
+
+\end_inset 
+
+ (+ | -) - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are
+ parsed properly and the macro LO_B(3) gets expanded.
+ Default is off.
+ Below is an example on how to use this pragma.
+
+\emph on 
+ Note: this functionality is not in conformance with standard!
+\layout Verse
+
+
+\family typewriter 
+#pragma pedantic_parse_number +
+\begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
+
+\end_inset 
+
+
+\newline 
+
+\newline 
+#define LO_B(x) ((x) & 0xff)
+\newline 
+
+\newline 
+unsigned char foo(void)
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+unsigned char c=0xfe-LO_B(3);
+\newline 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return c;
+\newline 
+}
+\newline 
+
 \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 Itemize
+
+
+\series bold 
+sdcc_hash
+\series default 
+
+\begin_inset LatexCommand \index{\#pragma sdcc\_hash}
+
+\end_inset 
+
+ (+ | -) - Allow "naked" hash in macro definition, for example:
+\newline 
+
+\family typewriter 
+#define DIR_LO(x) #(x & 0xff)
+\family default 
+
+\newline 
+Default is off.
+ Below is an example on how to use this pragma.
+\layout Verse
+
+
+\family typewriter 
+#pragma preproc_asm +
+\newline 
+#pragma sdcc_hash +
+\begin_inset LatexCommand \index{\#pragma sdcc\_hash}
+
+\end_inset 
+
+
+\newline 
+
+\newline 
+#define ROMCALL(x) 
+\backslash 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov R6_B3, #(x & 0xff) 
+\backslash 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov R7_B3, #((x >> 8) & 0xff) 
+\backslash 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+lcall __romcall
+\newline 
+
+\newline 
+...
+\newline 
+_asm
+\newline 
+ROMCALL(72)
+\newline 
+_endasm;
+\newline 
+...
+\newline 
+
 \layout Standard
 
 The pragma's are intended to be used to turn-on or off certain optimizations
@@ -16232,6 +17262,12 @@ int foo ()
 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
@@ -16256,8 +17292,8 @@ The compiler creates the following #defines
 \begin_inset  Tabular
 <lyxtabular version="3" rows="11" columns="2">
 <features>
-<column alignment="left" valignment="top" leftline="true" width="0">
-<column alignment="left" 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
@@ -16326,7 +17362,7 @@ SDCC_mcs51
 
 \end_inset 
 
-, etc
+, etc.
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -16334,7 +17370,7 @@ SDCC_mcs51
 
 \layout Standard
 
-depending on the model used (e.g.: -mds390
+depending on the model used (e.g.: -mds390)
 \end_inset 
 </cell>
 </row>
@@ -16690,17 +17726,17 @@ sfr
 
 
 \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.
@@ -16714,7 +17750,7 @@ 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}
 
@@ -16728,8 +17764,18 @@ Some MCS51 variants offer features like Double DPTR
 
 DS400 port
 \layout Standard
+\added_space_bottom bigskip 
+The DS80C400
+\begin_inset LatexCommand \index{DS80C400}
 
-The DS80C400 microcontroller has a rich set of peripherals.
+\end_inset 
+
+
+\begin_inset LatexCommand \index{DS400}
+
+\end_inset 
+
+ 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
@@ -16747,7 +17793,7 @@ The DS80C400 microcontroller has a rich set of peripherals.
 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 
@@ -16767,15 +17813,20 @@ regressions tests
 
 
 \emph default 
- as the MCS51 and DS390 ports, so floating point support, support for long
+ (see section 
+\begin_inset LatexCommand \ref{sec:Quality-control}
+
+\end_inset 
+
+) as the MCS51 and DS390 ports, so floating point support, support for long
  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 
 
@@ -16783,7 +17834,7 @@ As always, the code is the authoritative reference - see z80/ralloc.c and
  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 
 
@@ -16797,7 +17848,7 @@ As always, the code is the authoritative reference - see z80/ralloc.c and
 The HC08 port
 \layout Standard
 
-The port to the Motorola HC08
+The port to the Freescale/Motorola HC08
 \begin_inset LatexCommand \index{HC08}
 
 \end_inset 
@@ -16808,12 +17859,16 @@ The port to the Motorola HC08
  unoptimized.
  Some of the SDCC's standard C library functions have embedded non-HC08
  inline assembly and so are not yet usable.
-\newline 
+\layout Standard
+\added_space_bottom bigskip 
+The HC08 port passes the regression test suite (see section 
+\begin_inset LatexCommand \ref{sec:Quality-control}
 
-\newline 
+\end_inset 
 
+).
 \layout Section
-
+\pagebreak_top 
 The PIC14 port
 \layout Standard
 
@@ -16823,7 +17878,17 @@ The 14bit PIC
 \end_inset 
 
  port still requires a major effort from the development community.
- However it can work for very simple code.
+ However it can work for simple code.
+ It passes its (smaller set of) regression tests
+\begin_inset LatexCommand \index{Regression test (PIC14)}
+
+\end_inset 
+
+ in the directory 
+\shape italic 
+sdcc/src/regression
+\shape default 
+.
 \layout Subsection
 
 C code and 14bit PIC code page
@@ -16847,19 +17912,13 @@ The linker organizes allocation for the code page and RAM banks.
  used.
  The compiler treats all functions of a single C file as being in the same
  code page unless it is non static.
- The compiler treats all local variables of a single C file as being in
- the same RAM bank unless it is an extern.
 \newline 
 
 \newline 
 To get the best follow these guide lines:
 \layout Enumerate
 
-make local functions static, as non static functions require code page selection
- overhead.
-\layout Enumerate
-
-Make local variables static as extern variables require RAM bank selection
+Make local functions static, as non static functions require code page selection
  overhead.
 \layout Enumerate
 
@@ -16868,24 +17927,29 @@ For devices that have multiple code pages it is more efficient to use the
  for the 16F877 use 4 separate files and i.e.
  for the 16F874 use 2 separate files.
  This way the linker can put the code for each file into different code
- pages and the compiler can allocate reusable variables more efficiently
- and there's less page selection overhead.
+ pages and there's less page selection overhead.
+\layout Enumerate
+
  And as for any 8 bit micro (especially for PIC 14 as they have a very simple
- instruction set) use 'unsigned char' whereever possible instead of 'int'.
+ instruction set), use 'unsigned char' whereever possible instead of 'int'.
 \layout Subsection
 
 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}
+For the interrupt function, use the keyword '__interrupt'
+\begin_inset LatexCommand \index{PIC14!interrupt}
 
 \end_inset 
 
@@ -16896,7 +17960,7 @@ For the interrupt function, use the keyword 'interrupt'
 
 
 \family typewriter 
-void Intr(void) interrupt 0
+void Intr(void) __interrupt 0
 \newline 
 {
 \newline 
@@ -17055,7 +18119,51 @@ status Collapsed
 /
 \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
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-no-pcode-opt
+\begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
+
+\end_inset 
+
+ disable (slightly faulty) optimization on pCode
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-stack-loc
+\begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
+
+\end_inset 
+
+ sets the lowest address of the argument passing stack (defaults to a suitably
+ large shared databank to reduce BANKSEL overhead)
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -17069,7 +18177,12 @@ status Collapsed
 /
 \end_inset 
 
--no-pcode-opt disable (slightly faulty) optimization on pCode
+-stack-size
+\begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
+
+\end_inset 
+
+ sets the size if the argument passing stack (default: 16, minimum: 4)
 \layout Subsection
 
 The library
@@ -17116,7 +18229,12 @@ XXX
 \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
@@ -17150,8 +18268,23 @@ main()
 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}
 
@@ -17409,7 +18542,12 @@ status Collapsed
 /
 \end_inset 
 
--callee-saves See -
+-callee-saves
+\begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
+
+\end_inset 
+
+ See -
 \begin_inset ERT
 status Collapsed
 
@@ -17433,7 +18571,12 @@ 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.
@@ -17450,8 +18593,12 @@ status Collapsed
 /
 \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
@@ -17483,7 +18630,7 @@ status Collapsed
 /
 \end_inset 
 
--stack-model=[model] Used in conjuction with the command above.
+-pstack-model=[model] Used in conjuction with the command above.
  Defines the stack model to be used, valid stack models are : 
 \begin_deeper 
 \layout List
@@ -17579,7 +18726,12 @@ status Collapsed
 /
 \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
 
@@ -17854,8 +19006,12 @@ NO_REG_OPT do not perform pCode registers optimization.
 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 
 
@@ -18236,12 +19392,27 @@ Pragmas
 
 \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 
@@ -18294,18 +19465,12 @@ If the stack_size field is omitted then a stack is created with the default
 \layout List
 \labelwidthstring 00.00.0000
 
-wparam 
-\emph on 
-This pragma is deprecated.
- Its use will cause a warning message to be issued.
-\emph default 
-
-\newline 
+code
+\begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
 
-\layout List
-\labelwidthstring 00.00.0000
+\end_inset 
 
-code place a function symbol at static FLASH address
+ place a function symbol at static FLASH address
 \layout LyX-Code
 
 Example:
@@ -18663,8 +19828,17 @@ Header Files
 
 \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
@@ -18686,7 +19860,12 @@ The specific microcontroller is selected within the pic18fregs.h automatically,
 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 
@@ -18903,8 +20082,13 @@ The standard device libraries (see
 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
 
@@ -19067,12 +20251,21 @@ These limitations are caused by the fact that only FSRxL is modified when
 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.
@@ -19096,15 +20289,17 @@ void func_wparam(int a) wparam
 \layout LyX-Code
 
 }
-\layout Standard
-
-This keyword replaces the deprecated wparam pragma.
 \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
@@ -19268,7 +20463,12 @@ on stack, FSR0 points to the beginning
 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 
@@ -19585,7 +20785,7 @@ rest of the pointer
 
 \layout Standard
 
-descrption
+description
 \end_inset 
 </cell>
 </row>
@@ -20199,7 +21399,7 @@ void main(void)
 {
 \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 */
@@ -20793,7 +21993,12 @@ Here you can find some general tips for compiling programs with SDCC/pic16.
 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.
@@ -20821,6 +22026,34 @@ status Collapsed
 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
  stack frames.
  Other ways to reduce stack usage may exist.
+\layout Subsection
+
+Known bugs
+\layout Standard
+
+The PIC16 Port currently does not pass SDCC's regression test
+\begin_inset LatexCommand \index{Regression test (PIC16)}
+
+\end_inset 
+
+ suite (see section 
+\begin_inset LatexCommand \ref{sec:Quality-control}
+
+\end_inset 
+
+) and thus the nightly regression tests for the PIC16 target are currently
+ disabled for all hosts except for 
+\emph on 
+Linux on Opteron.
+
+\emph default 
+ This means you can see the result of the PIC16 regression tests f.e.
+ by checking the log files in 
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/regression_test_results/amd64-unknown-linux2.3/}
+
+\end_inset 
+
+ (pick the most up to date file there, scroll down, lend a hand).
 \layout Chapter
 
 Debugging
@@ -20937,9 +22170,9 @@ 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 a good example of a monitor with a very liberal licence is
- paulmon (
-\begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
+ For the 8051 good examples of monitors are paulmon and cmon51 (see section
+\begin_inset LatexCommand \ref{sec:Related-open-source-tools}
 
 \end_inset 
 
@@ -20953,7 +22186,7 @@ e.
 digital oscilloscope
 \emph default 
 
-\begin_inset LatexCommand \index{oscilloscope}
+\begin_inset LatexCommand \index{Oscilloscope}
 
 \end_inset 
 
@@ -21085,7 +22318,7 @@ Debugging with SDCDB
 \end_inset 
 
 
-\begin_inset LatexCommand \index{sdcdb (debugger)}
+\begin_inset LatexCommand \index{SDCDB (debugger)}
 
 \end_inset 
 
@@ -21110,7 +22343,6 @@ on, which also builds and installs the debugger in the target directory
  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 Subsection
 
 Compiling for Debugging
@@ -21172,7 +22404,7 @@ 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.
- (Currently sdcdb only connects to the simulator but 
+ (Currently SDCDM only connects to the simulator but 
 \emph on 
 newcdb
 \emph default 
@@ -21453,13 +22685,26 @@ bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
 \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://svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/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 
 
@@ -22383,6 +23628,18 @@ Use the smallest data type to represent your data-value.
  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.
@@ -22471,6 +23728,8 @@ comp.lang.c FAQ
 :
 \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.
@@ -22499,70 +23758,6 @@ Declare the variables to be local
  whenever possible, especially loop control variables (induction).
 \layout Itemize
 
-Since the compiler does not always do implicit integral promotion, the programme
-r should do an explicit cast when integral promotion is required.
-\layout Itemize
-
-Reducing the size of division, multiplication & modulus operations can reduce
- code size substantially.
- Take the following code for example.
-\begin_deeper 
-\layout Verse
-
-
-\family typewriter 
-foobar(unsigned int p1, unsigned char ch)
-\newline 
-{
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-unsigned char ch1 = p1 % ch ;
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-....
-\newline 
-}
-\layout Standard
-
-For the modulus operation the variable ch will be promoted to unsigned int
- first then the modulus operation will be performed (this will lead to a
- call to support routine _moduint()), and the result will be casted to a
- char.
- If the code is changed to 
-\layout Verse
-
-
-\family typewriter 
-foobar(unsigned int p1, unsigned char ch)
-\newline 
-{
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-unsigned char ch1 = (unsigned char)p1 % ch ;
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-....
-\newline 
-}
-\layout Standard
-
-It would substantially reduce the code generated (future versions of the
- compiler will be smart enough to detect such optimization opportunities).
-\end_deeper 
-\layout Itemize
-
 Have a look at the assembly listing to get a 
 \begin_inset Quotes sld
 \end_inset 
@@ -22575,23 +23770,50 @@ feeling
 \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 for compiler specific syntax.
- Eventually include the file <compiler.h
-\begin_inset LatexCommand \index{compiler.h (include file)}
+check the device specific header files
+\begin_inset LatexCommand \index{Header files}
 
 \end_inset 
 
-> to allow using common header files.
-\layout Itemize
 
-check whether the startup code contains the correct initialization (watchdog,
- peripherals).
-\layout Itemize
+\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 
+
+> 
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
+
+\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/cc2510fx.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
@@ -22611,7 +23833,10 @@ last
 \emph on 
 not
 \emph default 
- the same as endianness).check whether the keyword 
+ the same as endianness).
+\layout Itemize
+
+check whether the keyword 
 \emph on 
 volatile
 \emph default 
@@ -22619,6 +23844,12 @@ volatile
  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.
@@ -22628,10 +23859,48 @@ 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 
+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 
@@ -22641,7 +23910,7 @@ operator on bit variables.
 
 \end_inset 
 
-).
+.
 \layout Itemize
 
 check the assembly code generated for interrupt routines (f.e.
@@ -22652,11 +23921,37 @@ 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)
- char variables as integers others as char).
+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 layout.
+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
@@ -22666,7 +23961,7 @@ Tools
 
  included in the distribution
 \layout Standard
-\align center 
+\align left 
 
 \begin_inset  Tabular
 <lyxtabular version="3" rows="12" columns="3">
@@ -22680,6 +23975,8 @@ Tools
 
 \layout Standard
 
+
+\series bold 
 Name
 \end_inset 
 </cell>
@@ -22688,6 +23985,8 @@ Name
 
 \layout Standard
 
+
+\series bold 
 Purpose
 \end_inset 
 </cell>
@@ -22696,6 +23995,8 @@ Purpose
 
 \layout Standard
 
+
+\series bold 
 Directory
 \end_inset 
 </cell>
@@ -22706,7 +24007,7 @@ Directory
 
 \layout Standard
 
-uCsim
+ucSsim
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -22740,7 +24041,17 @@ keil2sdcc.pl
 
 \layout Standard
 
-header file conversion
+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">
@@ -22889,7 +24200,7 @@ sdcc/bin
 
 \layout Standard
 
-sdcdb
+SDCDB
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -23037,7 +24348,12 @@ packihx
 
 \layout Standard
 
-ihx packer
+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">
@@ -23074,19 +24390,21 @@ Documentation
 
  included in the distribution
 \layout Standard
-\align center 
+\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">
+<column alignment="block" valignment="top" leftline="true" width="40col%">
+<column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
+<row topline="true" bottomline="true" endhead="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+
+\series bold 
 Subject / Title
 \end_inset 
 </cell>
@@ -23095,7 +24413,9 @@ Subject / Title
 
 \layout Standard
 
-Where to get / filename
+
+\series bold 
+Filename / Where to get
 \end_inset 
 </cell>
 </row>
@@ -23114,6 +24434,22 @@ SDCC Compiler User Guide
 \layout Standard
 
 You're reading it right now
+\emph on 
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23132,6 +24468,22 @@ Changelog of SDCC
 \layout Standard
 
 sdcc/Changelog
+\emph on 
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23151,7 +24503,9 @@ ASXXXX
 
 \end_inset 
 
- Assemblers and ASLINK
+ Assemblers and
+\newline 
+ASLINK
 \begin_inset LatexCommand \index{aslink}
 
 \end_inset 
@@ -23169,7 +24523,23 @@ ASXXXX
 
 \layout Standard
 
-sdcc/as/doc/asxhtm.html
+sdcc/as/doc/asxhtm.html 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23192,7 +24562,23 @@ SDCC regression test
 
 \layout Standard
 
-sdcc/doc/test_suite_spec.pdf
+sdcc/doc/test_suite_spec.pdf 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23210,7 +24596,23 @@ Various notes
 
 \layout Standard
 
-sdcc/doc/*
+sdcc/doc/* 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23220,8 +24622,8 @@ sdcc/doc/*
 
 \layout Standard
 
-Notes on debugging with sdcdb
-\begin_inset LatexCommand \index{sdcdb (debugger)}
+Notes on debugging with SDCDB
+\begin_inset LatexCommand \index{SDCDB (debugger)}
 
 \end_inset 
 
@@ -23233,7 +24635,23 @@ Notes on debugging with sdcdb
 
 \layout Standard
 
-sdcc/debugger/README
+sdcc/debugger/README 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at
+\emph default 
+:
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23269,7 +24687,23 @@ sdcc/sim/ucsim/doc
 \bar default 
 \noun default 
 \color default
-/index.html
+/index.html 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23292,7 +24726,23 @@ Temporary notes on the pic16
 
 \layout Standard
 
-sdcc/src/pic16/NOTES
+sdcc/src/pic16/NOTES 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\newline 
+
+\emph default 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23329,6 +24779,22 @@ cdbfileformat.pd
 \noun default 
 \color default
 f
+\emph on 
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
 \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 
 
 
 \layout Standard
-\align center 
+\align left 
 
 \begin_inset  Tabular
-<lyxtabular version="3" rows="13" columns="3">
+<lyxtabular version="3" rows="14" columns="3">
 <features>
 <column alignment="left" valignment="top" leftline="true" width="0pt">
 <column alignment="block" valignment="top" leftline="true" width="30line%">
@@ -23362,6 +24833,8 @@ Related open source tools
 
 \layout Standard
 
+
+\series bold 
 Name
 \end_inset 
 </cell>
@@ -23370,6 +24843,8 @@ Name
 
 \layout Standard
 
+
+\series bold 
 Purpose
 \end_inset 
 </cell>
@@ -23378,6 +24853,8 @@ Purpose
 
 \layout Standard
 
+
+\series bold 
 Where to get
 \end_inset 
 </cell>
@@ -23499,7 +24976,7 @@ ec2drv/newcdb
 
 \layout Standard
 
-Tools for Silicon Laboratories JTAG debug adapter, partly based on sdcdb
+Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
  (Unix only)
 \end_inset 
 </cell>
@@ -23626,12 +25103,7 @@ Part of binutils (should be there anyway)
 
 \layout Standard
 
-doxygen
-\begin_inset LatexCommand \index{doxygen (source documentation tool)}
-
-\end_inset 
-
-
+cmon51
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -23639,7 +25111,7 @@ doxygen
 
 \layout Standard
 
-Source code documentation system
+8051 monitor (hex up-/download, single step, disassemble)
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -23648,7 +25120,7 @@ Source code documentation system
 \layout Standard
 
 
-\begin_inset LatexCommand \url{http://www.doxygen.org}
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
 
 \end_inset 
 
@@ -23662,7 +25134,12 @@ Source code documentation system
 
 \layout Standard
 
-kdevelop
+doxygen
+\begin_inset LatexCommand \index{doxygen (source documentation tool)}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -23670,7 +25147,7 @@ kdevelop
 
 \layout Standard
 
-IDE (has anyone tried integrating SDCC & sdcdb? Unix only)
+Source code documentation system
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -23679,7 +25156,38 @@ IDE (has anyone tried integrating SDCC & sdcdb? Unix only)
 \layout Standard
 
 
-\begin_inset LatexCommand \url{http://www.kdevelop.org}
+\begin_inset LatexCommand \url{http://www.doxygen.org}
+
+\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
+
+kdevelop
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+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">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset LatexCommand \url{http://www.kdevelop.org}
 
 \end_inset 
 
@@ -23766,7 +25274,7 @@ Statically checks c sources (see
 \layout Standard
 
 ddd
-\begin_inset LatexCommand \index{ddd (debugger)}
+\begin_inset LatexCommand \index{DDD (debugger)}
 
 \end_inset 
 
@@ -23778,8 +25286,8 @@ ddd
 
 \layout Standard
 
-Debugger, serves nicely as GUI to sdcdb
-\begin_inset LatexCommand \index{sdcdb (debugger)}
+Debugger, serves nicely as GUI to SDCDB
+\begin_inset LatexCommand \index{SDCDB (debugger)}
 
 \end_inset 
 
@@ -23811,20 +25319,22 @@ Debugger, serves nicely as GUI to sdcdb
 
 Related documentation / recommended reading
 \layout Standard
-\align center 
+\align left 
 
 \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="left" valignment="top" leftline="true" width="0pt">
+<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
 
+
+\series bold 
 Name
 \end_inset 
 </cell>
@@ -23833,6 +25343,8 @@ Name
 
 \layout Standard
 
+
+\series bold 
 Subject / Title
 \end_inset 
 </cell>
@@ -23841,6 +25353,8 @@ Subject / Title
 
 \layout Standard
 
+
+\series bold 
 Where to get
 \end_inset 
 </cell>
@@ -23904,7 +25418,12 @@ c-faq
 
 \layout Standard
 
-C-FAQ-list
+C-FAQ
+\begin_inset LatexCommand \index{C FAQ}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -23913,7 +25432,7 @@ C-FAQ-list
 \layout Standard
 
 
-\begin_inset LatexCommand \url{http://www.eskimo.com/~scs/C-faq/top.html}
+\begin_inset LatexCommand \url{http://www.c-faq.com}
 
 \end_inset 
 
@@ -23927,6 +25446,7 @@ C-FAQ-list
 
 \layout Standard
 
+ISO/IEC 9899:TC2
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -23934,7 +25454,15 @@ C-FAQ-list
 
 \layout Standard
 
-Latest datasheet of the target CPU
+
+\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">
@@ -23942,7 +25470,14 @@ Latest datasheet of the target CPU
 
 \layout Standard
 
-vendor
+
+\size footnotesize 
+
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -23952,6 +25487,7 @@ vendor
 
 \layout Standard
 
+ISO/IEC DTR 18037
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -23959,7 +25495,47 @@ vendor
 
 \layout Standard
 
-Revision history of datasheet
+
+\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>
+<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
+
+Latest datasheet of target CPU
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -23977,9 +25553,6 @@ vendor
 
 \layout Standard
 
-S.
- S.
- Muchnick
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -23987,7 +25560,7 @@ S.
 
 \layout Standard
 
-Advanced Compiler Design and Implementation
+Revision history of datasheet
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -23995,7 +25568,7 @@ Advanced Compiler Design and Implementation
 
 \layout Standard
 
-bookstore (very dedicated, probably read other books first)
+vendor
 \end_inset 
 </cell>
 </row>
@@ -24008,1415 +25581,1559 @@ bookstore (very dedicated, probably read other books first)
 
 \layout Section
 
-Some Questions
+Application notes specifically for SDCC
 \layout Standard
 
-Some questions answered, some pointers given - it might be time to in turn
- ask 
-\emph on 
-you
-\emph default 
- some questions: 
-\layout Itemize
+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}
 
-can you solve your project with the selected microcontroller? Would you
- find out early or rather late that your target is too small/slow/whatever?
- Can you switch to a slightly better device if it doesn't fit?
-\layout Itemize
+\end_inset 
 
-should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
- and/or another programming language be more adequate? Would an operating
- system on the target device help?
-\layout Itemize
+.
+\layout Standard
+\align left 
 
-if you solved the problem, will the marketing department be happy?
-\layout Itemize
+\size footnotesize 
 
-if the marketing department is happy, will customers be happy?
-\layout Itemize
+\begin_inset  Tabular
+<lyxtabular version="3" rows="7" columns="3">
+<features>
+<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
 
-if you're the project manager, marketing department and maybe even the customer
- in one person, have you tried to see the project from the outside?
-\layout Itemize
+\layout Standard
 
-is the project done if you think it is done? Or is just that other interface/pro
-tocol/feature/configuration/option missing? How about website, manual(s),
- internationali(z|s)ation, packaging, labels, 2nd source for components,
- electromagnetic compatability/interference, documentation for production,
- production test software, update mechanism, patent issues?
-\layout Itemize
 
-is your project adequately positioned in that magic triangle: fame, fortune,
- fun?
+\series bold 
+\size footnotesize 
+Vendor
+\end_inset 
+</cell>
+<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
+\begin_inset Text
+
 \layout Standard
 
-Maybe not all answers to these questions are known and some answers may
- even be 
-\emph on 
-no
-\emph defaul
-, nevertheless knowing these questions may help you to avoid burnout
-\begin_inset Foot
-collapsed false
+
+\series bold 
+\size footnotesize 
+Subject / Title
+\end_inse
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-burnout is bad for electronic devices, programmers and motorcycle tyres
+
+\series bold 
+\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
 
-.
- Chances are you didn't want to hear some of them...
-\layout Chapter
+\layout Standard
 
-Support
-\begin_inset LatexCommand \index{Support}
 
+\size footnotesize 
+Maxim / Dallas
 \end_inset 
-
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-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).
- 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 users.
- Is SDCC perfect? No, that's why we need your help.
- The developers take pride in fixing reported bugs.
- You can help by reporting the bugs and helping other SDCC users.
- There are lots of ways to contribute, and we encourage you to take part
- in making SDCC a great software package.
-\layout Standard
 
-The SDCC project is hosted on the SDCC sourceforge site at 
-\begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
+\size footnotesize 
+Using the SDCC Compiler for the DS80C400
+\begin_inset LatexCommand \index{DS80C400}
 
 \end_inset 
 
-.
- You'll find the complete set of mailing lists
-\begin_inset LatexCommand \index{Mailing list(s)}
 
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-, forums, bug reporting system, patch submission
-\begin_inset LatexCommand \index{Patch submission}
+\layout Standard
 
-\end_inset 
 
- system, download
-\begin_inset LatexCommand \index{download}
+\size footnotesize 
+
+\begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
 
 \end_inset 
 
- area and Subversion code repository
-\begin_inset LatexCommand \index{Subversion code repository}
 
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- there.
-\layout Section
+\layout Standard
 
-Reporting Bugs
-\begin_inset LatexCommand \index{Bug reporting}
 
+\size footnotesize 
+Maxim / Dallas
 \end_inset 
+</cell>
+<cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
+\begin_inset Text
 
+\layout Standard
 
-\begin_inset LatexCommand \index{Reporting bugs}
+
+\size footnotesize 
+Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
+\begin_inset LatexCommand \index{DS89C4x0}
 
 \end_inset 
 
+ Family of Microcontrollers
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-The recommended way of reporting bugs is using the infrastructure of the
- sourceforge site.
- You can follow the status of bug reports there and have an overview about
- the known bugs.
-\layout Standard
 
-Bug reports are automatically forwarded to the developer mailing list and
- will be fixed ASAP.
- When reporting a bug, it is very useful to include a small test program
- (the smaller the better) which reproduces the problem.
- If you can isolate the problem by looking at the generated assembly code,
- this can be very helpful.
- Compiling your program with the -
-\begin_inset ERT
-status Collapsed
+\size footnotesize 
 
-\layout Standard
+\begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
 
-\backslash 
-/
 \end_inset 
 
--dumpall
-\begin_inset LatexCommand \index{-\/-dumpall}
 
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- option can sometimes be useful in locating optimization problems.
- When reporting a bug please maker sure you:
-\layout Enumerate
-
-Attach the code you are compiling with SDCC.
-\layout Enumerate
-
-Specify the exact command you use to run SDCC, or attach your Makefile.
-\layout Enumerate
+\layout Standard
 
-Specify the SDCC version (type "
-\family sans 
-\series bold 
-sdcc -v
-\family default 
-\series default 
-"), your platform, and operating system.
-\layout Enumerate
 
-Provide an exact copy of any error message or incorrect output.
-\layout Enumerate
+\size footnotesize 
+Silicon Laboratories / Cygnal
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-Put something meaningful in the subject of your message.
 \layout Standard
 
-Please attempt to include these 5 important parts, as applicable, in all
- requests for support or when reporting any problems or bugs with SDCC.
- Though this will make your message lengthy, it will greatly improve your
- chance that SDCC users and developers will be able to help you.
- Some SDCC developers are frustrated by bug reports without code provided
- that they can use to reproduce and ultimately fix the problem, so please
- be sure to provide sample code if you are reporting a bug! 
-\layout Standard
 
-Please have a short check that you are using a recent version of SDCC and
- the bug is not yet known.
- This is the link for reporting bugs: 
-\begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
+\size footnotesize 
+Integrating SDCC 8051 Tools Into The Silicon Labs IDE
+\begin_inset LatexCommand \index{IDE}
 
 \end_inset 
 
-.
-\layout Section
-
-Requesting Features
-\begin_inset LatexCommand \label{sub:Requesting-Features}
 
 \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{Feature request}
-
-\end_inset 
 
+\size footnotesize 
 
-\begin_inset LatexCommand \index{Requesting features}
+\begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
 
 \end_inset 
 
 
-\layout Standard
-
-Like bug reports feature requests are forwarded to the developer mailing
- list.
- This is the link for requesting features: 
-\begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
-
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-.
-\layout Section
-
-Submitting patches
 \layout Standard
 
-Like bug reports contributed patches are forwarded to the developer mailing
- list.
- This is the link for submitting patches
-\begin_inset LatexCommand \index{Patch submission}
-
-\end_inset 
-
-: 
-\begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
 
+\size footnotesize 
+Ramtron / Goal Semiconductor
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-.
 \layout Standard
 
-You need to specify some parameters to the 
-\family typewriter 
-diff
-\family default 
- command for the patches to be useful.
- If you modified more than one file a patch created f.e.
- with 
-\family sans 
-\series bold 
 
-\begin_inset Quotes sld
+\size footnotesize 
+Interfacing SDCC to Syn and Textpad
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-diff -Naur unmodified_directory modified_directory >my_changes.patch
-\begin_inset Quotes srd
-\end_inset 
+\layout Standard
 
 
-\family default 
-\series default 
- will be fine, otherwise 
-\family sans 
-\series bold 
+\size footnotesize 
 
-\begin_inset Quotes sld
-\end_inset 
+\begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
 
-diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
-\begin_inset Quotes srd
 \end_inset 
 
 
-\series default 
-\family default 
-will do.
-\layout Section
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-Getting Help
 \layout Standard
 
-These links should take you directly to the 
-\begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
 
+\size footnotesize 
+Ramtron / Goal Semiconductor
 \end_inset 
-
-
-\begin_inset Foot
-collapsed false
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
- automated messages (mid 2003)
-\end_inset 
-
- and the 
-\begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
-
-\end_inset 
-
-, lists
-\begin_inset LatexCommand \index{Mailing list(s)}
 
+\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">
+\begin_inset Text
 
- and forums are archived and searchable so if you are lucky someone already
- had a similar problem.
- While mails to the lists themselves are delivered promptly their web front
- end on sourceforge sometimes shows a severe time lag (up to several weeks),
- if you're seriously using SDCC please consider subscribing to the lists.
-\layout Section
-
-ChangeLog
 \layout Standard
 
-You can follow the status of the Subversion version
-\begin_inset LatexCommand \index{version}
 
-\end_inset 
+\size footnotesize 
 
- of SDCC by watching the Changelog
-\begin_inset LatexCommand \index{Changelog}
+\begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
 
 \end_inset 
 
- in the Subversion repository
-\size footnotesize 
-\begin_inset LatexCommand \htmlurl{http://svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
 
 \end_inset 
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-.
-\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}
 
+\size footnotesize 
+Texas Instruments
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- (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
+\layout Standard
 
-Release policy
-\begin_inset LatexCommand \index{Release policy}
 
+\size footnotesize 
+MSC12xx Programming with SDCC
 \end_inset 
-
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-Historically there often were long delays between official releases and
- the sourceforge download area tends to get not updated at all.
- Excuses in the past might have referred to problems with live range analysis,
- but as this was fixed a while ago, the current problem is that another
- excuse has to be found.
- Kidding aside, we have to get better there! On the other hand there are
- daily snapshots available at 
-\begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
 
-\end_inset 
+\size footnotesize 
 
-, and you can always build the very last version (hopefully with many bugs
- fixed, and features added) from the source code available at 
-\begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
+\begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
 
 \end_inset 
 
-.
-\layout Section
 
-Examples
-\begin_inset LatexCommand \index{Examples}
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
 
 \end_inset 
 
 
+\layout Section
+
+Some Questions
 \layout Standard
 
-You'll find some small examples in the directory 
+Some questions answered, some pointers given - it might be time to in turn
+ ask 
 \emph on 
-sdcc/device/examples/.
+you
 \emph default 
-More examples and libraries are available at
-\emph on 
- The SDCC Open Knowledge Resource 
-\begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
-
-\end_inset 
-
-\emph default 
-web site or at 
-\begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
-
-\end_inset 
+ some questions: 
+\layout Itemize
 
-.
-\layout Comment
+can you solve your project with the selected microcontroller? Would you
+ find out early or rather late that your target is too small/slow/whatever?
+ Can you switch to a slightly better device if it doesn't fit?
+\layout Itemize
 
-I did insert a reference to Paul's web site here although it seems rather
- dedicated to a specific 8032 board (I think it's okay because it f.e.
- shows LCD/Harddisc interface and has a free 8051 monitor.
- Independent 8032 board vendors face hard competition of heavily subsidized
- development boards anyway).
-\layout Comment
+should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
+ and/or another programming language be more adequate? Would an operating
+ system on the target device help?
+\layout Itemize
 
-Maybe we should include some links to real world applications.
- Preferably pointer to pointers (one for each architecture) so this stays
- manageable here?
-\layout Section
+if you solved the problem, will the marketing department be happy?
+\layout Itemize
 
-Quality control
-\begin_inset LatexCommand \index{Quality control}
+if the marketing department is happy, will customers be happy?
+\layout Itemize
 
-\end_inset 
+if you're the project manager, marketing department and maybe even the customer
+ in one person, have you tried to see the project from the outside?
+\layout Itemize
 
+is the project done if you think it is done? Or is just that other interface/pro
+tocol/feature/configuration/option missing? How about website, manual(s),
+ internationali(z|s)ation, packaging, labels, 2nd source for components,
+ electromagnetic compatability/interference, documentation for production,
+ production test software, update mechanism, patent issues?
+\layout Itemize
 
+is your project adequately positioned in that magic triangle: fame, fortune,
+ fun?
 \layout Standard
 
-The compiler is passed through nightly compile and build checks.
- The so called 
-\shape italic 
-regression tests
-\shape default 
+Maybe not all answers to these questions are known and some answers may
+ even be 
+\emph on 
+no
+\emph default 
+, nevertheless knowing these questions may help you to avoid burnout
+\begin_inset Foot
+collapsed false
 
-\begin_inset LatexCommand \index{Regression test}
+\layout Standard
 
+burnout is bad for electronic devices, programmers and motorcycle tyres
 \end_inset 
 
- check that SDCC itself compiles flawlessly on several platforms and checks
- the quality of the code generated by SDCC by running the code through simulator
-s.
- There is a separate document 
-\shape italic 
-test_suite.pdf
-\begin_inset LatexCommand \index{Test suite}
+.
+ Chances are you didn't want to hear some of them...
+\layout Chapter
+
+Support
+\begin_inset LatexCommand \index{Support}
 
 \end_inset 
 
 
-\shape default 
- about this.
 \layout Standard
 
-You'll find the test code in the directory 
-\shape italic 
-sdcc/support/regression
-\shape default 
-.
- You can run these tests manually by running 
-\family sans 
-make
-\family default 
- in this directory (or f.e.
+SDCC has grown to be a large project.
+ The compiler alone (without the preprocessor, assembler and linker) is
+ 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 users.
+ Is SDCC perfect? No, that's why we need your help.
+ The developers take pride in fixing reported bugs.
+ You can help by reporting the bugs and helping other SDCC users.
+ There are lots of ways to contribute, and we encourage you to take part
+ in making SDCC a great software package.
  
-\family sans 
-\series bold 
+\layout Standard
 
-\begin_inset Quotes sld
-\end_inset 
+The SDCC project is hosted on the SDCC sourceforge site at 
+\begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
 
-make test-mcs51
-\begin_inset Quotes srd
 \end_inset 
 
-
-\family default 
-\series default 
- if you don't want to run the complete tests).
- The test code might also be interesting if you want to look for examples
-\begin_inset LatexCommand \index{Examples}
+.
+ You'll find the complete set of mailing lists
+\begin_inset LatexCommand \index{Mailing list(s)}
 
 \end_inset 
 
- checking corner cases of SDCC or if you plan to submit patches
+, forums, bug reporting system, patch submission
 \begin_inset LatexCommand \index{Patch submission}
 
 \end_inset 
 
-.
-\layout Standard
-
-The pic port uses a different set of regression tests, you'll find them
- in the directory 
-\shape italic 
-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
+ system, download
+\begin_inset LatexCommand \index{download}
 
-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}
+ area and Subversion code repository
+\begin_inset LatexCommand \index{Subversion code repository}
 
 \end_inset 
 
-, 
-\begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
-
-\end_inset 
+ there.
+\layout Section
 
-), over assembly programming, to C to FPGA compilers (
-\begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
+Reporting Bugs
+\begin_inset LatexCommand \index{Bug reporting}
 
 \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}
+\begin_inset LatexCommand \index{Reporting bugs}
 
 \end_inset 
 
-, following some 
-\begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
 
-\end_inset 
+\layout Standard
 
-, understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
- Source Software, CPU simulation, compiler regression tests
-\begin_inset LatexCommand \index{Regression test}
+The recommended way of reporting bugs is using the infrastructure of the
+ sourceforge site.
+ You can follow the status of bug reports there and have an overview about
+ the known bugs.
+\layout Standard
 
-\end_inset 
+Bug reports are automatically forwarded to the developer mailing list and
+ will be fixed ASAP.
+ When reporting a bug, it is very useful to include a small test program
+ (the smaller the better) which reproduces the problem.
+ If you can isolate the problem by looking at the generated assembly code,
+ this can be very helpful.
+ Compiling your program with the -
+\begin_inset ERT
+status Collapsed
 
-.
-\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}
+\layout Standard
 
+\backslash 
+/
 \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://wiki.laptop.org/wiki/One_Laptop_per_Child}
+-dumpall
+\begin_inset LatexCommand \index{-\/-dumpall}
 
 \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
+ option can sometimes be useful in locating optimization problems.
+ When reporting a bug please make sure you:
 \layout Enumerate
 
-be able to change to a new target platform without having to adopt a new
- tool chain
+Attach the code you are compiling with SDCC.
 \layout Enumerate
 
-have complete control over and insight into the tool chain
+Specify the exact command you use to run SDCC, or attach your Makefile.
 \layout Enumerate
 
-make your students aware about the pros and cons of open source software
- development
+Specify the SDCC version (type "
+\family sans 
+\series bold 
+sdcc -v
+\family default 
+\series default 
+"), your platform, and operating system.
 \layout Enumerate
 
-give back to the public as you are probably at least partially publically
- funded
+Provide an exact copy of any error message or incorrect output.
 \layout Enumerate
 
-give students a chance to publically prove their skills and to possibly
- see a world wide impact
+Put something meaningful in the subject of your message.
 \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
-\layout Section
+Please attempt to include these 5 important parts, as applicable, in all
+ requests for support or when reporting any problems or bugs with SDCC.
+ Though this will make your message lengthy, it will greatly improve your
+ chance that SDCC users and developers will be able to help you.
+ Some SDCC developers are frustrated by bug reports without code provided
+ that they can use to reproduce and ultimately fix the problem, so please
+ be sure to provide sample code if you are reporting a bug! 
+\layout Standard
 
-Optimizations
-\begin_inset LatexCommand \index{Optimizations}
+Please have a short check that you are using a recent version of SDCC and
+ the bug is not yet known.
+ This is the link for reporting bugs: 
+\begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
 
 \end_inset 
 
-
-\layout Standard
-
-SDCC performs a host of standard optimizations in addition to some MCU specific
- optimizations.
-\layout Subsection
-
-Sub-expression Elimination
-\begin_inset LatexCommand \index{Subexpression elimination}
+.
+ 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
 
-The compiler does local and 
-\emph on 
-g
-\emph default 
-lobal 
-\emph on 
-c
-\emph default 
-ommon 
-\emph on 
-s
-\emph default 
-ubexpression 
+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 
-e
+reporting bugs is good
 \emph default 
-limination, e.g.: 
-\layout Verse
-
+.
+\layout Section
 
-\family typewriter 
-i = x + y + 1; 
-\newline 
-j = x + y;
-\layout Standard
+Requesting Features
+\begin_inset LatexCommand \label{sub:Requesting-Features}
 
-will be translated to
-\layout Verse
+\end_inset 
 
 
-\family typewriter 
-iTemp = x + y; 
-\newline 
-i = iTemp + 1; 
-\newline 
-j = iTemp;
-\layout Standard
+\begin_inset LatexCommand \index{Feature request}
 
-Some subexpressions are not as obvious as the above example, e.g.:
-\layout Verse
+\end_inset 
 
 
-\family typewriter 
-a->b[i].c = 10; 
-\newline 
-a->b[i].d = 11;
-\layout Standard
+\begin_inset LatexCommand \index{Requesting features}
 
-In this case the address arithmetic a->b[i] will be computed only once;
- the equivalent code in C would be.
-\layout Verse
+\end_inset 
 
 
-\family typewriter 
-iTemp = a->b[i]; 
-\newline 
-iTemp.c = 10; 
-\newline 
-iTemp.d = 11;
 \layout Standard
 
-The compiler will try to keep these temporary variables in registers.
-\layout Subsection
-
-Dead-Code Elimination
-\begin_inset LatexCommand \index{Dead-code elimination}
+Like bug reports feature requests are forwarded to the developer mailing
+ list.
+ This is the link for requesting features: 
+\begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
 
 \end_inset 
 
+.
+\layout Section
 
-\layout Verse
+Submitting patches
+\layout Standard
 
+Like bug reports contributed patches are forwarded to the developer mailing
+ list.
+ This is the link for submitting patches
+\begin_inset LatexCommand \index{Patch submission}
 
-\family typewriter 
-int global;
-\newline 
+\end_inset 
 
-\newline 
-void f () { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-int i; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-i = 1; \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-/* dead store */ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-global = 1;\SpecialChar ~
-/* dead store */ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-global = 2; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-return; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-global = 3;\SpecialChar ~
-/* unreachable */ 
-\newline 
-}
-\layout Standard
+: 
+\begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
 
-will be changed to
-\layout Verse
+\end_inset 
 
+.
+\layout Standard
 
+You need to specify some parameters to the 
 \family typewriter 
-int global;
-\newline 
-
-\newline 
-void f () {
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-global = 2; 
-\newline 
-}
-\layout Subsection
+diff
+\family default 
+ command for the patches to be useful.
+ If you modified more than one file a patch created f.e.
+ with 
+\family sans 
+\series bold 
 
-Copy-Propagation
-\begin_inset LatexCommand \index{Copy propagation}
+\begin_inset Quotes sld
+\end_inset 
 
+diff -Naur unmodified_directory modified_directory >my_changes.patch
+\begin_inset Quotes srd
 \end_inset 
 
 
-\layout Verse
+\family default 
+\series default 
+ will be fine, otherwise 
+\family sans 
+\series bold 
 
+\begin_inset Quotes sld
+\end_inset 
 
-\family typewriter 
-int f() { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-int i, j; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-i = 10; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-j = i; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-return j; 
-\newline 
-}
-\layout Standard
+diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
+\begin_inset Quotes srd
+\end_inset 
 
-will be changed to 
-\layout Verse
 
+\series default 
+\family default 
+will do.
+\layout Section
 
-\family typewriter 
-int f() { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-int i, j; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-i = 10; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-j = 10; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-return 10; 
-\newline 
-}
+Getting Help
 \layout Standard
 
-Note: the dead stores created by this copy propagation will be eliminated
- by dead-code elimination.
-\layout Subsection
-
-Loop Optimizations
-\begin_inset LatexCommand \index{Loop optimization}
+These links should take you directly to the 
+\begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
 
 \end_inset 
 
 
-\begin_inset LatexCommand \label{sub:Loop-Optimizations}
-
-\end_inset 
-
+\begin_inset Foot
+collapsed false
 
 \layout Standard
 
-Two types of loop optimizations are done by SDCC 
-\emph on 
-loop invariant
-\emph default 
- lifting and
-\emph on 
- strength reduction
-\emph default 
- of loop induction variables.
- In addition to the strength reduction the optimizer marks the induction
- variables and the register allocator tries to keep the induction variables
- in registers for the duration of the loop.
- Because of this preference of the register allocator
-\begin_inset LatexCommand \index{Register allocation}
+Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
+ automated messages (mid 2003)
+\end_inset 
+
+ and the 
+\begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
 
 \end_inset 
 
-, loop induction optimization causes an increase in register pressure, which
- may cause unwanted spilling of other temporary variables into the stack
-\begin_inset LatexCommand \index{stack}
+, lists
+\begin_inset LatexCommand \index{Mailing list(s)}
 
 \end_inset 
 
- / data space.
- The compiler will generate a warning message when it is forced to allocate
- extra space either on the stack or data space.
- If this extra space allocation is undesirable then induction optimization
- can be eliminated either for the entire source file (with -
-\begin_inset ERT
-status Collapsed
+ and forums are archived and searchable so if you are lucky someone already
+ had a similar problem.
+ While mails to the lists themselves are delivered promptly their web front
+ end on sourceforge sometimes shows a severe time lag (up to several weeks),
+ if you're seriously using SDCC please consider subscribing to the lists.
+\layout Section
 
+ChangeLog
 \layout Standard
 
-\backslash 
-/
+You can follow the status of the Subversion version
+\begin_inset LatexCommand \index{version}
+
 \end_inset 
 
--noinduction option) or for a given function only using #pragma\SpecialChar ~
-noinduction
-\begin_inset LatexCommand \index{\#pragma noinduction}
+ of SDCC by watching the Changelog
+\begin_inset LatexCommand \index{Changelog}
 
 \end_inset 
 
-.
-\newline 
+ in the Subversion repository
+\size footnotesize 
+\begin_inset LatexCommand \htmlurl{http://svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
 
-\newline 
-Loop Invariant:
-\layout Verse
+\end_inset 
 
+.
+\layout Section
 
-\family typewriter 
-for (i = 0 ; i < 100 ; i ++) 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-f += k + l;
+Subversion Source Code Repository
 \layout Standard
 
-changed to
-\layout Verse
+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 
 
-\family typewriter 
-itemp = k + l; 
-\newline 
-for (i = 0; i < 100; i++) 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-f += itemp;
-\layout Standard
+ number.
+ Subversion allows to download the source of recent or previous versions
+\begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
 
-As mentioned previously some loop invariants are not as apparent, all static
- address computations are also moved out of the loop.
-\newline 
+\end_inset 
 
-\newline 
-Strength Reduction
-\begin_inset LatexCommand \index{Strength reduction}
+ (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 
 
-, this optimization substitutes an expression by a cheaper expression:
-\layout Verse
-
+ to Subversion (April 2006) are either by accessible by Subversion or by
+ cvs).
+\layout Section
 
-\family typewriter 
-for (i=0;i < 100; i++)
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-ar[i*5] = i*3;
-\layout Standard
+Release policy
+\begin_inset LatexCommand \index{Release policy}
 
-changed to
-\layout Verse
+\end_inset 
 
 
-\family typewriter 
-itemp1 = 0; 
-\newline 
-itemp2 = 0; 
-\newline 
-for (i=0;i< 100;i++) { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-ar[itemp1] = itemp2; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-itemp1 += 5; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-itemp2 += 3; 
-\newline 
-}
 \layout Standard
 
-The more expensive multiplication
-\begin_inset LatexCommand \index{Multiplication}
+Historically there often were long delays between official releases and
+ the sourceforge download area tends to get not updated at all.
+ Excuses in the past might have referred to problems with live range analysis,
+ but as this was fixed a while ago, the current problem is that another
+ excuse has to be found.
+ Kidding aside, we have to get better there! On the other hand there are
+ daily snapshots available at 
+\begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
 
 \end_inset 
 
- is changed to a less expensive addition.
-\layout Subsection
+, and you can always build the very last version (hopefully with many bugs
+ fixed, and features added) from the source code available at 
+\begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
 
-Loop Reversing
-\begin_inset LatexCommand \index{Loop reversing}
+\end_inset 
+
+.
+ A release wiki
+\begin_inset LatexCommand \index{wiki}
 
 \end_inset 
 
 
-\layout Standard
+\begin_inset LatexCommand \index{Release wiki}
 
-This optimization is done to reduce the overhead of checking loop boundaries
- for every iteration.
- Some simple loops can be reversed and implemented using a 
-\begin_inset Quotes eld
 \end_inset 
 
-decrement and jump if not zero
-\begin_inset Quotes erd
+ at 
+\begin_inset LatexCommand \url{http://sdcc.sf.net/release_wiki/}
+
 \end_inset 
 
- instruction.
- SDCC checks for the following criterion to determine if a loop is reversible
- (note: more sophisticated compilers use data-dependency analysis to make
- this determination, SDCC uses a more simple minded analysis).
-\layout Itemize
+ also holds some information about past and future releases.
+\layout Section
 
-The 'for' loop is of the form 
-\newline 
+Examples
+\begin_inset LatexCommand \index{Examples}
 
-\newline 
+\end_inset 
 
-\family typewriter 
-for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
- += 1])
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-<for body>
-\layout Itemize
 
-The <for body> does not contain 
-\begin_inset Quotes eld
-\end_inset 
+\layout Standard
+
+You'll find some small examples in the directory 
+\emph on 
+sdcc/device/examples/.
+\emph default 
+More examples and libraries are available at
+\emph on 
+ The SDCC Open Knowledge Resource 
+\begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
 
-continue
-\begin_inset Quotes erd
 \end_inset 
 
- or 'break
-\begin_inset Quotes erd
+\emph default 
+web site or at 
+\begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
+
 \end_inset 
 
 .
-\layout Itemize
+\layout Comment
 
-All goto's are contained within the loop.
-\layout Itemize
+I did insert a reference to Paul's web site here although it seems rather
+ dedicated to a specific 8032 board (I think it's okay because it f.e.
+ shows LCD/Harddisc interface and has a free 8051 monitor.
+ Independent 8032 board vendors face hard competition of heavily subsidized
+ development boards anyway).
+\layout Comment
 
-No function calls within the loop.
-\layout Itemize
+Maybe we should include some links to real world applications.
+ Preferably pointer to pointers (one for each architecture) so this stays
+ manageable here?
+\layout Section
 
-The loop control variable <sym> is not assigned any value within the loop
-\layout Itemize
+Quality control
+\begin_inset LatexCommand \label{sec:Quality-control}
 
-The loop control variable does NOT participate in any arithmetic operation
- within the loop.
-\layout Itemize
+\end_inset 
 
-There are NO switch statements in the loop.
-\layout Subsection
 
-Algebraic Simplifications
-\layout Standard
+\begin_inset LatexCommand \index{Quality control}
 
-SDCC does numerous algebraic simplifications, the following is a small sub-set
- of these optimizations.
-\layout Verse
+\end_inset 
 
 
-\family typewriter 
-i = j + 0;\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- /* changed to: */\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- i = j; 
-\newline 
-i /= 2;\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- /* changed to: */\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- i >>= 1; 
-\newline 
-i = j - j;\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- /* changed to: */\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- i = 0; 
-\newline 
-i = j / 1;\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- /* changed to: */\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- i = j;
 \layout Standard
 
-Note the subexpressions
-\begin_inset LatexCommand \index{Subexpression}
+The compiler is passed through nightly compile and build checks.
+ The so called 
+\shape italic 
+regression tests
+\shape default 
+
+\begin_inset LatexCommand \index{Regression test}
 
 \end_inset 
 
- given above are generally introduced by macro expansions or as a result
- of copy/constant propagation.
-\layout Subsection
+ check that SDCC itself compiles flawlessly on several host platforms (i386,
+ Opteron, 64 bit Alpha, ppc64, MacOS X on PPC, Solaris on Sparc) and checks
+ the quality of the code generated by SDCC by running the code for several
+ target platforms through simulators.
+ The regression test suite comprises more than 100 files which expand to
+ more than 500 test cases which include more than 4500 tests.
+ The results of these tests are published daily on SDCC's snapshot page
+ (click on the red or green symbols on the right side of 
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
 
-'switch' Statements
-\begin_inset LatexCommand \label{sub:'switch'-Statements}
+\end_inset 
+
+).
+\layout Standard
+
+There is a separate document 
+\shape italic 
+test_suite.pdf 
+\begin_inset LatexCommand \index{Test suite}
 
 \end_inset 
 
 
-\begin_inset LatexCommand \index{switch statement}
+\shape default 
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
+
+\end_inset 
+
+ about the regression test suite.
+\layout Standard
+
+You'll find the test code in the directory 
+\shape italic 
+sdcc/support/regression
+\shape default 
+.
+ You can run these tests manually by running 
+\family sans 
+make
+\family default 
+ in this directory (or f.e.
+\family sans 
+\series bold 
+
+\begin_inset Quotes sld
+\end_inset 
+
+make test-mcs51
+\begin_inset Quotes srd
+\end_inset 
+
+
+\family default 
+\series default 
+ if you don't want to run the complete tests).
+ The test code might also be interesting if you want to look for examples
+\begin_inset LatexCommand \index{Examples}
 
 \end_inset 
 
+ checking corner cases of SDCC or if you plan to submit patches
+\begin_inset LatexCommand \index{Patch submission}
+
+\end_inset 
 
+.
 \layout Standard
 
-SDCC can optimize switch statements to jump tables
-\begin_inset LatexCommand \index{jump tables}
+The 14bit pic port uses a different set of regression tests 
+\begin_inset LatexCommand \index{Regression test (PIC14)}
 
 \end_inset 
 
+, you'll find them in the directory 
+\shape italic 
+sdcc/src/regression
+\shape default 
 .
- It makes the decision based on an estimate of the generated code size.
- SDCC is quite liberal in the requirements for jump table generation: 
-\layout Itemize
+\layout Section
 
-The labels need not be in order, and the starting number need not be one
- or zero, the case labels are in numerical sequence or not too many case
- labels are missing.
-\begin_deeper 
-\layout Verse
+Use of SDCC in Education
+\layout Standard
+
+In short: 
+\emph on 
+highly
+\emph default 
+ encouraged
+\begin_inset Foot
+collapsed false
 
+\layout Standard
 
-\family typewriter 
-switch(i) {\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 ~
-switch (i) { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-case 4: ...\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 ~
-case 0: ...
+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 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-case 5: ...\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 ~
-case 1: ...
+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
+\layout Section
+
+Optimizations
+\begin_inset LatexCommand \index{Optimizations}
+
+\end_inset 
+
+
+\layout Standard
+
+SDCC performs a host of standard optimizations in addition to some MCU specific
+ optimizations.
  
+\layout Subsection
+
+Sub-expression Elimination
+\begin_inset LatexCommand \index{Subexpression elimination}
+
+\end_inset 
+
+
+\layout Standard
+
+The compiler does local and 
+\emph on 
+g
+\emph default 
+lobal 
+\emph on 
+c
+\emph default 
+ommon 
+\emph on 
+s
+\emph default 
+ubexpression 
+\emph on 
+e
+\emph default 
+limination, e.g.: 
+\layout Verse
+
+
+\family typewriter 
+i = x + y + 1; 
+\newline 
+j = x + y;
+\layout Standard
+
+will be translated to
+\layout Verse
+
+
+\family typewriter 
+iTemp = x + y; 
+\newline 
+i = iTemp + 1; 
+\newline 
+j = iTemp;
+\layout Standard
+
+Some subexpressions are not as obvious as the above example, e.g.:
+\layout Verse
+
+
+\family typewriter 
+a->b[i].c = 10; 
+\newline 
+a->b[i].d = 11;
+\layout Standard
+
+In this case the address arithmetic a->b[i] will be computed only once;
+ the equivalent code in C would be.
+\layout Verse
+
+
+\family typewriter 
+iTemp = a->b[i]; 
+\newline 
+iTemp.c = 10; 
+\newline 
+iTemp.d = 11;
+\layout Standard
+
+The compiler will try to keep these temporary variables in registers.
+\layout Subsection
+
+Dead-Code Elimination
+\begin_inset LatexCommand \index{Dead-code elimination}
+
+\end_inset 
+
+
+\layout Verse
+
+
+\family typewriter 
+int global;
+\newline 
+
+\newline 
+void f () { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-case 3: ...\SpecialChar ~
-\SpecialChar ~
+int i; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+i = 1; \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+/* dead store */ 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+global = 1;\SpecialChar ~
+/* dead store */ 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+global = 2; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+return; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+global = 3;\SpecialChar ~
+/* unreachable */ 
+\newline 
+}
+\layout Standard
+
+will be changed to
+\layout Verse
+
+
+\family typewriter 
+int global;
+\newline 
+
+\newline 
+void f () {
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+global = 2; 
+\newline 
+}
+\layout Subsection
+
+Copy-Propagation
+\begin_inset LatexCommand \index{Copy propagation}
+
+\end_inset 
+
+
+\layout Verse
+
+
+\family typewriter 
+int f() { 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+int i, j; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+i = 10; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+j = i; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+return j; 
+\newline 
+}
+\layout Standard
+
+will be changed to 
+\layout Verse
+
 
+\family typewriter 
+int f() { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-case 6: ...\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
+int i, j; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+i = 10; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+j = 10; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-case 3: ...
+return 10; 
+\newline 
+}
+\layout Standard
+
+Note: the dead stores created by this copy propagation will be eliminated
+ by dead-code elimination.
+\layout Subsection
+
+Loop Optimizations
+\begin_inset LatexCommand \index{Loop optimization}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \label{sub:Loop-Optimizations}
+
+\end_inset 
+
+
+\layout Standard
+
+Two types of loop optimizations are done by SDCC 
+\emph on 
+loop invariant
+\emph default 
+ lifting and
+\emph on 
+ strength reduction
+\emph default 
+ of loop induction variables.
+ In addition to the strength reduction the optimizer marks the induction
+ variables and the register allocator tries to keep the induction variables
+ in registers for the duration of the loop.
+ Because of this preference of the register allocator
+\begin_inset LatexCommand \index{Register allocation}
+
+\end_inset 
+
+, loop induction optimization causes an increase in register pressure, which
+ may cause unwanted spilling of other temporary variables into the stack
+\begin_inset LatexCommand \index{stack}
+
+\end_inset 
+
+ / data space.
+ The compiler will generate a warning message when it is forced to allocate
+ extra space either on the stack or data space.
+ If this extra space allocation is undesirable then induction optimization
+ can be eliminated either for the entire source file (with -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-noinduction option) or for a given function only using #pragma\SpecialChar ~
+noinduction
+\begin_inset LatexCommand \index{\#pragma noinduction}
+
+\end_inset 
+
+.
+\newline 
+
+\newline 
+Loop Invariant:
+\layout Verse
+
+
+\family typewriter 
+for (i = 0 ; i < 100 ; i ++) 
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-case 7: ...\SpecialChar ~
-\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+f += k + l;
+\layout Standard
+
+changed to
+\layout Verse
+
+
+\family typewriter 
+itemp = k + l; 
+\newline 
+for (i = 0; i < 100; i++) 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+f += itemp;
+\layout Standard
+
+As mentioned previously some loop invariants are not as apparent, all static
+ address computations are also moved out of the loop.
+\newline 
+
+\newline 
+Strength Reduction
+\begin_inset LatexCommand \index{Strength reduction}
+
+\end_inset 
+
+, this optimization substitutes an expression by a cheaper expression:
+\layout Verse
+
+
+\family typewriter 
+for (i=0;i < 100; i++)
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ar[i*5] = i*3;
+\layout Standard
+
+changed to
+\layout Verse
+
+
+\family typewriter 
+itemp1 = 0; 
+\newline 
+itemp2 = 0; 
+\newline 
+for (i=0;i< 100;i++) { 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ar[itemp1] = itemp2; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+itemp1 += 5; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 4: ...
+itemp2 += 3; 
+\newline 
+}
+\layout Standard
+
+The more expensive multiplication
+\begin_inset LatexCommand \index{Multiplication}
+
+\end_inset 
+
+ is changed to a less expensive addition.
+\layout Subsection
+
+Loop Reversing
+\begin_inset LatexCommand \index{Loop reversing}
+
+\end_inset 
+
+
+\layout Standard
+
+This optimization is done to reduce the overhead of checking loop boundaries
+ for every iteration.
+ Some simple loops can be reversed and implemented using a 
+\begin_inset Quotes eld
+\end_inset 
+
+decrement and jump if not zero
+\begin_inset Quotes erd
+\end_inset 
+
+ instruction.
+ SDCC checks for the following criterion to determine if a loop is reversible
+ (note: more sophisticated compilers use data-dependency analysis to make
+ this determination, SDCC uses a more simple minded analysis).
+\layout Itemize
+
+The 'for' loop is of the form 
+\newline 
+
+\newline 
+
+\family typewriter 
+for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
+ += 1])
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-case 8: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+<for body>
+\layout Itemize
+
+The <for body> does not contain 
+\begin_inset Quotes eld
+\end_inset 
+
+continue
+\begin_inset Quotes erd
+\end_inset 
+
+ or 'break
+\begin_inset Quotes erd
+\end_inset 
+
+.
+\layout Itemize
+
+All goto's are contained within the loop.
+\layout Itemize
+
+No function calls within the loop.
+\layout Itemize
+
+The loop control variable <sym> is not assigned any value within the loop
+\layout Itemize
+
+The loop control variable does NOT participate in any arithmetic operation
+ within the loop.
+\layout Itemize
+
+There are NO switch statements in the loop.
+\layout Subsection
+
+Algebraic Simplifications
+\layout Standard
+
+SDCC does numerous algebraic simplifications, the following is a small sub-set
+ of these optimizations.
+\layout Verse
+
+
+\family typewriter 
+i = j + 0;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ /* changed to: */\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ i = j; 
+\newline 
+i /= 2;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ /* changed to: */\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ i >>= 1; 
+\newline 
+i = j - j;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ /* changed to: */\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 5: ...
+ i = 0; 
 \newline 
+i = j / 1;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 9: ...\SpecialChar ~
-\SpecialChar ~
+ /* changed to: */\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ i = j;
+\layout Standard
+
+Note the subexpressions
+\begin_inset LatexCommand \index{Subexpression}
+
+\end_inset 
+
+ given above are generally introduced by macro expansions or as a result
+ of copy/constant propagation.
+\layout Subsection
+
+'switch' Statements
+\begin_inset LatexCommand \label{sub:'switch'-Statements}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{switch statement}
+
+\end_inset 
+
+
+\layout Standard
+
+SDCC can optimize switch statements to jump tables
+\begin_inset LatexCommand \index{jump tables}
+
+\end_inset 
+
+.
+ It makes the decision based on an estimate of the generated code size.
+ SDCC is quite liberal in the requirements for jump table generation: 
+\layout Itemize
+
+The labels need not be in order, and the starting number need not be one
+ or zero, the case labels are in numerical sequence or not too many case
+ labels are missing.
+\begin_deeper 
+\layout Verse
+
+
+\family typewriter 
+switch(i) {\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -25438,13 +27155,16 @@ case 9: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 6: ...
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+switch (i) { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 10: ...\SpecialChar ~
+case 4: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -25469,13 +27189,14 @@ case 10: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 7: ...
+\SpecialChar ~
+case 0: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 11: ...\SpecialChar ~
+case 5: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -25500,13 +27221,14 @@ case 11: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 8: ...
+\SpecialChar ~
+case 1: ...
  
 \newline 
-}\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+case 3: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -25532,142 +27254,67 @@ case 8: ...
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+case 6: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-}
-\layout Standard
-
-Both the above switch statements will be implemented using a jump-table.
- The example to the right side is slightly more efficient as the check for
- the lower boundary of the jump-table is not needed.
-\end_deeper 
-\layout Itemize
-
-The number of case labels is not larger than supported by the target architectur
-e.
-\layout Itemize
-
-If the case labels are not in numerical sequence ('gaps' between cases)
- SDCC checks whether a jump table with additionally inserted dummy cases
- is still attractive.
-\layout Itemize
-
-If the starting number is not zero and a check for the lower boundary of
- the jump-table can thus be eliminated SDCC might insert dummy cases 0,
- ...
- .
-\layout Standard
-
-Switch statements which have large gaps in the numeric sequence or those
- that have too many case labels can be split into more than one switch statement
- for efficient code generation, e.g.:
-\layout Verse
-
-
-\family typewriter 
-switch (i) { 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 1: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 2: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 3: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 4: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 5: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 6: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 7: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 101: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 102: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 103: ...
+\SpecialChar ~
+case 3: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 104: ...
-\newline 
+\SpecialChar ~
+case 7: ...\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 105: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 106: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 107: ...
-\newline 
-}
-\layout Standard
-
-If the above switch statement is broken down into two switch statements
-\layout Verse
-
-
-\family typewriter 
-switch (i) { 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 1: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 2: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 3: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 case 4: ...
@@ -25675,215 +27322,107 @@ case 4: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
+\SpecialChar ~
+case 8: ...\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 ~
 case 5: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 6: ...
-\newline 
 \SpecialChar ~
+case 9: ...\SpecialChar ~
 \SpecialChar ~
-case 7: ...
-\newline 
-}
-\layout Standard
-
-and
-\layout Verse
-
-
-\family typewriter 
-switch (i) { 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 101: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 102: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 103: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 104: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 105: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 106: ...
-\newline 
 \SpecialChar ~
 \SpecialChar ~
-case 107: ...
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+case 6: ...
  
 \newline 
-}
-\layout Standard
-
-then both the switch statements will be implemented using jump-tables whereas
- the unmodified switch statement will not be.
-\layout Comment
-
-There might be reasons which SDCC cannot know about to either favour or
- not favour jump tables.
- If the target system has to be as quick for the last switch case as for
- the first (pro jump table), or if the switch argument is known to be zero
- in the majority of the cases (contra jump table).
-\layout Standard
-
-The pragma nojtbound
-\begin_inset LatexCommand \index{\#pragma nojtbound}
-
-\end_inset 
-
- can be used to turn off checking the 
-\emph on 
-j
-\emph default 
-ump 
-\emph on 
-t
-\emph default 
-able 
-\emph on 
-bound
-\emph default 
-aries.
- It has no effect if a default label is supplied.
- Use of this pragma is dangerous: if the switch
-\begin_inset LatexCommand \index{switch statement}
-
-\end_inset 
-
- argument is not matched by a case statement the processor will happily
- jump into Nirvana.
-\layout Subsection
-
-Bit-shifting Operations
-\begin_inset LatexCommand \index{Bit shifting}
-
-\end_inset 
-
-.
-\layout Standard
-
-Bit shifting is one of the most frequently used operation in embedded programmin
-g.
- SDCC tries to implement bit-shift operations in the most efficient way
- possible, e.g.:
-\layout Verse
-
-
-\family typewriter 
-unsigned char i;
-\newline 
-...
-\newline 
-i >>= 4; 
-\newline 
-...
-\layout Standard
-
-generates the following code:
-\layout Verse
-
-
-\family typewriter 
-mov\SpecialChar ~
- a,_i 
-\newline 
-swap a 
-\newline 
-anl\SpecialChar ~
- a,#0x0f 
-\newline 
-mov\SpecialChar ~
- _i,a
-\layout Standard
-
-In general SDCC will never setup a loop if the shift count is known.
- Another example:
-\layout Verse
-
-
-\family typewriter 
-unsigned int i; 
-\newline 
-...
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+case 10: ...\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 ~
+case 7: ...
  
 \newline 
-i >>= 9; 
-\newline 
-...
-\layout Standard
-
-will generate:
-\layout Verse
-
-
-\family typewriter 
-mov\SpecialChar ~
 \SpecialChar ~
-a,(_i + 1) 
-\newline 
-mov\SpecialChar ~
 \SpecialChar ~
-(_i + 1),#0x00 
-\newline 
-clr\SpecialChar ~
 \SpecialChar ~
-c 
-\newline 
-rrc\SpecialChar ~
+case 11: ...\SpecialChar ~
 \SpecialChar ~
-a 
-\newline 
-mov\SpecialChar ~
 \SpecialChar ~
-_i,a
-\layout Subsection
-
-Bit-rotation
-\begin_inset LatexCommand \index{Bit rotation}
-
-\end_inset 
-
-
-\layout Standard
-
-A special case of the bit-shift operation is bit rotation
-\begin_inset LatexCommand \index{rotating bits}
-
-\end_inset 
-
-, SDCC recognizes the following expression to be a left bit-rotation:
-\layout Verse
-
-
-\family typewriter 
-\series bold 
-unsigned
-\series default 
 \SpecialChar ~
 \SpecialChar ~
-char i;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -25894,353 +27433,400 @@ char i;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* unsigned is needed for rotation */ 
-\newline 
-...
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+case 8: ...
  
 \newline 
-i = ((i << 1) | (i >> 7)); 
-\family default 
+}\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 ~
+}
+\layout Standard
 
-\newline 
+Both the above switch statements will be implemented using a jump-table.
+ The example to the right side is slightly more efficient as the check for
+ the lower boundary of the jump-table is not needed.
+\end_deeper 
+\layout Itemize
 
-\family typewriter 
-...
+The number of case labels is not larger than supported by the target architectur
+e.
+\layout Itemize
+
+If the case labels are not in numerical sequence ('gaps' between cases)
+ SDCC checks whether a jump table with additionally inserted dummy cases
+ is still attractive.
+\layout Itemize
+
+If the starting number is not zero and a check for the lower boundary of
+ the jump-table can thus be eliminated SDCC might insert dummy cases 0,
+ ...
+ .
 \layout Standard
 
-will generate the following code:
+Switch statements which have large gaps in the numeric sequence or those
+ that have too many case labels can be split into more than one switch statement
+ for efficient code generation, e.g.:
 \layout Verse
 
 
 \family typewriter 
-mov\SpecialChar ~
+switch (i) { 
+\newline 
 \SpecialChar ~
-a,_i 
+\SpecialChar ~
+case 1: ...
 \newline 
-rl\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-a 
+case 2: ...
 \newline 
-mov\SpecialChar ~
 \SpecialChar ~
-_i,a
-\layout Standard
-
-SDCC uses pattern matching on the parse tree to determine this operation.Variatio
-ns of this case will also be recognized as bit-rotation, i.e.: 
-\layout Verse
-
-
-\family typewriter 
-i = ((i >> 7) | (i << 1)); /* left-bit rotation */
-\layout Subsection
-
-Nibble and Byte Swapping
-\layout Standard
-
-Other special cases of the bit-shift operations are nibble or byte swapping
-\begin_inset LatexCommand \index{swapping nibbles/bytes}
-
-\end_inset 
-
-, SDCC recognizes the following expressions:
-\layout Verse
-
-
-\family typewriter 
-\series bold 
-unsigned
-\series default 
 \SpecialChar ~
-\SpecialChar ~
-char i; 
+case 3: ...
 \newline 
-
-\series bold 
-unsigned
-\series default 
 \SpecialChar ~
 \SpecialChar ~
-int j; 
-\newline 
-...
-\newline 
-i = ((i << 4) | (i >> 4)); 
-\family default 
-
-\newline 
-
-\family typewriter 
-j = ((j << 8) | (j >> 8)); 
-\layout Standard
-
-and generates a swap instruction for the nibble swapping
-\begin_inset LatexCommand \index{Nibble swapping}
-
-\end_inset 
-
- or move instructions for the byte swapping
-\begin_inset LatexCommand \index{Byte swapping}
-
-\end_inset 
-
-.
- The 
-\begin_inset Quotes sld
-\end_inset 
-
-j
-\begin_inset Quotes srd
-\end_inset 
-
- example can be used to convert from little to big-endian or vice versa.
- If you want to change the endianness of a 
-\emph on 
-signed
-\emph default 
- integer you have to cast to 
-\family typewriter 
-(unsigned int)
-\family default 
- first.
-\layout Standard
-
-Note that SDCC stores numbers in little-endian
-\begin_inset Foot
-collapsed false
-
-\layout Standard
-
-Usually 8-bit processors don't care much about endianness.
- This is not the case for the standard 8051 which only has an instruction
- to increment its 
-\emph on 
-dptr
-\emph default 
-
-\begin_inset LatexCommand \index{DPTR}
-
-\end_inset 
-
--datapointer
-\emph on 
+case 4: ...
  
-\emph default 
-so little-endian is the more efficient byte order.
-\end_inset 
-
-
-\begin_inset LatexCommand \index{little-endian}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{Endianness}
-
-\end_inset 
-
- format (i.e.
- lowest order first).
-\layout Subsection
-
-Highest Order Bit
-\begin_inset LatexCommand \index{Highest Order Bit}
-
-\end_inset 
-
- / Any Order Bit
-\begin_inset LatexCommand \index{Any Order Bit}
-
-\end_inset 
-
-
-\layout Standard
-
-It is frequently required to obtain the highest order bit of an integral
- type (long, int, short or char types).
- Also obtaining any other order bit is not uncommon.
- SDCC recognizes the following expressions to yield the highest order bit
- and generates optimized code for it, e.g.:
-\layout Verse
-
-
-\family typewriter 
-unsigned int gint; 
-\newline 
-
-\newline 
-foo () { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-unsigned char hob1, aob1; 
+case 5: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-bit hob2, hob3, aob2, aob3; 
+case 6: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-...
+case 7: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-hob1 = (gint >> 15) & 1; 
+case 101: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-hob2 = (gint >> 15) & 1; 
+case 102: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-hob3 = gint & 0x8000; 
+case 103: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-aob1 = (gint >> 9) & 1; 
+case 104: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-aob2 = (gint >> 8) & 1; 
+case 105: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-aob3 = gint & 0x0800; 
+case 106: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-..
+case 107: ...
  
 \newline 
 }
 \layout Standard
 
-will generate the following code:
+If the above switch statement is broken down into two switch statements
 \layout Verse
 
 
 \family typewriter 
+switch (i) { 
+\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 ~
- 61 ;\SpecialChar ~
- hob.c 7 
+case 1: ...
 \newline 
-000A E5*01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+case 2: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 3: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 4: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 5: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 6: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 7: ...
+\newline 
+}
+\layout Standard
+
+and
+\layout Verse
+
+
+\family typewriter 
+switch (i) { 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
- 62\SpecialChar ~
+case 101: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 102: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 103: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+case 104: ...
+\newline 
 \SpecialChar ~
- mov\SpecialChar ~
 \SpecialChar ~
- a,(_gint + 1) 
+case 105: ...
 \newline 
-000C 23\SpecialChar ~
-\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+case 106: ...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- 63\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- rl\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- a 
+case 107: ...
 \newline 
-000D 54 01\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- 64\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
+}
+\layout Standard
+
+then both the switch statements will be implemented using jump-tables whereas
+ the unmodified switch statement will not be.
+\layout Comment
+
+There might be reasons which SDCC cannot know about to either favour or
+ not favour jump tables.
+ If the target system has to be as quick for the last switch case as for
+ the first (pro jump table), or if the switch argument is known to be zero
+ in the majority of the cases (contra jump table).
+\layout Standard
+
+The pragma nojtbound
+\begin_inset LatexCommand \index{\#pragma nojtbound}
+
+\end_inset 
+
+ can be used to turn off checking the 
+\emph on 
+j
+\emph default 
+ump 
+\emph on 
+t
+\emph default 
+able 
+\emph on 
+bound
+\emph default 
+aries.
+ It has no effect if a default label is supplied.
+ Use of this pragma is dangerous: if the switch
+\begin_inset LatexCommand \index{switch statement}
+
+\end_inset 
+
+ argument is not matched by a case statement the processor will happily
+ jump into Nirvana.
+\layout Subsection
+
+Bit-shifting Operations
+\begin_inset LatexCommand \index{Bit shifting}
+
+\end_inset 
+
+.
+\layout Standard
+
+Bit shifting is one of the most frequently used operation in embedded programmin
+g.
+ SDCC tries to implement bit-shift operations in the most efficient way
+ possible, e.g.:
+\layout Verse
+
+
+\family typewriter 
+unsigned char i;
+\newline 
+...
+\newline 
+i >>= 4; 
+\newline 
+...
+\layout Standard
+
+generates the following code:
+\layout Verse
+
+
+\family typewriter 
+mov\SpecialChar ~
+ a,_i 
+\newline 
+swap a 
+\newline 
+anl\SpecialChar ~
+ a,#0x0f 
+\newline 
+mov\SpecialChar ~
+ _i,a
+\layout Standard
+
+In general SDCC will never setup a loop if the shift count is known.
+ Another example:
+\layout Verse
+
+
+\family typewriter 
+unsigned int i; 
+\newline 
+...
+\newline 
+i >>= 9; 
+\newline 
+...
+\layout Standard
+
+will generate:
+\layout Verse
+
+
+\family typewriter 
+mov\SpecialChar ~
 \SpecialChar ~
+a,(_i + 1) 
+\newline 
+mov\SpecialChar ~
 \SpecialChar ~
- anl\SpecialChar ~
+(_i + 1),#0x00 
+\newline 
+clr\SpecialChar ~
 \SpecialChar ~
- a,#0x01 
+c 
 \newline 
-000F F5*02\SpecialChar ~
+rrc\SpecialChar ~
 \SpecialChar ~
+a 
+\newline 
+mov\SpecialChar ~
 \SpecialChar ~
+_i,a
+\layout Subsection
+
+Bit-rotation
+\begin_inset LatexCommand \index{Bit rotation}
+
+\end_inset 
+
+
+\layout Standard
+
+A special case of the bit-shift operation is bit rotation
+\begin_inset LatexCommand \index{rotating bits}
+
+\end_inset 
+
+, SDCC recognizes the following expression to be a left bit-rotation:
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+unsigned
+\series default 
 \SpecialChar ~
 \SpecialChar ~
+char i;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26251,47 +27837,235 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 65\SpecialChar ~
+/* unsigned is needed for rotation */ 
+\newline 
+...
+\newline 
+i = ((i << 1) | (i >> 7)); 
+\family default 
+
+\newline 
+
+\family typewriter 
+...
+\layout Standard
+
+will generate the following code:
+\layout Verse
+
+
+\family typewriter 
+mov\SpecialChar ~
 \SpecialChar ~
+a,_i 
+\newline 
+rl\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+a 
+\newline 
+mov\SpecialChar ~
 \SpecialChar ~
+_i,a
+\layout Standard
+
+SDCC uses pattern matching on the parse tree to determine this operation.Variatio
+ns of this case will also be recognized as bit-rotation, i.e.: 
+\layout Verse
+
+
+\family typewriter 
+i = ((i >> 7) | (i << 1)); /* left-bit rotation */
+\layout Subsection
+
+Nibble and Byte Swapping
+\layout Standard
+
+Other special cases of the bit-shift operations are nibble or byte swapping
+\begin_inset LatexCommand \index{swapping nibbles/bytes}
+
+\end_inset 
+
+, SDCC recognizes the following expressions:
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+unsigned
+\series default 
 \SpecialChar ~
 \SpecialChar ~
+char i; 
+\newline 
+
+\series bold 
+unsigned
+\series default 
 \SpecialChar ~
- mov\SpecialChar ~
 \SpecialChar ~
- _foo_hob1_1_1,a 
+int j; 
+\newline 
+...
+\newline 
+i = ((i << 4) | (i >> 4)); 
+\family default 
+
+\newline 
+
+\family typewriter 
+j = ((j << 8) | (j >> 8)); 
+\layout Standard
+
+and generates a swap instruction for the nibble swapping
+\begin_inset LatexCommand \index{Nibble swapping}
+
+\end_inset 
+
+ or move instructions for the byte swapping
+\begin_inset LatexCommand \index{Byte swapping}
+
+\end_inset 
+
+.
+ The 
+\begin_inset Quotes sld
+\end_inset 
+
+j
+\begin_inset Quotes srd
+\end_inset 
+
+ example can be used to convert from little to big-endian or vice versa.
+ If you want to change the endianness of a 
+\emph on 
+signed
+\emph default 
+ integer you have to cast to 
+\family typewriter 
+(unsigned int)
+\family default 
+ first.
+\layout Standard
+
+Note that SDCC stores numbers in little-endian
+\begin_inset Foot
+collapsed false
+
+\layout Standard
+
+Usually 8-bit processors don't care much about endianness.
+ This is not the case for the standard 8051 which only has an instruction
+ to increment its 
+\emph on 
+dptr
+\emph default 
+
+\begin_inset LatexCommand \index{DPTR}
+
+\end_inset 
+
+-datapointer
+\emph on 
+\emph default 
+so little-endian is the more efficient byte order.
+\end_inset 
+
+
+\begin_inset LatexCommand \index{little-endian}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Endianness}
+
+\end_inset 
+
+ format (i.e.
+ lowest order first).
+\layout Subsection
+
+Highest Order Bit
+\begin_inset LatexCommand \index{Highest Order Bit}
+
+\end_inset 
+
+ / Any Order Bit
+\begin_inset LatexCommand \index{Any Order Bit}
+
+\end_inset 
+
+
+\layout Standard
+
+It is frequently required to obtain the highest order bit of an integral
+ type (long, int, short or char types).
+ Also obtaining any other order bit is not uncommon.
+ SDCC recognizes the following expressions to yield the highest order bit
+ and generates optimized code for it, e.g.:
+\layout Verse
+
+
+\family typewriter 
+unsigned int gint; 
+\newline 
+
+\newline 
+foo () { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
+unsigned char hob1, aob1; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+bit hob2, hob3, aob2, aob3; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+...
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+hob1 = (gint >> 15) & 1; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+hob2 = (gint >> 15) & 1; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+hob3 = gint & 0x8000; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+aob1 = (gint >> 9) & 1; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+aob2 = (gint >> 8) & 1; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
+aob3 = gint & 0x0800; 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- 66 ;\SpecialChar ~
- hob.c 8 
+..
 \newline 
-0011 E5*01\SpecialChar ~
+}
+\layout Standard
+
+will generate the following code:
+\layout Verse
+
+
+\family typewriter 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26306,7 +28080,6 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 67\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26314,14 +28087,14 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- mov\SpecialChar ~
 \SpecialChar ~
- a,(_gint + 1) 
-\newline 
-0013 33\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ 61 ;\SpecialChar ~
+ hob.c 7 
+\newline 
+000A E5*01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26336,7 +28109,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 68\SpecialChar ~
+ 62\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26344,11 +28117,11 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
rlc\SpecialChar ~
mov\SpecialChar ~
 \SpecialChar ~
- a 
+ a,(_gint + 1) 
 \newline 
-0014 92*00\SpecialChar ~
+000C 23\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26363,22 +28136,23 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 69\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ 63\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- mov\SpecialChar ~
 \SpecialChar ~
- _foo_hob2_1_1,c 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
+ rl\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ a 
+\newline 
+000D 54 01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26393,6 +28167,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ 64\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26400,10 +28175,11 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 66 ;\SpecialChar ~
- hob.c 9 
+ anl\SpecialChar ~
+\SpecialChar ~
+ a,#0x01 
 \newline 
-0016 E5*01\SpecialChar ~
+000F F5*02\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26418,7 +28194,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 67\SpecialChar ~
+ 65\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26428,9 +28204,8 @@ will generate the following code:
 \SpecialChar ~
  mov\SpecialChar ~
 \SpecialChar ~
- a,(_gint + 1) 
+ _foo_hob1_1_1,a 
 \newline 
-0018 33\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26448,7 +28223,6 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 68\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26456,11 +28230,11 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- rlc\SpecialChar ~
 \SpecialChar ~
- a 
+ 66 ;\SpecialChar ~
+ hob.c 8 
 \newline 
-0019 92*01\SpecialChar ~
+0011 E5*01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26475,7 +28249,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 69\SpecialChar ~
+ 67\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26485,8 +28259,9 @@ will generate the following code:
 \SpecialChar ~
  mov\SpecialChar ~
 \SpecialChar ~
- _foo_hob3_1_1,c 
+ a,(_gint + 1) 
 \newline 
+0013 33\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26504,6 +28279,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ 68\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26511,11 +28287,11 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ rlc\SpecialChar ~
 \SpecialChar ~
- 70 ;\SpecialChar ~
- hob.c 10 
+ a 
 \newline 
-001B E5*01\SpecialChar ~
+0014 92*00\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26530,7 +28306,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
71\SpecialChar ~
69\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26540,9 +28316,8 @@ will generate the following code:
 \SpecialChar ~
  mov\SpecialChar ~
 \SpecialChar ~
- a,(_gint + 1) 
+ _foo_hob2_1_1,c 
 \newline 
-001D 03\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26559,8 +28334,6 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
- 72\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26568,12 +28341,12 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- rr\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- a 
+ 66 ;\SpecialChar ~
+ hob.c 9 
 \newline 
-001E 54 01\SpecialChar ~
+0016 E5*01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26588,7 +28361,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
73\SpecialChar ~
67\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26596,11 +28369,11 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
anl\SpecialChar ~
mov\SpecialChar ~
 \SpecialChar ~
- a,#0x01 
+ a,(_gint + 1) 
 \newline 
-0020 F5*03\SpecialChar ~
+0018 33\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26615,21 +28388,22 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 74\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ 68\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- mov\SpecialChar ~
 \SpecialChar ~
- _foo_aob1_1_1,a 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
+ rlc\SpecialChar ~
 \SpecialChar ~
+ a 
+\newline 
+0019 92*01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26644,6 +28418,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ 69\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26651,11 +28426,10 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ mov\SpecialChar ~
 \SpecialChar ~
- 75 ;\SpecialChar ~
- hob.c 11 
+ _foo_hob3_1_1,c 
 \newline 
-0022 E5*01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26670,7 +28444,6 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 76\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26678,14 +28451,14 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- mov\SpecialChar ~
 \SpecialChar ~
- a,(_gint + 1) 
-\newline 
-0024 13\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ 70 ;\SpecialChar ~
+ hob.c 10 
+\newline 
+001B E5*01\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26700,7 +28473,7 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- 77\SpecialChar ~
+ 71\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -26708,9 +28481,179 @@ will generate the following code:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
rrc\SpecialChar ~
mov\SpecialChar ~
 \SpecialChar ~
- a 
+ a,(_gint + 1) 
+\newline 
+001D 03\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 72\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ rr\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ a 
+\newline 
+001E 54 01\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 73\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ anl\SpecialChar ~
+\SpecialChar ~
+ a,#0x01 
+\newline 
+0020 F5*03\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 74\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ mov\SpecialChar ~
+\SpecialChar ~
+ _foo_aob1_1_1,a 
+\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 ~
+ 75 ;\SpecialChar ~
+ hob.c 11 
+\newline 
+0022 E5*01\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 76\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ mov\SpecialChar ~
+\SpecialChar ~
+ a,(_gint + 1) 
+\newline 
+0024 13\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ 77\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ rrc\SpecialChar ~
+\SpecialChar ~
+ a 
 \newline 
 0025 92*02\SpecialChar ~
 \SpecialChar ~
@@ -27168,976 +29111,2726 @@ will generate the following code:
  (_foo_how2_1_1 + 1),(_glong + 2) 
 \layout Standard
 
-Again, variations of these cases may 
-\emph on 
-not
-\emph default 
- be recognized.
- They are standard C expressions, so I heartily recommend these be the only
- way to get the higher order byte/word, (it is portable).
- Of course it will be recognized even if it is embedded in other expressions,
- e.g.:
-\layout Verse
+Again, variations of these cases may 
+\emph on 
+not
+\emph default 
+ be recognized.
+ They are standard C expressions, so I heartily recommend these be the only
+ way to get the higher order byte/word, (it is portable).
+ Of course it will be recognized even if it is embedded in other expressions,
+ e.g.:
+\layout Verse
+
+
+\family typewriter 
+xyz = gint + ((gint >> 8) & 0xFF);
+\layout Standard
+
+will still be recognized.
+\layout Subsection
+
+Peephole Optimizer
+\begin_inset LatexCommand \label{sub:Peephole-Optimizer}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Peephole optimizer}
+
+\end_inset 
+
+
+\layout Standard
+
+The compiler uses a rule based, pattern matching and re-writing mechanism
+ for peep-hole optimization.
+ It is inspired by 
+\emph on 
+copt
+\emph default 
+ a peep-hole optimizer by Christopher W.
+ Fraser (cwfraser\SpecialChar ~
+@\SpecialChar ~
+microsoft.com).
+ A default set of rules are compiled into the compiler, additional rules
+ may be added with the 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-peep-file
+\begin_inset LatexCommand \index{-\/-peep-file}
+
+\end_inset 
+
+ <filename>
+\emph default 
+ option.
+ The rule language is best illustrated with examples.
+\layout Verse
+
+
+\family typewriter 
+replace { 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+mov %1,a 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+mov a,%1
+\newline 
+} by {
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+mov %1,a
+\newline 
+}
+\layout Standard
+
+The above rule will change the following assembly
+\begin_inset LatexCommand \index{Assembler routines}
+
+\end_inset 
+
+ sequence:
+\layout Verse
+
+
+\family typewriter 
+mov r1,a 
+\newline 
+mov a,r1
+\layout Standard
+
+to
+\layout Verse
+
+
+\family typewriter 
+mov r1,a
+\layout Standard
+
+Note: All occurrences of a 
+\emph on 
+%n
+\emph default 
+ (pattern variable) must denote the same string.
+ With the above rule, the assembly sequence:
+\layout Verse
+
+
+\family typewriter 
+mov r1,a 
+\newline 
+mov a,r2
+\layout Standard
+
+will remain unmodified.
+\newline 
+
+\newline 
+Other special case optimizations may be added by the user (via 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-peep-file option
+\emph default 
+).
+ E.g.
+ some variants of the 8051 MCU
+\begin_inset LatexCommand \index{MCS51 variants}
+
+\end_inset 
+
+ allow only 
+\family typewriter 
+ajmp
+\family default 
+ and 
+\family typewriter 
+acall
+\family default 
+.
+ The following two rules will change all 
+\family typewriter 
+ljmp
+\family default 
+ and 
+\family typewriter 
+lcall
+\family default 
+ to 
+\family typewriter 
+ajmp
+\family default 
+ and 
+\family typewriter 
+acall
+\layout Verse
+
+
+\family typewriter 
+replace { lcall %1 } by { acall %1 } 
+\newline 
+replace { ljmp %1 } by { ajmp %1 }
+\layout Standard
+
+The 
+\emph on 
+inline-assembler code
+\emph default 
+ is also passed through the peep hole optimizer, thus the peephole optimizer
+ can also be used as an assembly level macro expander.
+ The rules themselves are MCU dependent whereas the rule language infra-structur
+e is MCU independent.
+ Peephole optimization rules for other MCU can be easily programmed using
+ the rule language.
+\newline 
+
+\newline 
+The syntax for a rule is as follows:
+\layout Verse
+
+
+\family typewriter 
+rule := replace [ restart ] '{' <assembly sequence> '
+\backslash 
+n' 
+\newline 
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ '}' by '{' '
+\backslash 
+n' 
+\newline 
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ <assembly sequence> '
+\backslash 
+n' 
+\newline 
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ '}' [if <functionName> ] '
+\backslash 
+n' 
+\layout Standard
+
+<assembly sequence> := assembly instruction (each instruction including
+ labels must be on a separate line).
+\newline 
+
+\newline 
+The optimizer will apply to the rules one by one from the top in the sequence
+ of their appearance, it will terminate when all rules are exhausted.
+ If the 'restart' option is specified, then the optimizer will start matching
+ the rules again from the top, this option for a rule is expensive (performance)
+, it is intended to be used in situations where a transformation will trigger
+ the same rule again.
+ An example of this (not a good one, it has side effects) is the following
+ rule:
+\layout Verse
+
+
+\family typewriter 
+replace restart { 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+pop %1 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+push %1 } by { 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+; nop 
+\newline 
+}
+\layout Standard
+
+Note that the replace pattern cannot be a blank, but can be a comment line.
+ Without the 'restart' option only the innermost 'pop' 'push' pair would
+ be eliminated, i.e.:
+\layout Verse
+
+
+\family typewriter 
+pop ar1 
+\newline 
+pop ar2 
+\newline 
+push ar2 
+\newline 
+push ar1
+\layout Standard
+
+would result in:
+\layout Verse
+
+
+\family typewriter 
+pop ar1 
+\newline 
+; nop 
+\newline 
+push ar1
+\layout Standard
+
+
+\emph on 
+with
+\emph default 
+ the restart option the rule will be applied again to the resulting code
+ and then all the pop-push pairs will be eliminated to yield:
+\layout Verse
+
+
+\family typewriter 
+; nop 
+\newline 
+; nop
+\layout Standard
+
+A conditional function can be attached to a rule.
+ Attaching rules are somewhat more involved, let me illustrate this with
+ an example.
+\layout Verse
+
+
+\family typewriter 
+replace { 
+\newline 
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+ljmp %5 
+\newline 
+%2:
+\newline 
+} by { 
+\newline 
+\SpecialChar ~
+ \SpecialChar ~
+ \SpecialChar ~
+sjmp %5 
+\newline 
+%2:
+\newline 
+} if labelInRange
+\layout Standard
+
+The optimizer does a look-up of a function name table defined in function
+\emph on 
+callFuncByName
+\emph default 
+ in the source file SDCCpeeph.c, with the name 
+\emph on 
+labelInRange
+\emph default 
+.
+ If it finds a corresponding entry the function is called.
+ Note there can be no parameters specified for these functions, in this
+ case the use of 
+\emph on 
+%5
+\emph default 
+ is crucial, since the function 
+\emph on 
+labelInRange
+\emph default 
+ expects to find the label in that particular variable (the hash table containin
+g the variable bindings is passed as a parameter).
+ If you want to code more such functions, take a close look at the function
+ labelInRange and the calling mechanism in source file SDCCpeeph.c.
+ Currently implemented are 
+\emph on 
+labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
+ 24bitMode, portIsDS390, 24bitModeAndPortDS390 
+\emph default 
+and
+\emph on 
+ notVolatile
+\emph default 
+.
+\layout Standard
+
+I know this whole thing is a little kludgey, but maybe some day we will
+ have some better means.
+ If you are looking at this file, you will see the default rules that are
+ compiled into the compiler, you can add your own rules in the default set
+ there if you get tired of specifying the -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-peep-file option.
+\layout Section
+
+ANSI-Compliance
+\begin_inset LatexCommand \index{ANSI-compliance}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \label{sub: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:
+\layout Itemize
+
+functions are not reentrant
+\begin_inset LatexCommand \index{reentrant}
+
+\end_inset 
+
+ unless explicitly declared as such or the 
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-stack-auto
+\begin_inset LatexCommand \index{-\/-stack-auto}
+
+\end_inset 
+
+
+\series default 
+ command line option is specified.
+\layout Itemize
+
+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
+
+
+\family typewriter 
+struct s { ...
+ }; 
+\newline 
+struct s s1, s2; 
+\newline 
+foo() 
+\newline 
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline 
+}
+\newline 
+
+\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 ~
+\SpecialChar ~
+struct s rets; 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return rets; /* is invalid in SDCC although allowed in ANSI */ 
+\newline 
+}
+\end_deeper 
+\layout Itemize
+
+initialization of structure arrays must be fully braced.
+\begin_deeper 
+\layout Verse
+
+
+\family typewriter 
+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 
+\layout Itemize
+
+'long long
+\begin_inset LatexCommand \index{long long (not supported)}
+
+\end_inset 
+
+' (64 bit integers
+\begin_inset LatexCommand \index{int (64 bit) (not supported)}
+
+\end_inset 
+
+) not supported.
+\layout Itemize
+
+'double
+\begin_inset LatexCommand \index{double (not supported)}
+
+\end_inset 
+
+' precision floating point 
+\begin_inset LatexCommand \index{Floating point support}
+
+\end_inset 
+
+not supported.
+\layout Itemize
+
+Old K&R style
+\begin_inset LatexCommand \index{K\&R style}
+
+\end_inset 
+
+ function declarations are NOT allowed.
+\begin_deeper 
+\layout Verse
+
+
+\family typewriter 
+foo(i,j) /* this old style of function declarations */ 
+\newline 
+int i,j; /* are valid in ANSI but not valid in SDCC */ 
+\newline 
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline 
+}
+\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 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-std-c89
+\begin_inset LatexCommand \index{-\/-std-c89}
+
+\end_inset 
+
+ or -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-std-c99
+\begin_inset LatexCommand \index{-\/-std-c99}
+
+\end_inset 
+
+
+\series default 
+ command line options are used.
+ These may include (depending on the selected processor): 'at', 'banked',
+ 'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
+t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
+ 'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
+ '_naked'.
+ Compliant equivalents of these keywords are always available in a form
+ that begin with two underscores
+\begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
+
+\end_inset 
+
+, f.e.
+ '__data' instead of 'data'.
+\layout Section
+
+Cyclomatic Complexity
+\begin_inset LatexCommand \index{Cyclomatic complexity}
+
+\end_inset 
+
+
+\layout Standard
+
+Cyclomatic complexity of a function is defined as the number of independent
+ paths the program can take during execution of the function.
+ This is an important number since it defines the number test cases you
+ have to generate to validate the function.
+ The accepted industry standard for complexity number is 10, if the cyclomatic
+ complexity reported by SDCC exceeds 10 you should think about simplification
+ of the function logic.
+ Note that the complexity level is not related to the number of lines of
+ code in a function.
+ Large functions can have low complexity, and small functions can have large
+ complexity levels.
+\newline 
+
+\newline 
+SDCC uses the following formula to compute the complexity:
+\newline 
+
+\layout Standard
+
+complexity = (number of edges in control flow graph) - (number of nodes
+ in control flow graph) + 2;
+\newline 
+
+\newline 
+Having said that the industry standard is 10, you should be aware that in
+ some cases it be may unavoidable to have a complexity level of less than
+ 10.
+ For example if you have switch statement with more than 10 case labels,
+ each case label adds one to the complexity level.
+ The complexity level is by no means an absolute measure of the algorithmic
+ complexity of the function, it does however provide a good starting point
+ for which functions you might look at for further optimization.
+\layout Section
+
+Retargetting for other Processors
+\layout Standard
+
+The issues for retargetting the compiler are far too numerous to be covered
+ by this document.
+ What follows is a brief description of each of the seven phases of the
+ compiler and its MCU dependency.
+\layout Itemize
+
+Parsing the source and building the annotated parse tree.
+ This phase is largely MCU independent (except for the language extensions).
+ Syntax & semantic checks are also done in this phase, along with some initial
+ optimizations like back patching labels and the pattern matching optimizations
+ like bit-rotation etc.
+\layout Itemize
+
+The second phase involves generating an intermediate code which can be easy
+ manipulated during the later phases.
+ This phase is entirely MCU independent.
+ The intermediate code generation assumes the target machine has unlimited
+ number of registers, and designates them with the name iTemp.
+ The compiler can be made to dump a human readable form of the code generated
+ by using the -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-dumpraw option.
+\layout Itemize
+
+This phase does the bulk of the standard optimizations and is also MCU independe
+nt.
+ This phase can be broken down into several sub-phases:
+\newline 
+
+\newline 
+Break down intermediate code (iCode) into basic blocks.
+\newline 
+Do control flow & data flow analysis on the basic blocks.
+\newline 
+Do local common subexpression elimination, then global subexpression elimination
+\newline 
+Dead code elimination
+\newline 
+Loop optimizations
+\newline 
+If loop optimizations caused any changes then do 'global subexpression eliminati
+on' and 'dead code elimination' again.
+\layout Itemize
+
+This phase determines the live-ranges; by live range I mean those iTemp
+ variables defined by the compiler that still survive after all the optimization
+s.
+ Live range analysis
+\begin_inset LatexCommand \index{Live range analysis}
+
+\end_inset 
+
+ is essential for register allocation, since these computation determines
+ which of these iTemps will be assigned to registers, and for how long.
+\layout Itemize
+
+Phase five is register allocation.
+ There are two parts to this process.
+\newline 
+
+\newline 
+The first part I call 'register packing' (for lack of a better term).
+ In this case several MCU specific expression folding is done to reduce
+ register pressure.
+\newline 
+
+\newline 
+The second part is more MCU independent and deals with allocating registers
+ to the remaining live ranges.
+ A lot of MCU specific code does creep into this phase because of the limited
+ number of index registers available in the 8051.
+\layout Itemize
+
+The Code generation phase is (unhappily), entirely MCU dependent and very
+ little (if any at all) of this code can be reused for other MCU.
+ However the scheme for allocating a homogenized assembler operand for each
+ iCode operand may be reused.
+\layout Itemize
+
+As mentioned in the optimization section the peep-hole optimizer is rule
+ based system, which can reprogrammed for other MCUs.
+\layout Standard
+
+More information is available in a wiki
+\begin_inset LatexCommand \index{wiki}
+
+\end_inset 
+
+ (preliminary link 
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/release_wiki/index.php?page=SDCC+internals+and+porting}
+
+\end_inset 
+
+) and in the thread 
+\begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
+
+\end_inset 
+
+ .
+\layout Chapter
+
+Compiler internals
+\begin_inset LatexCommand \index{Compiler internals}
+
+\end_inset 
+
+
+\layout Section
+
+The anatomy of the compiler
+\begin_inset LatexCommand \label{sub:The-anatomy-of}
+
+\end_inset 
+
+
+\layout Standard
+
+
+\shape italic 
+This is an excerpt from an article published in Circuit Cellar Magazine
+ in 
+\series bold 
+August 2000
+\series default 
+.
+ It's a little outdated (the compiler is much more efficient now and user/develo
+per friendly), but pretty well exposes the guts of it all.
+\shape default 
+
+\newline 
+
+\newline 
+The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
+ It is fairly easy to retarget for other 8-bit MCU.
+ Here we take a look at some of the internals of the compiler.
+\layout Paragraph*
+
+Parsing
+\begin_inset LatexCommand \index{Parsing}
+
+\end_inset 
+
+\layout Standard
+
+Parsing the input source file and creating an AST (Annotated Syntax Tree
+\begin_inset LatexCommand \index{Annotated syntax tree}
+
+\end_inset 
+
+).
+ This phase also involves propagating types (annotating each node of the
+ parse tree with type information) and semantic analysis.
+ There are some MCU specific parsing rules.
+ For example the storage classes, the extended storage classes are MCU specific
+ while there may be a xdata storage class for 8051 there is no such storage
+ class for z80 or Atmel AVR.
+ SDCC allows MCU specific storage class extensions, i.e.
+ xdata will be treated as a storage class specifier when parsing 8051 C
+ code but will be treated as a C identifier when parsing z80 or ATMEL AVR
+ C code.
+\layout Paragraph*
+
+Generating iCode
+\begin_inset LatexCommand \index{iCode}
+
+\end_inset 
+
+
+\layout Standard
+
+Intermediate code generation.
+ In this phase the AST is broken down into three-operand form (iCode).
+ These three operand forms are represented as doubly linked lists.
+ ICode is the term given to the intermediate form generated by the compiler.
+ ICode example section shows some examples of iCode generated for some simple
+ C source functions.
+\layout Paragraph*
+
+Optimizations
+\begin_inset LatexCommand \index{Optimizations}
+
+\end_inset 
+
+.
+\layout Standard
+
+Bulk of the target independent optimizations is performed in this phase.
+ The optimizations include constant propagation, common sub-expression eliminati
+on, loop invariant code movement, strength reduction of loop induction variables
+ and dead-code elimination.
+\layout Paragraph*
+
+Live range analysis
+\begin_inset LatexCommand \index{Live range analysis}
+
+\end_inset 
+
+
+\layout Standard
+
+During intermediate code generation phase, the compiler assumes the target
+ machine has infinite number of registers and generates a lot of temporary
+ variables.
+ The live range computation determines the lifetime of each of these compiler-ge
+nerated temporaries.
+ A picture speaks a thousand words.
+ ICode example sections show the live range annotations for each of the
+ operand.
+ It is important to note here, each iCode is assigned a number in the order
+ of its execution in the function.
+ The live ranges are computed in terms of these numbers.
+ The from number is the number of the iCode which first defines the operand
+ and the to number signifies the iCode which uses this operand last.
+\layout Paragraph*
+
+Register Allocation
+\begin_inset LatexCommand \index{Register allocation}
+
+\end_inset 
+
+
+\layout Standard
+
+The register allocation determines the type and number of registers needed
+ by each operand.
+ In most MCUs only a few registers can be used for indirect addressing.
+ In case of 8051 for example the registers R0 & R1 can be used to indirectly
+ address the internal ram and DPTR to indirectly address the external ram.
+ The compiler will try to allocate the appropriate register to pointer variables
+ if it can.
+ ICode example section shows the operands annotated with the registers assigned
+ to them.
+ The compiler will try to keep operands in registers as much as possible;
+ there are several schemes the compiler uses to do achieve this.
+ When the compiler runs out of registers the compiler will check to see
+ if there are any live operands which is not used or defined in the current
+ basic block being processed, if there are any found then it will push that
+ operand and use the registers in this block, the operand will then be popped
+ at the end of the basic block.
+\layout Standard
+
+There are other MCU specific considerations in this phase.
+ Some MCUs have an accumulator; very short-lived operands could be assigned
+ to the accumulator instead of a general-purpose register.
+\layout Paragraph*
+
+Code generation
+\layout Standard
+
+Figure II gives a table of iCode
+\begin_inset LatexCommand \index{iCode}
+
+\end_inset 
+
+ operations supported by the compiler.
+ The code generation involves translating these operations into corresponding
+ assembly code for the processor.
+ This sounds overly simple but that is the essence of code generation.
+ Some of the iCode operations are generated on a MCU specific manner for
+ example, the z80 port does not use registers to pass parameters so the
+ SEND and RECV iCode operations will not be generated, and it also does
+ not support JUMPTABLES.
+\newline 
+
+\layout Standard
+
+
+\size footnotesize 
+Figure II 
+\begin_inset  Tabular
+<lyxtabular version="3" rows="39" columns="4">
+<features islongtable="true" headBottomDL="true">
+<column alignment="block" valignment="top" leftline="true" width="13col%">
+<column alignment="left" valignment="top" leftline="true" width="13col%">
+<column alignment="block" valignment="top" leftline="true" width="22col%">
+<column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
+<row topline="true" bottomline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+iCode
+\series default 
+
+\begin_inset LatexCommand \index{iCode}
+
+\end_inset 
+
+
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+Operands
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+Description
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+C Equivalent
+\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 
+'!'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+NOT operation 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = ! IC_LEFT;
+\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 
+'~'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Bitwise complement of 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = ~IC_LEFT;
+\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 
+RRC
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Rotate right with carry
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
+\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 
+RLC
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Rotate left with carry
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
+\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 
+GETHBIT
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Get the highest order bit of IC_LEFT
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
+\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 
+UNARYMINUS
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Unary minus
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = - IC_LEFT;
+\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 
+IPUSH
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Push the operand into stack
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+NONE
+\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 
+IPOP
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Pop the operand from the stack 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+NONE
+\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 
+CALL
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Call the function represented by IC_LEFT 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT();
+\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 
+PCALL
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Call via function pointer
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = (*IC_LEFT)();
+\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 
+RETURN
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Return the value in operand IC_LEFT 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+return IC_LEFT;
+\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 
+LABEL
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LABEL() 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Label
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LABEL:
+\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 
+GOTO
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LABEL() 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Goto label
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+goto IC_LABEL();
+\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 
+'+'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Addition
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT + IC_RIGHT
+\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 
+'-'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Subtraction
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT - IC_RIGHT 
+\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 
+'*'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Multiplication 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT * IC_RIGHT;
+\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 
+'/'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Division
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT / IC_RIGHT;
+\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 
+'%'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Modulus
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT % IC_RIGHT;
+\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 
+'<'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
 
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-xyz = gint + ((gint >> 8) & 0xFF);
 \layout Standard
 
-will still be recognized.
-\layout Subsection
 
-Peephole Optimizer
-\begin_inset LatexCommand \label{sub:Peephole-Optimizer}
+\size footnotesize 
+Less than
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
+
+\size footnotesize 
+IC_RESULT = IC_LEFT < IC_RIGHT;
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\begin_inset LatexCommand \index{Peephole optimizer}
 
+\size footnotesize 
+'>'
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
 
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-The compiler uses a rule based, pattern matching and re-writing mechanism
- for peep-hole optimization.
- It is inspired by 
-\emph on 
-copt
-\emph default 
- a peep-hole optimizer by Christopher W.
- Fraser (cwfraser\SpecialChar ~
-@\SpecialChar ~
-microsoft.com).
- A default set of rules are compiled into the compiler, additional rules
- may be added with the 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
+
+\size footnotesize 
+Greater than 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
+
+\size footnotesize 
+IC_RESULT = IC_LEFT > IC_RIGHT;
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
--peep-file
-\begin_inset LatexCommand \index{-\/-peep-file}
 
+\size footnotesize 
+EQ_OP
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- <filename>
-\emph default 
- option.
- The rule language is best illustrated with examples.
-\layout Verse
+\layout Standard
 
 
-\family typewriter 
-replace { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-mov %1,a 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-mov a,%1
-\newline 
-} by {
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-mov %1,a
-\newline 
-}
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Equal to 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT == IC_RIGHT;
+\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 
+AND_OP
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT() 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Logical and operation
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT && IC_RIGHT; 
+\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 
+OR_OP
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT() 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Logical or operation 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT || IC_RIGHT; 
+\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 
+'^'
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT() 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+Exclusive OR
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT ^ IC_RIGHT;
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
 \layout Standard
 
-The above rule will change the following assembly
-\begin_inset LatexCommand \index{Assembler routines}
 
+\size footnotesize 
+'|'
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- sequence:
-\layout Verse
+\layout Standard
 
 
-\family typewriter 
-mov r1,a 
-\newline 
-mov a,r1
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT() 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
 \layout Standard
 
-to
-\layout Verse
 
+\size footnotesize 
+Bitwise OR 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-mov r1,a
 \layout Standard
 
-Note: All occurrences of a 
-\emph on 
-%n
-\emph default 
- (pattern variable) must denote the same string.
- With the above rule, the assembly sequence:
-\layout Verse
 
+\size footnotesize 
+IC_RESULT = IC_LEFT | IC_RIGHT;
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-mov r1,a 
-\newline 
-mov a,r2
 \layout Standard
 
-will remain unmodified.
-\newline 
 
-\newlin
-Other special case optimizations may be added by the user (via 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
+\size footnotesiz
+BITWISEAND
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
--peep-file option
-\emph default 
-).
- E.g.
- some variants of the 8051 MCU
-\begin_inset LatexCommand \index{MCS51 variants}
 
+\size footnotesize 
+Bitwise AND 
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
- allow only 
-\family typewriter 
-ajmp
-\family default 
- and 
-\family typewriter 
-acall
-\family default 
-.
- The following two rules will change all 
-\family typewriter 
-ljmp
-\family default 
- and 
-\family typewriter 
-lcall
-\family default 
- to 
-\family typewriter 
-ajmp
-\family default 
- and 
-\family typewriter 
-acall
-\layout Verse
+\layout Standard
 
 
-\family typewriter 
-replace { lcall %1 } by { acall %1 } 
-\newline 
-replace { ljmp %1 } by { ajmp %1 }
+\size footnotesize 
+IC_RESULT = IC_LEFT & IC_RIGHT;
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
 \layout Standard
 
-The 
-\emph on 
-inline-assembler code
-\emph default 
- is also passed through the peep hole optimizer, thus the peephole optimizer
- can also be used as an assembly level macro expander.
- The rules themselves are MCU dependent whereas the rule language infra-structur
-e is MCU independent.
- Peephole optimization rules for other MCU can be easily programmed using
- the rule language.
-\newline 
 
-\newline 
-The syntax for a rule is as follows:
-\layout Verse
+\size footnotesize 
+LEFT_OP
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
+
+
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-rule := replace [ restart ] '{' <assembly sequence> '
-\backslash 
-n' 
-\newline 
-\SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- '}' by '{' '
-\backslash 
-n' 
-\newline 
-\SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- <assembly sequence> '
-\backslash 
-n' 
-\newline 
-\SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
- '}' [if <functionName> ] '
-\backslash 
-n' 
 \layout Standard
 
-<assembly sequence> := assembly instruction (each instruction including
- labels must be on a separate line).
-\newline 
 
-\newline 
-The optimizer will apply to the rules one by one from the top in the sequence
- of their appearance, it will terminate when all rules are exhausted.
- If the 'restart' option is specified, then the optimizer will start matching
- the rules again from the top, this option for a rule is expensive (performance)
-, it is intended to be used in situations where a transformation will trigger
- the same rule again.
- An example of this (not a good one, it has side effects) is the following
- rule:
-\layout Verse
+\size footnotesize 
+Left shift 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
+
+
+\size footnotesize 
+IC_RESULT = IC_LEFT << IC_RIGHT 
+\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 
+RIGHT_OP
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-replace restart { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-pop %1 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-push %1 } by { 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-; nop 
-\newline 
-}
 \layout Standard
 
-Note that the replace pattern cannot be a blank, but can be a comment line.
- Without the 'restart' option only the innermost 'pop' 'push' pair would
- be eliminated, i.e.:
-\layout Verse
 
+\size footnotesize 
+IC_LEFT() IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-pop ar1 
-\newline 
-pop ar2 
-\newline 
-push ar2 
-\newline 
-push ar1
 \layout Standard
 
-would result in:
-\layout Verse
 
+\size footnotesize 
+Right shift
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-pop ar1 
-\newline 
-; nop 
-\newline 
-push ar1
 \layout Standard
 
 
-\emph on 
-with
-\emph default 
- the restart option the rule will be applied again to the resulting code
- and then all the pop-push pairs will be eliminated to yield:
-\layout Verse
-
+\size footnotesize 
+IC_RESULT = IC_LEFT >> IC_RIGHT 
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-; nop 
-\newline 
-; nop
 \layout Standard
 
-A conditional function can be attached to a rule.
- Attaching rules are somewhat more involved, let me illustrate this with
- an example.
-\layout Verse
 
-
-\family typewriter 
-replace { 
-\newline 
-\SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
-ljmp %5 
-\newline 
-%2:
-\newline 
-} by { 
-\newline 
-\SpecialChar ~
- \SpecialChar ~
- \SpecialChar ~
-sjmp %5 
-\newline 
-%2:
+\size footnotesize 
+GET_VALUE_
 \newline 
-} if labelInRange
-\layout Standard
+AT_ ADDRESS
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-The optimizer does a look-up of a function name table defined in function
-\emph on 
-callFuncByName
-\emph default 
- in the source file SDCCpeeph.c, with the name 
-\emph on 
-labelInRange
-\emph default 
-.
- If it finds a corresponding entry the function is called.
- Note there can be no parameters specified for these functions, in this
- case the use of 
-\emph on 
-%5
-\emph default 
- is crucial, since the function 
-\emph on 
-labelInRange
-\emph default 
- expects to find the label in that particular variable (the hash table containin
-g the variable bindings is passed as a parameter).
- If you want to code more such functions, take a close look at the function
- labelInRange and the calling mechanism in source file SDCCpeeph.c.
- Currently implemented are 
-\emph on 
-labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
- 24bitMode, portIsDS390, 24bitModeAndPortDS390 
-\emph default 
-and
-\emph on 
- notVolatile
-\emph default 
-.
 \layout Standard
 
-I know this whole thing is a little kludgey, but maybe some day we will
- have some better means.
- If you are looking at this file, you will see the default rules that are
- compiled into the compiler, you can add your own rules in the default set
- there if you get tired of specifying the -
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
 
-\backslash 
-/
+\size footnotesize 
+IC_LEFT() IC_RESULT()
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
--peep-file option.
-\layout Section
+\layout Standard
 
-ANSI-Compliance
-\begin_inset LatexCommand \index{ANSI-compliance}
 
+\size footnotesize 
+Indirect fetch 
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\begin_inset LatexCommand \label{sub:ANSI-Compliance}
 
+\size footnotesize 
+IC_RESULT = (*IC_LEFT);
 \end_inset 
-
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-Deviations from the compliance:
-\layout Itemize
-
-functions are not reentrant
-\begin_inset LatexCommand \index{reentrant}
 
+\size footnotesize 
+POINTER_SET
 \end_inset 
-
- unless explicitly declared as such or the 
-\series bold 
--
-\begin_inset ERT
-status Collapsed
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
+
+\size footnotesize 
+IC_RIGHT() IC_RESULT() 
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
--stack-auto
-\begin_inset LatexCommand \index{-\/-stack-auto}
+\layout Standard
 
+
+\size footnotesize 
+Indirect set
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\series default 
- 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.:
-\begin_deeper 
-\layout Verse
+\size footnotesize 
+(*IC_RESULT) = IC_RIGHT;
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\family typewriter 
-struct s { ...
- }; 
-\newline 
-struct s s1, s2; 
-\newline 
-foo() 
-\newline 
-{ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
-\newline 
-}
-\newline 
-struct s foo1 (struct s parms) /* invalid in SDCC although allowed in ANSI
- */
-\newline 
-{ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-struct s rets; 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return rets;/* is invalid in SDCC although allowed in ANSI */ 
-\newline 
-}
-\end_deeper 
-\layout Itemize
 
-initialization of structure arrays must be fully braced.
-\begin_deeper 
-\layout Verse
+\size footnotesize 
+'='
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
 
-\family typewriter 
-struct s { char x } a[] = {1, 2}; /* invalid in SDCC */
-\newline 
-struct s { char x } a[] = {{1}, {2}}; /* OK */
-\end_deeper 
-\layout Itemize
+\size footnotesize 
+IC_RIGHT() IC_RESULT()
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
-'long long
-\begin_inset LatexCommand \index{long long (not supported)}
 
+\size footnotesize 
+Assignment
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
-' (64 bit integers
-\begin_inset LatexCommand \index{int (64 bit) (not supported)}
 
+\size footnotesize 
+IC_RESULT = IC_RIGHT;
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-) not supported.
-\layout Itemize
+\layout Standard
 
-'double
-\begin_inset LatexCommand \index{double (not supported)}
 
+\size footnotesize 
+IFX
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-' precision floating point 
-\begin_inset LatexCommand \index{Floating point support}
+\layout Standard
 
+
+\size footnotesize 
+IC_COND IC_TRUE IC_LABEL
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-not supported.
-\layout Itemize
+\layout Standard
 
-Old K&R style
-\begin_inset LatexCommand \index{K\&R style}
 
+\size footnotesize 
+Conditional jump.
+ If true label is present then jump to true label if condition is true else
+ jump to false label if condition is false 
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
- function declarations are NOT allowed.
-\begin_deeper 
-\layout Verse
+\layout Standard
 
 
-\family typewriter 
-foo(i,j) /* this old style of function declarations */ 
-\newline 
-int i,j; /* are valid in ANSI but not valid in SDCC */ 
-\newline 
-{ 
+\size footnotesize 
+if (IC_COND) goto IC_TRUE; 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
+Or 
 \newline 
-}
-\end_deeper 
-\layout Itemize
-
-Most enhancements in C99 are not supported, f.e.:
-\begin_deeper 
-\layout Verse
+If (!IC_COND) goto IC_FALSE;
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\family typewriter 
-\series bold 
-inline
-\series default 
- int increment (int a) { return a+1; } /* is invalid in SDCC although allowed
- in C99 */
-\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 
--
-\begin_inset ERT
-status Collapsed
+\size footnotesize 
+ADDRESS_OF
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
-\end_inset 
-
--std-c89
-\begin_inset LatexCommand \index{-\/-std-c89}
 
+\size footnotesize 
+IC_LEFT() IC_RESULT()
 \end_inset 
-
- or -
-\begin_inset ERT
-status Collapsed
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
-\end_inset 
-
--std-c99
-\begin_inset LatexCommand \index{-\/-std-c99}
 
+\size footnotesize 
+Address of 
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\series default 
- command line options are used.
- These may include (depending on the selected processor): 'at', 'banked',
- 'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
-t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
- 'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
- '_naked'.
- Compliant equivalents of these keywords are always available in a form
- that begin with two underscores
-\begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
 
+\size footnotesize 
+IC_RESULT = &IC_LEFT();
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-, f.e.
- '__data' instead of 'data'.
-\layout Section
+\layout Standard
 
-Cyclomatic Complexity
-\begin_inset LatexCommand \index{Cyclomatic complexity}
 
+\size footnotesize 
+JUMPTABLE
 \end_inset 
-
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-Cyclomatic complexity of a function is defined as the number of independent
- paths the program can take during execution of the function.
- This is an important number since it defines the number test cases you
- have to generate to validate the function.
- The accepted industry standard for complexity number is 10, if the cyclomatic
- complexity reported by SDCC exceeds 10 you should think about simplification
- of the function logic.
- Note that the complexity level is not related to the number of lines of
- code in a function.
- Large functions can have low complexity, and small functions can have large
- complexity levels.
-\newline 
 
-\newline 
-SDCC uses the following formula to compute the complexity:
-\newline 
+\size footnotesize 
+IC_JTCOND IC_JTLABELS
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-complexity = (number of edges in control flow graph) - (number of nodes
- in control flow graph) + 2;
-\newline 
 
-\newline 
-Having said that the industry standard is 10, you should be aware that in
- some cases it be may unavoidable to have a complexity level of less than
- 10.
- For example if you have switch statement with more than 10 case labels,
- each case label adds one to the complexity level.
- The complexity level is by no means an absolute measure of the algorithmic
- complexity of the function, it does however provide a good starting point
- for which functions you might look at for further optimization.
-\layout Section
+\size footnotesize 
+Jump to list of labels depending on the value of JTCOND
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-Retargetting for other Processors
 \layout Standard
 
-The issues for retargetting the compiler are far too numerous to be covered
- by this document.
- What follows is a brief description of each of the seven phases of the
- compiler and its MCU dependency.
-\layout Itemize
-
-Parsing the source and building the annotated parse tree.
- This phase is largely MCU independent (except for the language extensions).
- Syntax & semantic checks are also done in this phase, along with some initial
- optimizations like back patching labels and the pattern matching optimizations
- like bit-rotation etc.
-\layout Itemize
 
-The second phase involves generating an intermediate code which can be easy
- manipulated during the later phases.
- This phase is entirely MCU independent.
- The intermediate code generation assumes the target machine has unlimited
- number of registers, and designates them with the name iTemp.
- The compiler can be made to dump a human readable form of the code generated
- by using the -
-\begin_inset ERT
-status Collapsed
+\size footnotesize 
+Switch statement
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
-\end_inset 
-
--dumpraw option.
-\layout Itemize
 
-This phase does the bulk of the standard optimizations and is also MCU independe
-nt.
- This phase can be broken down into several sub-phases:
-\newline 
+\size footnotesize 
+CAST
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\newline 
-Break down intermediate code (iCode) into basic blocks.
-\newline 
-Do control flow & data flow analysis on the basic blocks.
-\newline 
-Do local common subexpression elimination, then global subexpression elimination
-\newline 
-Dead code elimination
-\newline 
-Loop optimizations
-\newline 
-If loop optimizations caused any changes then do 'global subexpression eliminati
-on' and 'dead code elimination' again.
-\layout Itemize
+\layout Standard
 
-This phase determines the live-ranges; by live range I mean those iTemp
- variables defined by the compiler that still survive after all the optimization
-s.
- Live range analysis
-\begin_inset LatexCommand \index{Live range analysis}
 
+\size footnotesize 
+IC_RIGHT() IC_LEFT() IC_RESULT()
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- is essential for register allocation, since these computation determines
- which of these iTemps will be assigned to registers, and for how long.
-\layout Itemize
+\layout Standard
 
-Phase five is register allocation.
- There are two parts to this process.
-\newline 
 
-\newline 
-The first part I call 'register packing' (for lack of a better term).
- In this case several MCU specific expression folding is done to reduce
- register pressure.
-\newline 
+\size footnotesize 
+Cast types 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\newline 
-The second part is more MCU independent and deals with allocating registers
- to the remaining live ranges.
- A lot of MCU specific code does creep into this phase because of the limited
- number of index registers available in the 8051.
-\layout Itemize
+\layout Standard
 
-The Code generation phase is (unhappily), entirely MCU dependent and very
- little (if any at all) of this code can be reused for other MCU.
- However the scheme for allocating a homogenized assembler operand for each
- iCode operand may be reused.
-\layout Itemize
 
-As mentioned in the optimization section the peep-hole optimizer is rule
- based system, which can reprogrammed for other MCUs.
-\layout Chapter
+\size footnotesize 
+IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-Compiler internals
-\begin_inset LatexCommand \index{Compiler internals}
+\layout Standard
 
-\end_inset 
 
+\size footnotesize 
+SEND
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\layout Section
+\layout Standard
 
-The anatomy of the compiler
-\begin_inset LatexCommand \label{sub:The-anatomy-of}
 
+\size footnotesize 
+IC_LEFT()
 \end_inset 
-
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
 
-\shape italic 
-This is an excerpt from an article published in Circuit Cellar Magazine
- in 
-\series bold 
-August 2000
-\series default 
-.
- It's a little outdated (the compiler is much more efficient now and user/develo
-per friendly), but pretty well exposes the guts of it all.
-\shape default 
-
+\size footnotesize 
+This is used for passing parameters in registers; 
 \newline 
+move IC_LEFT to the next available parameter register.
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\newline 
-The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
- It is fairly easy to retarget for other 8-bit MCU.
- Here we take a look at some of the internals of the compiler.
-\layout Paragraph*
+\layout Standard
 
-Parsing
-\begin_inset LatexCommand \index{Parsing}
 
+\size footnotesize 
+None
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-Parsing the input source file and creating an AST (Annotated Syntax Tree
-\begin_inset LatexCommand \index{Annotated syntax tree}
 
+\size footnotesize 
+RECV
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-).
- This phase also involves propagating types (annotating each node of the
- parse tree with type information) and semantic analysis.
- There are some MCU specific parsing rules.
- For example the storage classes, the extended storage classes are MCU specific
- while there may be a xdata storage class for 8051 there is no such storage
- class for z80 or Atmel AVR.
- SDCC allows MCU specific storage class extensions, i.e.
- xdata will be treated as a storage class specifier when parsing 8051 C
- code but will be treated as a C identifier when parsing z80 or ATMEL AVR
- C code.
-\layout Paragraph*
+\layout Standard
 
-Generating iCode
-\begin_inset LatexCommand \index{iCode}
 
+\size footnotesize 
+IC_RESULT()
 \end_inset 
-
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-Intermediate code generation.
- In this phase the AST is broken down into three-operand form (iCode).
- These three operand forms are represented as doubly linked lists.
- ICode is the term given to the intermediate form generated by the compiler.
- ICode example section shows some examples of iCode generated for some simple
- C source functions.
-\layout Paragraph*
-
-Optimizations
-\begin_inset LatexCommand \index{Optimizations}
 
+\size footnotesize 
+This is used for receiving parameters passed in registers;
+\newline 
+Move the values in the next parameter register to IC_RESULT 
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-.
 \layout Standard
 
-Bulk of the target independent optimizations is performed in this phase.
- The optimizations include constant propagation, common sub-expression eliminati
-on, loop invariant code movement, strength reduction of loop induction variables
- and dead-code elimination.
-\layout Paragraph*
-
-Live range analysis
-\begin_inset LatexCommand \index{Live range analysis}
 
+\size footnotesize 
+None
 \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
 
-During intermediate code generation phase, the compiler assumes the target
- machine has infinite number of registers and generates a lot of temporary
- variables.
- The live range computation determines the lifetime of each of these compiler-ge
-nerated temporaries.
- A picture speaks a thousand words.
- ICode example sections show the live range annotations for each of the
- operand.
- It is important to note here, each iCode is assigned a number in the order
- of its execution in the function.
- The live ranges are computed in terms of these numbers.
- The from number is the number of the iCode which first defines the operand
- and the to number signifies the iCode which uses this operand last.
-\layout Paragraph*
-
-Register Allocation
-\begin_inset LatexCommand \index{Register allocation}
 
+\shape slanted 
+\size footnotesize 
+(some more have been added)
 \end_inset 
-
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-The register allocation determines the type and number of registers needed
- by each operand.
- In most MCUs only a few registers can be used for indirect addressing.
- In case of 8051 for example the registers R0 & R1 can be used to indirectly
- address the internal ram and DPTR to indirectly address the external ram.
- The compiler will try to allocate the appropriate register to pointer variables
- if it can.
- ICode example section shows the operands annotated with the registers assigned
- to them.
- The compiler will try to keep operands in registers as much as possible;
- there are several schemes the compiler uses to do achieve this.
- When the compiler runs out of registers the compiler will check to see
- if there are any live operands which is not used or defined in the current
- basic block being processed, if there are any found then it will push that
- operand and use the registers in this block, the operand will then be popped
- at the end of the basic block.
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
 \layout Standard
 
-There are other MCU specific considerations in this phase.
- Some MCUs have an accumulator; very short-lived operands could be assigned
- to the accumulator instead of a general-purpose register.
-\layout Paragraph*
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-Code generation
 \layout Standard
 
-Figure II gives a table of iCode operations supported by the compiler.
- The code generation involves translating these operations into corresponding
- assembly code for the processor.
- This sounds overly simple but that is the essence of code generation.
- Some of the iCode operations are generated on a MCU specific manner for
- example, the z80 port does not use registers to pass parameters so the
- SEND and RECV iCode operations will not be generated, and it also does
- not support JUMPTABLES.
+
+\shape slanted 
+\size footnotesize 
+see f.e.
  
-\newline 
+\family typewriter 
+gen51Code()
+\family default 
+ in 
+\family typewriter 
+src/mcs51/gen.c
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset 
+
 
-\series bold 
-\shape italic 
-\color red
-<Where is Figure II?>
 \layout Comment
 
 In the original article Figure II was announced to be downloadable on 
@@ -28145,8 +31838,7 @@ In the original article Figure II was announced to be downloadable on
 Circuit Cellar
 \shape default 
 's web site.
- Unfortunately it never seemed to have shown up there, so: where is Figure
- II?
+ ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
 \layout Paragraph*
 
 ICode Example
@@ -29413,6 +33105,38 @@ Thanks to all the other volunteer developers who have helped with coding,
 
 \newline 
 
+\newline 
+
+\emph on 
+Also thanks to Sourceforge 
+\begin_inset LatexCommand \url{http://www.sf.net}
+
+\end_inset 
+
+ which has hosted the project since 1999 and donates significant download
+ bandwidth and probably more than 
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+$10^{13}$
+\end_inset 
+
+CPU cycles per day.
+\newline 
+\begin_inset Note
+collapsed false
+
+\layout Standard
+
+more than 10^13 is an estimate: on my Athlon 2800+ it takes about (0.5+6.5+20)
+ minutes for (configure+make+regression test), and there is (i386, amd64,
+ alpha, ppc64, (mingw32), sparc, macosx).
+\end_inset 
+
+
 \layout Standard
 
 This document was initially written by Sandeep Dutta