* .version: bumped version number to 2.4.8
[fw/sdcc] / doc / sdccman.lyx
index 36fecf54ac542d5eb85f9fbc46728b920f7147c6..2c211266192251a6999ab64d8248df7701c1c7db 100644 (file)
@@ -2,6 +2,8 @@
 \lyxformat 221
 \textclass book
 \begin_preamble
+
+
 \usepackage[
   pdftitle={SDCC Compiler User Guide},
   pdfauthor={SDCC development team},
@@ -81,7 +83,7 @@ SDCC Compiler User Guide
 
 
 \size normal 
-SDCC 2.4.0
+SDCC 2.4.7
 \size footnotesize 
 
 \newline 
@@ -127,7 +129,8 @@ C
 \emph on 
 C
 \emph default 
-ompiler) is a Freeware, retargettable, optimizing ANSI-C compiler by 
+ompiler) is an open source, retargettable, optimizing ANSI-C compiler by
 \series bold 
 Sandeep Dutta
 \series default 
@@ -142,7 +145,17 @@ Sandeep Dutta
  It can be retargetted 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 & ASLINK, a Freeware, retargettable assembler & linker.
+ SDCC uses ASXXXX
+\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
+
+\end_inset 
+
+ & ASLINK
+\begin_inset LatexCommand \index{aslink}
+
+\end_inset 
+
+, an open source retargettable assembler & linker.
  SDCC has extensive language extensions suitable for utilizing various microcont
 rollers and underlying hardware effectively.
  
@@ -273,7 +286,7 @@ Open Source
 
 All packages used in this compiler system are 
 \emph on 
-opensource
+open source
 \emph default 
  and 
 \emph on 
@@ -455,6 +468,12 @@ The SDCC home page at
  Web links to other SDCC related sites can also be found here.
  This document can be found in the DOC directory of the source package as
  a text or HTML file.
+ A pdf version of this document is available at 
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
+
+\end_inset 
+
+.
  Some of the other tools (simulator and assembler) included with SDCC contain
  their own documentation and can be found in the source distribution.
  If you want the latest unreleased software, the complete source package
@@ -1950,6 +1969,21 @@ make install prefix=$(HOME)/local/sdcc
 \layout Standard
 
 Of course this doesn't change the search paths compiled into the binaries.
+\newline 
+
+\newline 
+Moreover the install path can be changed by defining DESTDIR
+\begin_inset LatexCommand \index{DESTDIR}
+
+\end_inset 
+
+:
+\layout LyX-Code
+
+make install DESTDIR=$(HOME)/sdcc.rpm/
+\layout Standard
+
+Please note that DESTDIR must have a trailing slash!
 \layout Section
 
 Search Paths
@@ -3125,11 +3159,14 @@ SDCC sources use the unix line ending LF.
  And use an editor which can handle LF-only line endings.
  Make sure not to commit files with windows line endings.
  The tabulator spacing
-\begin_inset LatexCommand \index{tabulator spacing (8)}
+\begin_inset LatexCommand \index{tabulator spacing (8 columns)}
 
 \end_inset 
 
  used in the project is 8.
+ Although a tabulator spacing of 8 is a sensible choice for programmers
+ (it's a power of 2 and allows to display 8/16 bit signed variables without
+ loosing columns) the plan is to move towards using only spaces in the source.
 \layout Subsection
 
 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
@@ -3169,6 +3206,43 @@ bin before running SDCC.
  
 \newline 
 
+\newline 
+WARNING: Visual studio is very picky with line terminations; it expects
+ the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
+ If you are getting a message such as "This makefile was not generated by
+ Developer Studio etc.
+ etc.
+\begin_inset Quotes srd
+\end_inset 
+
+ when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
+ need to convert the Unix style line endings to DOS style line endings.
+ To do so you can use the 
+\begin_inset Quotes sld
+\end_inset 
+
+unix2dos
+\begin_inset Quotes srd
+\end_inset 
+
+ utility freely available on the internet.
+ Doug Hawkins reported in the sdcc-user list that this works:
+\newline 
+
+\newline 
+C:
+\backslash 
+Programming
+\backslash 
+SDCC> unix2dos sdcc.dsw
+\newline 
+C:
+\backslash 
+Programming
+\backslash 
+SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
+\newline 
+
 \newline 
 In order to build SDCC with MSVC you need win32 executables of bison.exe,
  flex.exe, and gawk.exe.
@@ -3419,13 +3493,6 @@ x).
 \end_inset 
 
  as editor this is straightforward.
- If you want to avoid installing the tools you will have some success with
- a bootable Knoppix CD 
-\begin_inset LatexCommand \url{http://www.knoppix.net}
-
-\end_inset 
-
-.
  Prebuilt documentation in html and pdf format is available from 
 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
 
@@ -4244,7 +4311,7 @@ sourcefile.adb
  - An intermediate file containing debug information needed to create the
  .cdb file (with -
 \begin_inset ERT
-status Collapsed
+status Open
 
 \layout Standard
 
@@ -4610,26 +4677,31 @@ To create a new library file, start by compiling all the required modules.
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcc -c _divsint.c
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcc -c _divuint.c
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcc -c _modsint.c
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcc -c _moduint.c
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcc -c _mulint.c
 \newline 
@@ -4644,8 +4716,11 @@ This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcclib libint.lib _divsint.rel
+\family default 
+
 \begin_inset LatexCommand \index{sdcclib}
 
 \end_inset 
@@ -4654,21 +4729,25 @@ sdcclib libint.lib _divsint.rel
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcclib libint.lib _divuint.rel
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcclib libint.lib _modsint.rel
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcclib libint.lib _moduint.rel
 \layout Standard
 
 
+\family sans 
 \series bold 
 sdcclib libint.lib _mulint.rel
 \series default 
@@ -4685,114 +4764,138 @@ If the file already exists in the library, it will be replaced.
 
 \newline 
 
+\family sans 
 \series bold 
 sdcclib -s libint.lib
+\family default 
+
 \begin_inset LatexCommand \index{sdcclib}
 
 \end_inset 
 
 
 \newline 
+
+\family typewriter 
+\series default 
 _divsint.rel:
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divsint_a_1_1
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divsint_PARM_2
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divsint
 \newline 
 _divuint.rel:
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divuint_a_1_1
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divuint_PARM_2
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divuint_reste_1_1
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divuint_count_1_1
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __divuint
 \newline 
 _modsint.rel:
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __modsint_a_1_1
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __modsint_PARM_2
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __modsint
 \newline 
 _moduint.rel:
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __moduint_a_1_1
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __moduint_PARM_2
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __moduint_count_1_1
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __moduint
 \newline 
 _mulint.rel:
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __mulint_PARM_2
 \layout Standard
 
 
-\series bold 
+\family typewriter 
 __mulint
+\family default 
+\series bold 
+
 \newline 
 
 \layout Standard
 
-If the source files are compiled using --debug, the corresponding debug
- information file .adb will be include in the library file as well.
+If the source files are compiled using -
+\begin_inset ERT
+status Open
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-debug
+\begin_inset LatexCommand \index{-\/-debug}
+
+\end_inset 
+
+, the corresponding debug information file .adb will be include in the library
+ file as well.
  The library files created with sdcclib are plain text files, so they can
  be viewed with a text editor.
  It is not recomended to modify a library file created with sdcclib using
@@ -4954,6 +5057,11 @@ Processor Selection Options
  AVR users should probably have a look at avr-gcc 
 \begin_inset LatexCommand \url{ http://savannah.nongnu.org/download/avr-libc/snapshots/}
 
+\end_inset 
+
+ or winavr 
+\begin_inset LatexCommand \url{http://winavr.sourceforge.net}
+
 \end_inset 
 
 .
@@ -5935,7 +6043,33 @@ status Collapsed
 
 \end_inset 
 
- Causes the linker use unused register banks for data variables or stack.
+ Causes the linker to use unused register banks for data variables and pack
+ data, idata and stack together.
+ This is the default now.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-no-pack-iram
+\series default 
+\SpecialChar ~
+
+\begin_inset LatexCommand \index{-\/-pack-iram}
+
+\end_inset 
+
+ Causes the linker to use old style for allocating memory areas.
 \layout Subsection
 
 DS390 / DS400 Options
@@ -6319,7 +6453,13 @@ status Collapsed
 \series default 
  Will not do loop invariant optimizations, this may be turned off for reasons
  explained for the previous option.
- For more details of loop optimizations performed see section Loop Invariants.
+ For more details of loop optimizations performed see Loop Invariants in
+ section 
+\begin_inset LatexCommand \ref{sub:Loop-Optimizations}
+
+\end_inset 
+
+.
  It is recommended that this option NOT be used, #pragma\SpecialChar ~
 noinvariant
 \begin_inset LatexCommand \index{\#pragma noinvariant}
@@ -6585,7 +6725,7 @@ status Collapsed
 
 
 \series default 
 Pass the inline assembler code through the peep hole optimizer.
+ Pass the inline assembler code through the peep hole optimizer.
  This can cause unexpected changes to inline assembler code, please go through
  the peephole optimizer
 \begin_inset LatexCommand \index{Peephole optimizer}
@@ -6594,6 +6734,54 @@ status Collapsed
 
  rules defined in the source file tree '<target>/peeph.def' before using
  this option.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-opt-code-speed
+\begin_inset LatexCommand \index{-\/-opt-code-speed}
+
+\end_inset 
+
+
+\series default 
+ The compiler will optimize code generation towards fast code, possibly
+ at the expense of code size.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-opt-code-size
+\begin_inset LatexCommand \index{-\/-opt-code-size}
+
+\end_inset 
+
+
+\series default 
+ The compiler will optimize code generation towards compact code, possibly
+ at the expense of code speed.
 \layout Subsection
 
 Other Options
@@ -6735,9 +6923,15 @@ reentrant
 \end_inset 
 
 .
- see section Parameters and Local Variables for more details.
+ See section 
+\begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
+
+\end_inset 
+
+ Parameters and Local Variables for more details.
  If this option is used all source files in the project should be compiled
  with this option.
+ It automatically implies --int-long-reent and --float-reent.
  
 \layout List
 \labelwidthstring 00.00.0000
@@ -6986,14 +7180,16 @@ status Collapsed
 
 
 \series default 
- This option can be used when the code generated is called by a monitor
- program.
- The compiler will generate a 'ret' upon return from the 'main'
+ 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.
+ The return from the 'main'
 \begin_inset LatexCommand \index{main return}
 
 \end_inset 
 
- function.
+ function will return to the function calling main.
  The default setting is to lock up i.e.
  generate a '
 \family typewriter 
@@ -7015,8 +7211,8 @@ status Collapsed
 /
 \end_inset 
 
--nostdincl
-\begin_inset LatexCommand \index{-\/-nostdincl}
+-nostdinc
+\begin_inset LatexCommand \index{-\/-nostdinc}
 
 \end_inset 
 
@@ -7111,7 +7307,30 @@ status Collapsed
 
 \series default 
  Hides your ugly and inefficient c-code from the asm file, so you can always
- blame the compiler :).
+ blame the compiler :)
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-no-peep-comments
+\begin_inset LatexCommand \index{-\/-no-peep-comments}
+
+\end_inset 
+
+
+\series default 
+ Will not include peep-hole comments in the generated files.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -7175,6 +7394,30 @@ status Collapsed
 \labelwidthstring 00.00.0000
 
 
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-disable-warning\SpecialChar ~
+<nnnn>
+\begin_inset LatexCommand \index{-\/-disable-warning}
+
+\end_inset 
+
+
+\series default 
+ Disable specific warning with number <nnnn>.
+\layout List
+\labelwidthstring 00.00.0000
+
+
 \series bold 
 -
 \begin_inset ERT
@@ -8029,8 +8272,10 @@ pdata
 
 \layout Standard
 
-Paged xdata access is currently not as straightforward as using the other
- addressing modes of a 8051.
+Paged xdata access is just as straightforward as using the other addressing
+ modes of a 8051.
+ It is typically located at the start of xdata and has a maximum size of
+ 256 bytes.
  The following example writes 0x01 to the address pointed to.
  Please note, pdata access physically accesses xdata memory.
  The high byte of the address is determined by port P2 
@@ -8113,7 +8358,7 @@ F2\SpecialChar ~
 movx @r0,a 
 \layout Standard
 
-Be extremely carefull if you use pdata together with the -
+If the -
 \begin_inset ERT
 status Collapsed
 
@@ -8128,7 +8373,8 @@ status Collapsed
 
 \end_inset 
 
- option.
+ option is used the pdata memory area is followed by the xstack memory area
+ and the sum of their sizes is limited to 256 bytes.
 \layout Subsubsection
 
 code
@@ -8267,15 +8513,14 @@ _test_bit
 The bit addressable memory consists of 128 bits which are located from 0x20
  to 0x2f in data memory.
  
-\layout Standard
-
+\newline 
 Apart from this 8051 specific storage class most architectures support ANSI-C
  bitfields
 \begin_inset LatexCommand \index{bitfields}
 
 \end_inset 
 
+
 \begin_inset Foot
 collapsed false
 
@@ -8286,6 +8531,8 @@ Not really meant as examples, but nevertheless showing what bitfields are
 \end_inset 
 
 .
+ In accordance with ISO/IEC 9899 bits and bitfields without an explicit
+ signed modifier are implemented as unsigned.
 \layout Subsubsection
 
 sfr
@@ -8558,14 +8805,15 @@ data
 
  grows, it will use up the remaining register banks, and the 16 bytes used
  by the 128 bit variables, and 80 bytes for general purpose use.
- If any bit variables are used, the data variables will be placed after
- the byte holding the last bit variable.
+ If any bit variables are used, the data variables will be placed in unused
register banks and after the byte holding the last bit variable.
  For example, if register banks 0 and 1 are used, and there are 9 bit variables
  (two bytes used), 
 \emph on 
 data
 \emph default 
- variables will be placed starting at address 0x22.
+ variables will be placed starting from address 0x10 to 0x20 and continue
+ at address 0x22.
  You can also use -
 \begin_inset ERT
 status Collapsed
@@ -8607,7 +8855,7 @@ idata
  
 \layout Standard
 
-By default the 8051 linker will place the stack after the last byte of data
+By default the 8051 linker will place the stack after the last byte of (i)data
  variables.
  Option -
 \begin_inset ERT
@@ -8961,7 +9209,7 @@ xdata
  0x7ffe unsigned int chksum;
 \layout Standard
 
-In the above example the variable chksum will located at 0x7ffe and 0x7fff
+In the above example the variable chksum will be located at 0x7ffe and 0x7fff
  of the external ram.
  The compiler does 
 \emph on 
@@ -9003,8 +9251,7 @@ In case of memory mapped I/O devices the keyword
 \emph on 
 volatile
 \emph default 
- should be used to tell the compiler that accesses might not be optimized
- away:
+ has to be used to tell the compiler that accesses might not be removed:
 \layout Verse
 
 
@@ -9082,37 +9329,51 @@ le space.
 
 
 \family typewriter 
-extern volatile bit SDI;
+extern volatile bit MOSI;\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* master out, slave in */
 \newline 
-extern volatile bit SCLK;
+extern volatile bit MISO;\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* master in, slave out */
 \newline 
-extern volatile bit CPOL;
+extern volatile bit MCLK;\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* master clock */
 \newline 
 
 \newline 
-void DS1306_put(unsigned char value)
-\newline 
-{
+/* Input and Output of a byte on a 3-wire serial bus.
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+If needed adapt polarity of clock, polarity of data and bit order
+\newline 
 \SpecialChar ~
-unsigned char mask=0x80;
+*/
 \newline 
-
+unsigned char spi_io(unsigned char out_byte) 
+\newline 
+{ 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-while(mask)
+unsigned char i=8;
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-{
+do { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -9122,7 +9383,7 @@ while(mask)
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-SDI=(value & mask)?1:0;
+MOSI = out_byte & 0x80; 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -9132,7 +9393,7 @@ SDI=(value & mask)?1:0;
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-SCLK=!CPOL;
+out_byte <<= 1;
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -9142,7 +9403,7 @@ SCLK=!CPOL;
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-SCLK=CPOL;
+MCLK = 1; 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -9152,13 +9413,61 @@ SCLK=CPOL;
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mask/=2;
-\newline 
+/* _asm nop _endasm; */\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-}
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* for slow peripherals */
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+if(MISO) 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+out_byte += 1; 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+MCLK = 0; 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+} while(--i);
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return out_byte; 
 \newline 
 }
 \layout Standard
@@ -9168,29 +9477,23 @@ Then, someplace in the code for the first hardware you would use
 
 
 \family typewriter 
-bit at 0x80 SDI;\SpecialChar ~
+bit at 0x80 MOSI;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 /* I/O port 0, bit 0 */
 \newline 
-bit at 0x81 SCLK;\SpecialChar ~
+bit at 0x81 MISO;\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 /* I/O port 0, bit 1 */
 \newline 
-bit CPOL;\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
+bit at 0x82 MCLK;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-/* This is a variable, let the linker allocate this one */
+/* I/O port 0, bit 2 */
 \layout Standard
 
 Similarly, for the second hardware you would use
@@ -9198,13 +9501,14 @@ Similarly, for the second hardware you would use
 
 
 \family typewriter 
-bit at 0x83 SDI;\SpecialChar ~
+bit at 0x83 MOSI;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 /* I/O port 0, bit 3 */
 \newline 
-bit at 0x91 SCLK;\SpecialChar ~
+bit at 0x91 MISO;\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 /* I/O port 1, bit 1 */
@@ -9214,18 +9518,11 @@ bit
 
 \end_inset 
 
- CPOL;\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
+ at 0x92 MCLK;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-/* This is a variable, let the linker allocate this one */
+/* I/O port 1, bit 2 */
 \layout Standard
 
 and you can use the same hardware dependent routine without changes, as
@@ -9250,6 +9547,11 @@ Parameters
 \end_inset 
 
 
+\begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
+
+\end_inset 
+
+
 \layout Standard
 
 Automatic (local) variables and parameters to functions can either be placed
@@ -9280,7 +9582,7 @@ They can be placed on the stack
 
 \end_inset 
 
either by using the
+ by using the
 \emph on 
  -
 \begin_inset ERT
@@ -9299,7 +9601,17 @@ status Collapsed
 
 
 \emph default 
- option or by using the 
+ option, by using 
+\emph on 
+#pragma\SpecialChar ~
+stackauto
+\emph default 
+
+\begin_inset LatexCommand \index{\#pragma stackauto}
+
+\end_inset 
+
+ or by using the 
 \emph on 
 reentrant
 \begin_inset LatexCommand \index{reentrant}
@@ -9688,11 +10000,9 @@ using
 \layout Standard
 
 Interrupt service routines open the door for some very interesting bugs:
-\layout Standard
-
-If the interrupt service routines changes variables which are accessed by
- other functions these variables should be declared 
+\newline 
+If an interrupt service routine changes variables which are accessed by
+ other functions these variables have to be declared 
 \emph on 
 volatile
 \emph default 
@@ -9708,7 +10018,7 @@ volatile
 If the access to these variables is not 
 \emph on 
 atomic
-\begin_inset LatexCommand \index{atomic access}
+\begin_inset LatexCommand \index{atomic}
 
 \end_inset 
 
@@ -9716,7 +10026,7 @@ atomic
 \emph default 
  (i.e.
  the processor needs more than one instruction for the access and could
- be interrupted while accessing the variable) the interrupt must disabled
+ 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.
@@ -9780,6 +10090,36 @@ counter
  
 \layout Standard
 
+The return address and the registers used in the interrupt service routine
+ are saved on the stack
+\begin_inset LatexCommand \index{stack}
+
+\end_inset 
+
+ so there must be sufficient stack space.
+ If there isn't variables or registers (or even the return address itself)
+ will be corrupted.
+ This 
+\emph on 
+stack overflow
+\emph default 
+
+\begin_inset LatexCommand \index{stack overflow}
+
+\end_inset 
+
+ is most likely to happen if the interrupt occurs during the 
+\begin_inset Quotes sld
+\end_inset 
+
+deepest
+\begin_inset Quotes srd
+\end_inset 
+
+ subroutine when the stack is already in use for f.e.
+ many return addresses.
+\layout Standard
+
 A special note here, int (16 bit) and long (32 bit) integer division
 \begin_inset LatexCommand \index{Division}
 
@@ -10132,6 +10472,41 @@ Since the number of interrupts available is chip specific and the interrupt
 \end_inset 
 
  for details on customizing startup.
+\layout Subsection
+
+Z80 Interrupt Service Routines
+\layout Standard
+
+The Z80 uses several different methods for determining the correct interrupt
+ vector depending on the hardware implementation.
+ Therefore, SDCC ignores the optional interrupt number and does not attempt
+ to generate an interrupt vector table.
+\layout Standard
+
+By default, SDCC generates code for a maskable interrupt, which uses an
+ RETI instruction to return from the interrupt.
+ To write an interrupt handler for the non-maskable interrupt, which needs
+ an RETN instruction instead, add the 
+\emph on 
+critical
+\emph default 
+ keyword:
+\layout Verse
+
+
+\family typewriter 
+void nmi_isr (void) critical interrupt
+\newline 
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline 
+}
 \layout Section
 
 Enabling and Disabling Interrupts
@@ -10454,8 +10829,108 @@ interrupt priorities
  On some architectures which don't support interrupt priorities these can
  be implemented by manipulating the interrupt mask and reenabling interrupts
  within the interrupt routine.
- Don't add complexity unless you have to.
+ Check there is sufficient space on the stack
+\begin_inset LatexCommand \index{stack}
+
+\end_inset 
+
+ and don't add complexity unless you have to.
+\layout Subsection
+
+Semaphore
+\begin_inset LatexCommand \index{semaphore}
+
+\end_inset 
+
+ locking (mcs51/ds390)
+\layout Standard
+
+Some architectures (mcs51/ds390) have an atomic
+\begin_inset LatexCommand \index{atomic}
+
+\end_inset 
+
+ bit test and
+\emph on 
+\emph default 
+clear
+\emph on 
+\emph default 
+instruction.
+ These type of instructions are typically used in preemptive multitasking
+ systems, where a routine f.e.
+ claims the use of a data structure ('acquires a lock
+\begin_inset LatexCommand \index{lock}
+
+\end_inset 
+
+ on it'), makes some modifications and then releases the lock when the data
+ structure is consistent again.
+ The instruction may also be used if interrupt and non-interrupt code have
+ to compete for a resource.
+ With the atomic bit test and clear instruction interrupts
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset 
+
+ don't have to be disabled for the locking operation.
+\layout Standard
+
+SDCC generates this instruction if the source follows this pattern:
+\layout Verse
+
+
+\family typewriter 
+volatile bit resource_is_free; 
+\newline 
+
+\newline 
+if (resource_is_free) 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+resource_is_free=0; 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
  
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+resource_is_free=1;
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+} 
+\layout Standard
+
+Note, mcs51 and ds390 support only an atomic
+\begin_inset LatexCommand \index{atomic}
+
+\end_inset 
+
+ bit test and 
+\emph on 
+clear
+\emph default 
+ instruction (as opposed to atomic bit test and 
+\emph on 
+set).
 \layout Section
 
 Functions using private register banks
@@ -10616,8 +11091,33 @@ _sdcc_external_startup()
  or perform some other critical operation prior to static & global variable
  initialization.
  On some mcs51 variants xdata has to be explicitly enabled before it can
- be accessed, this is the place to do it.
- See also the compiler option 
+ be accessed or if the watchdog 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 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-iram-size
+\begin_inset LatexCommand \index{-\/-iram-size}
+
+\end_inset 
+
+n
+\emph default 
+ is used.
+ (recommended for Chipcon CC1010).
+\layout Standard
+
+See also the compiler option 
 \emph on 
 -
 \begin_inset ERT
@@ -10754,7 +11254,11 @@ if( head != tail-1 )
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-buf[ head++ ] = c; 
+buf[ head++ ] = c;\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* access to a 256 byte aligned array */
 \newline 
 } 
 \layout Standard
@@ -13243,66 +13747,117 @@ putchar()
  in sdcc/device/lib.
 \layout Standard
 
-If you're short on memory you might want to use 
-\family typewriter 
-printf_small()
-\family default 
-\emph on 
-instead
-\emph default 
- of
+The default
 \family typewriter 
  printf()
 \begin_inset LatexCommand \index{printf()}
 
 \end_inset 
 
-.
 
 \family default 
- For the mcs51 there is an assembly version 
+implementation in
 \family typewriter 
-printf_fast()
+ printf_large.c
 \family default 
- which should fit the requirements of many embedded systems (by unsetting
- #defines it can be customized to 
+ does not support float (except on ds390).
+ To enable this recompile it with the option 
 \emph on 
-not
-\emph default 
- support long variables and field widths).
-\layout Subsection
-
-Math functions (sin, pow, sqrt etc.)
-\layout Subsection
+-
+\begin_inset ERT
+status Collapsed
 
-Other libraries
 \layout Standard
 
-Libraries
-\begin_inset LatexCommand \index{Libraries}
-
+\backslash 
+/
 \end_inset 
 
- included in SDCC should have a license at least as liberal as the GNU Lesser
- General Public License
-\begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
+DUSE_FLOATS=1
+\begin_inset LatexCommand \index{USE\_FLOATS}
 
 \end_inset 
 
-\emph on 
-LGPL
+
 \emph default 
-.
-\layout Comment
+ on the command line.
+ Use
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
 
-license statements for the libraries are missing.
- sdcc/device/lib/ser_ir.c
-\layout Comment
+\layout Standard
 
-or _decdptr f.e.
- come with a GPL (as opposed to LGPL) License - this will not be liberal
+\backslash 
+/
+\end_inset 
+
+-model-large
+\begin_inset LatexCommand \index{-\/-model-large}
+
+\end_inset 
+
+
+\emph default 
+ for the mcs51 port, since this uses a lot of memory.
+\layout Standard
+
+If you're short on memory you might want to use 
+\family typewriter 
+printf_small()
+\family default 
+\emph on 
+instead
+\emph default 
+ of
+\family typewriter 
+ printf().
+
+\family default 
+ For the mcs51 there is an assembly version 
+\family typewriter 
+printf_fast()
+\family default 
+ which should fit the requirements of many embedded systems (by unsetting
+ #defines it can be customized to 
+\emph on 
+not
+\emph default 
+ support long variables and field widths).
+\layout Subsection
+
+Math functions (sin, pow, sqrt etc.)
+\layout Subsection
+
+Other libraries
+\layout Standard
+
+Libraries
+\begin_inset LatexCommand \index{Libraries}
+
+\end_inset 
+
+ included in SDCC should have a license at least as liberal as the GNU Lesser
+ General Public License
+\begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
+
+\end_inset 
+
+\emph on 
+LGPL
+\emph default 
+.
+\layout Comment
+
+license statements for the libraries are missing.
+ sdcc/device/lib/ser_ir.c
+\layout Comment
+
+or _decdptr f.e.
+ come with a GPL (as opposed to LGPL) License - this will not be liberal
  enough for many embedded programmers.
 \layout Standard
 
@@ -13429,8 +13984,9 @@ status Collapsed
 
 \end_inset 
 
- memory (usually at the start of the external ram segment) and is 256 bytes
- in size.
+ memory (usually at the start of the external ram segment) and uses all
+ unused space in pdata (max.
+ 256 bytes).
  When -
 \begin_inset ERT
 status Collapsed
@@ -13466,7 +14022,8 @@ status Collapsed
 
  option, all parameters and local variables are allocated on the external
  stack (note: support libraries will need to be recompiled with the same
- options).
+ options.
+ There is a predefined target in the library makefile).
 \layout Standard
 
 The compiler outputs the higher order address byte of the external ram segment
@@ -13593,7 +14150,8 @@ save
 \end_inset 
 
  - this will save all current options to the save/restore stack.
- See restore.
+ See #pragma\SpecialChar ~
+restore.
 \layout Itemize
 
 restore
@@ -13605,47 +14163,103 @@ restore
  saves & restores can be nested.
  SDCC uses a save/restore stack: save pushes current options to the stack,
  restore pulls current options from the stack.
- See save.
+ See #pragma\SpecialChar ~
+save.
+\newline 
+
 \layout Itemize
 
-nogcse
-\begin_inset LatexCommand \index{\#pragma nogcse}
+callee_saves
+\begin_inset LatexCommand \index{\#pragma callee\_saves}
 
 \end_inset 
 
- - will stop global common subexpression elimination.
-\layout Itemize
 
-noinduction
-\begin_inset LatexCommand \index{\#pragma noinduction}
+\begin_inset LatexCommand \index{function prologue}
 
 \end_inset 
 
- - will stop loop induction optimizations.
-\layout Itemize
+ function1[,function2[,function3...]] - The compiler by default uses a caller
+ saves convention for register saving across function calls, however this
+ can cause unnecessary register pushing & popping
+\begin_inset LatexCommand \index{push/pop}
 
-nojtbound
-\begin_inset LatexCommand \index{\#pragma nojtbound}
+\end_inset 
+
+ when calling small functions from larger functions.
+ This option can be used to switch off the register saving convention for
+ the function names specified.
+ The compiler will not save registers when calling these functions, extra
+ code need to be manually inserted at the entry & exit for these functions
+ to save & restore the registers used by these functions, this can SUBSTANTIALLY
+ reduce code & improve run time performance of the generated code.
+ In the future the compiler (with inter procedural analysis) may be able
+ to determine the appropriate scheme to use for each function call.
+ If -
+\begin_inset ERT
+status Collapsed
 
+\layout Standard
+
+\backslash 
+/
 \end_inset 
 
- - will not generate code for boundary value checking, when switch statements
- are turned into jump-tables (dangerous).
- For more details see section 
-\begin_inset LatexCommand \ref{sub:'switch'-Statements}
+-callee-saves command line option is used, the function names specified
+ in #pragma\SpecialChar ~
+callee_saves
+\begin_inset LatexCommand \index{\#pragma callee\_saves}
 
 \end_inset 
 
-.
+ is appended to the list of functions specified in the command line.
 \layout Itemize
 
-nooverlay
-\begin_inset LatexCommand \index{\#pragma nooverlay}
+exclude
+\begin_inset LatexCommand \index{\#pragma exclude}
 
 \end_inset 
 
- - the compiler will not overlay the parameters and local variables of a
- function.
+ none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
+ of pairs of push/pop
+\begin_inset LatexCommand \index{push/pop}
+
+\end_inset 
+
+ instructions in 
+\emph on 
+I
+\emph default 
+nterrupt
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset 
+
+\emph on 
+S
+\emph default 
+ervice 
+\emph on 
+R
+\emph default 
+outines.
+ The directive should be placed immediately before the ISR function definition
+ and it affects ALL ISR functions following it.
+ To enable the normal register saving for ISR functions use #pragma\SpecialChar ~
+exclude\SpecialChar ~
+none
+\begin_inset LatexCommand \index{\#pragma exclude}
+
+\end_inset 
+
+.
+ See also the related keyword _naked
+\begin_inset LatexCommand \index{\_naked}
+
+\end_inset 
+
+.
 \layout Itemize
 
 less_pedantic
@@ -13657,37 +14271,38 @@ less_pedantic
  your own now ;-(
 \layout Itemize
 
-noloopreverse
-\begin_inset LatexCommand \index{\#pragma noloopreverse}
+disable_warning <nnnn>
+\begin_inset LatexCommand \index{\#pragma disable\_warning}
 
 \end_inset 
 
- - Will not do loop reversal optimization
+ - the compiler will not warn you anymore about warning number <nnnn>.
 \layout Itemize
 
-exclude
-\begin_inset LatexCommand \index{\#pragma exclude}
+nogcse
+\begin_inset LatexCommand \index{\#pragma nogcse}
 
 \end_inset 
 
- none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables generation of
- pair of push/pop
-\begin_inset LatexCommand \index{push/pop}
+ - will stop global common subexpression elimination.
+\layout Itemize
+
+noinduction
+\begin_inset LatexCommand \index{\#pragma noinduction}
 
 \end_inset 
 
- instruction in ISR function (using interrupt
-\begin_inset LatexCommand \index{interrupt}
+ - will stop loop induction optimizations.
+\layout Itemize
+
+noinvariant
+\begin_inset LatexCommand \index{\#pragma noinvariant}
 
 \end_inset 
 
- keyword).
- The directive should be placed immediately before the ISR function definition
- and it affects ALL ISR functions following it.
- To enable the normal register saving for ISR functions use #pragma\SpecialChar ~
-exclude\SpecialChar ~
-none
-\begin_inset LatexCommand \index{\#pragma exclude}
+ - will not do loop invariant optimizations.
+ For more details see Loop Invariants in section
+\begin_inset LatexCommand \ref{sub:Loop-Optimizations}
 
 \end_inset 
 
@@ -13719,33 +14334,44 @@ noiv
 about interrupts.
 \layout Itemize
 
-callee_saves
-\begin_inset LatexCommand \index{\#pragma callee\_saves}
+nojtbound
+\begin_inset LatexCommand \index{\#pragma nojtbound}
+
+\end_inset 
+
+ - will not generate code for boundary value checking, when switch statements
+ are turned into jump-tables (dangerous).
+ For more details see section 
+\begin_inset LatexCommand \ref{sub:'switch'-Statements}
 
 \end_inset 
 
+.
+\layout Itemize
 
-\begin_inset LatexCommand \index{function prologue}
+noloopreverse
+\begin_inset LatexCommand \index{\#pragma noloopreverse}
 
 \end_inset 
 
- function1[,function2[,function3...]] - The compiler by default uses a caller
- saves convention for register saving across function calls, however this
- can cause unnecessary register pushing & popping
-\begin_inset LatexCommand \index{push/pop}
+ - Will not do loop reversal optimization
+\layout Itemize
+
+nooverlay
+\begin_inset LatexCommand \index{\#pragma nooverlay}
 
 \end_inset 
 
- when calling small functions from larger functions.
- This option can be used to switch off the register saving convention for
- the function names specified.
- The compiler will not save registers when calling these functions, extra
- code need to be manually inserted at the entry & exit for these functions
- to save & restore the registers used by these functions, this can SUBSTANTIALLY
- reduce code & improve run time performance of the generated code.
- In the future the compiler (with inter procedural analysis) may be able
- to determine the appropriate scheme to use for each function call.
- If -
+ - the compiler will not overlay the parameters and local variables of a
+ function.
+\layout Itemize
+
+stackauto
+\begin_inset LatexCommand \index{\#pragma stackauto}
+
+\end_inset 
+
+- See option -
 \begin_inset ERT
 status Collapsed
 
@@ -13755,14 +14381,46 @@ status Collapsed
 /
 \end_inset 
 
--callee-saves command line option is used, the function names specified
- in #pragma\SpecialChar ~
-callee_saves
-\begin_inset LatexCommand \index{\#pragma callee\_saves}
+-stack-auto
+\begin_inset LatexCommand \index{-\/-stack-auto}
 
 \end_inset 
 
- is appended to the list of functions specified in the command line.
+ and section 
+\begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
+
+\end_inset 
+
+ Parameters and Local Variables.
+\layout Itemize
+
+opt_code_speed 
+\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.
+\layout Itemize
+
+opt_code_size 
+\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.
+\layout Itemize
+
+opt_code_balanced 
+\begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
+
+\end_inset 
+
+- The compiler will attempt to generate code that is both compact and fast,
+ as long as meeting one goal is not a detriment to the other (this is the
+ default).
 \layout Standard
 
 SDCPP supports the following #pragma directives:
@@ -14256,20 +14914,48 @@ sfr
 \emph default 
  is where the chip designers decided to put it.
  Needless to say that they didn't agree on a common name either.
- As pdata addressing is used in the startup code for the initialization
- of xdata variables a separate startup code should be used as described
- in section 
-\begin_inset LatexCommand \ref{sub:Startup-Code}
+ So that the startup code can correctly initialize xdata variables, you
+ should define an sfr with the name _XPAGE
+\family typewriter 
+
+\begin_inset LatexCommand \index{\_XPAGE (mcs51)}
 
 \end_inset 
 
-.
-\layout Subsection
 
-Other Features available by SFR
-\layout Standard
+\family default 
+ at the appropriate location if the default, port P2, is not used for this.
+ Some examples are:
+\layout Verse
 
-Some MCS51 variants offer features like Double DPTR
+
+\family typewriter 
+sfr at 0x92 _XPAGE; /* Cypress EZ-USB family */
+\layout Verse
+
+
+\family typewriter 
+sfr at 0xaf _XPAGE; /* some Silicon Labs (Cygnal) chips */
+\layout Verse
+
+
+\family typewriter 
+sfr at 0xaa _XPAGE; /* some Silicon Labs (Cygnal) chips */
+\layout Standard
+
+For more exotic implementations further customizations may be needed.
+ See section 
+\begin_inset LatexCommand \ref{sub:Startup-Code}
+
+\end_inset 
+
+ for other possibilities.
+\layout Subsection
+
+Other Features available by SFR
+\layout Standard
+
+Some MCS51 variants offer features like Double DPTR
 \begin_inset LatexCommand \index{DPTR}
 
 \end_inset 
@@ -14280,6 +14966,24 @@ Some MCS51 variants offer features like Double DPTR
  a patch to SDCC.
 \layout Section
 
+DS400 port
+\layout Standard
+
+The DS80C400 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
+ at 
+\size footnotesize 
+
+\begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
+
+\end_inset 
+
+.
+\layout Section
+
 The Z80 and gbz80 port
 \layout Standard
 
@@ -14441,16 +15145,23 @@ void Intr(void) interrupt 0
 T0IF = 0; /* Clear timer interrupt */
 \newline 
 }
-\layout Standard
+\layout Subsection
 
 Linking and assembling
-\newline 
+\layout Standard
+
 For assembling you can use either GPUTILS'
 \begin_inset LatexCommand \index{gputils (pic tools)}
 
 \end_inset 
 
  gpasm.exe or MPLAB's mpasmwin.exe.
+ GPUTILS is available from 
+\begin_inset LatexCommand \url{http://gputils.sourceforge.net/}
+
+\end_inset 
+
+.
  For linking you can use either GPUTIL's gplink or MPLAB's mplink.exe.
  If you use MPLAB and an interrupt function then the linker script file
  vectors section will need to be enlarged to link with mplink.
@@ -14547,6 +15258,13 @@ $(PRJ).hex: $(OBJS)
 \SpecialChar ~
 \SpecialChar ~
 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS)
+\layout Standard
+
+Please note that indentations within a
+\family typewriter 
+ Makefile
+\family default 
+ have to be done with a tabulator character.
 \layout Section
 
 The PIC16
@@ -14591,11 +15309,17 @@ status Collapsed
 /
 \end_inset 
 
--stack-auto Auto variables that are function parameters, will be saved on
- stack by default.
-\emph on 
-There is no need to specify this in the command line.
+-callee-saves See -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-all-callee-saves
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14609,10 +15333,10 @@ status Collapsed
 /
 \end_inset 
 
--float-reent All floating point functions are reentrant by default.
+-all-callee-saves All function arguments are passed on stack by default.
  
 \emph on 
-There is no need to specifiy this in the command line.
+There is no need to specify this in the command line.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14626,17 +15350,26 @@ status Collapsed
 /
 \end_inset 
 
--callee-saves See -
-\begin_inset ERT
-status Collapsed
+-fommit-frame-pointer Frame pointer will be omitted when the function uses
+ no local variables.
+\layout Subsection
 
-\layout Standard
+Port Specific Options
+\begin_inset LatexCommand \index{Options PIC16}
 
-\backslash 
-/
 \end_inset 
 
--all-callee-saves
+
+\layout Standard
+
+The port specific options appear after the global options in the sdcc --help
+ output.
+\layout Subsubsection
+
+General Options
+\layout Standard
+
+General options enable certain port features and optimizations.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14650,10 +15383,7 @@ status Collapsed
 /
 \end_inset 
 
--all-callee-saves All function arguments are passed on stack by default.
-\emph on 
-There is no need to specify this in the command line.
+-nodefaultlibs do not link default libraries when linking.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14667,21 +15397,25 @@ status Collapsed
 /
 \end_inset 
 
--fommit-frame-pointer Frame pointer will be omitted when the function uses
- no local variables.
-\layout Subsection
-
-Port Specific Options
-\layout Standard
+-obanksel=# Set optimization level for inserting BANKSELs.
+\begin_deeper 
+\layout List
+\labelwidthstring 00.00.0000
 
-The port specific options appear after the global options in the sdcc --help
- output.
-\layout Subsubsection
+0 is no optimization
+\layout List
+\labelwidthstring 00.00.0000
 
-General Options
-\layout Standard
+1 checks previous used register and if it is the same then does not emit
+ BANKSEL, accounts only for labels.
+\layout List
+\labelwidthstring 00.00.0000
 
-General options enable certain port features and optimizations.
+2 tries to check the location of (even different) symbols and removes BANKSELs
+ if they are in the same bank.
+ Important: This will only work properly if the linker script does not have
+ sections across bank borders!
+\end_deeper 
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14695,8 +15429,7 @@ status Collapsed
 /
 \end_inset 
 
--pgen-bank Instructs the port to insert BANKSEL directives before instructions
- that use the Bank Select Register (BSR).
+-pomit-config-words Omit the generation of the configuration words.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14710,8 +15443,7 @@ status Collapsed
 /
 \end_inset 
 
--pomit-config-words Instructs the port to omit the generation of the configurati
-on words.
+-pomit-ivt Omit the generation of the interrupt vectors.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14725,11 +15457,7 @@ status Collapsed
 /
 \end_inset 
 
--pomit-ivt Instructs the port to omit the generation of the interrupt vectors
-\layout List
-\labelwidthstring 00.00.0000
-
--
+-pleave-reset-vector Used in conjuction with -
 \begin_inset ERT
 status Collapsed
 
@@ -14739,8 +15467,7 @@ status Collapsed
 /
 \end_inset 
 
--pleave-reset-vector Used in conjuction with the previous command, instructs
- the port NOT to omit the reset vector.
+-pomit-ivt, instructs the port NOT to omit the reset vector.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14794,12 +15521,21 @@ status Collapsed
 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
  unitialized data variables with [kword].
  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
-\layout Subsubsection
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
 
-Debugging Options
 \layout Standard
 
-Debugging options enable extra debugging information in the output files.
+\backslash 
+/
+\end_inset 
+
+-ivt-loc <nnnn> positions the Interrupt Vector Table at location <nnnn>.
+ Useful for bootloaders.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14813,7 +15549,7 @@ status Collapsed
 /
 \end_inset 
 
--debug-xtra Similar to --debug, but dumps more information.
+-asm= sets the full path and name of an external assembler to call.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14827,9 +15563,7 @@ status Collapsed
 /
 \end_inset 
 
--debug-ralloc Force register allocator to dump <source>.d file with debugging
- information.
- <source> is the name of the file compiled.
+-link= sets the full path and name of an external linker to call.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -14843,84 +15577,239 @@ status Collapsed
 /
 \end_inset 
 
--pcode-verbose Enable pcode debugging information in translation.
-\layout Subsection
+-call-tree dump call tree in .calltree file
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
 
-Preprocessor Macros
 \layout Standard
 
-PIC16 port defines the following preprocessor macros while translating a
- source.
+\backslash 
+/
+\end_inset 
+
+-mplab-comp MPLAB compatibility option.
+ Currently only suppresses special gpasm directives.
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
 \layout Standard
-\align center 
 
-\begin_inset  Tabular
-<lyxtabular version="3" rows="2" columns="2">
-<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
-<row topline="true" bottomline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
+\backslash 
+/
+\end_inset 
+
+-use-crt= Use a custom run-time module instead of the defaults.
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
 
 \layout Standard
 
-Macro
+\backslash 
+/
 \end_inset 
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
+
+-no-crt Don't link the default run-time modules
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
 
 \layout Standard
 
-Description
+\backslash 
+/
 \end_inset 
-</cell>
-</row>
-<row topline="true" bottomline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
 
+-optimize-goto Try to use (conditional) BRA instead of GOTO
+\layout Subsubsection
+
+Debugging Options
 \layout Standard
 
-pic18fxxxx
+Debugging options enable extra debugging information in the output files.
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
 \end_inset 
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
+
+-debug-xtra Similar to -
+\begin_inset ERT
+status Collapsed
 
 \layout Standard
 
-MCU Identification.
-\emph on 
-xxxx
-\emph default 
- is the microcontrol identification number, i.e.
- 452, 6620, etc
+\backslash 
+/
 \end_inset 
-</cell>
-</row>
-</lyxtabular>
+
+-debug
+\begin_inset LatexCommand \index{-\/-debug}
 
 \end_inset 
 
+, but dumps more information.
+\layout List
+\labelwidthstring 00.00.0000
 
-\layout Subsection
+-
+\begin_inset ERT
+status Collapsed
 
-Directories
 \layout Standard
 
-PIC16 port uses the following directories for searching header files and
- libraries.
+\backslash 
+/
+\end_inset 
+
+-debug-ralloc Force register allocator to dump <source>.d file with debugging
+ information.
+ <source> is the name of the file compiled.
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
 \layout Standard
-\align center 
 
-\begin_inset  Tabular
-<lyxtabular version="3" rows="3" columns="4">
-<features>
-<column alignment="center" valignment="top" leftline="true" width="0">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+\backslash 
+/
+\end_inset 
+
+-pcode-verbose Enable pcode debugging information in translation.
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-denable-peeps Force the usage of peepholes.
+ Use with care.
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-gstack Trace push/pops for stack pointer overflow
+\layout Subsection
+
+Preprocessor Macros
+\layout Standard
+
+PIC16 port defines the following preprocessor macros while translating a
+ source.
+\layout Standard
+\align center 
+
+\begin_inset  Tabular
+<lyxtabular version="3" rows="2" columns="2">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Macro
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Description
+\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
+
+pic18fxxxx
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+MCU Identification.
+\emph on 
+xxxx
+\emph default 
+ is the microcontrol identification number, i.e.
+ 452, 6620, etc
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset 
+
+
+\layout Subsection
+
+Directories
+\layout Standard
+
+PIC16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset 
+
+ port uses the following directories for searching header files and libraries.
+\layout Standard
+\align center 
+
+\begin_inset  Tabular
+<lyxtabular version="3" rows="3" columns="4">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
 <column alignment="center" valignment="top" width="0">
 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
 <row topline="true" bottomline="true">
@@ -14929,7 +15818,343 @@ PIC16 port uses the following directories for searching header files and
 
 \layout Standard
 
-Directory
+Directory
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Description
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Target
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Command prefix
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+PREFIX/sdcc/include/pic16
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+PIC16 specific headers
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Compiler
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+-I
+\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
+
+PREFIX/sdcc/lib/pic16
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+PIC16 specific libraries
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Linker
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+-L
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset 
+
+
+\layout Subsection
+
+Pragmas
+\begin_inset LatexCommand \label{sub:PIC16_Pragmas}
+
+\end_inset 
+
+
+\layout Standard
+
+PIC16 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.
+ 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 
+The stack pragma should be used only once in a project.
+ Multiple pragmas may result in indeterminate behaviour of the program.
+\newline 
+The format is as follows:
+\layout LyX-Code
+
+#pragma stack bottom_address [stack_size]
+\layout Standard
+
+
+\emph on 
+bottom_address
+\emph default 
+ is the lower bound of the stack section.
+ The stack pointer initially will point at address (bottom_address+stack_size-1).
+\layout LyX-Code
+
+Example:
+\layout LyX-Code
+
+\layout LyX-Code
+
+/* initializes stack of 100 bytes at RAM address 0x200 */
+\layout LyX-Code
+
+#pragma stack 0x200 100
+\layout List
+\labelwidthstring 00.00.0000
+
+wparam 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 one byte of the first
+ parameter will get lost.
+ This pragma should be placed in the header file to propagate the calling
+ convention to all callers.
+\layout LyX-Code
+
+#pragma wparam function1[, function2, ...]
+\layout LyX-Code
+
+\layout LyX-Code
+
+Example:
+\layout LyX-Code
+
+\layout LyX-Code
+
+/* pass one byte via stack and one byte via WREG */
+\layout LyX-Code
+
+#pragma wparam foo
+\layout LyX-Code
+
+void foo(int x);
+\layout List
+\labelwidthstring 00.00.0000
+
+code place a function symbol at static FLASH address
+\layout LyX-Code
+
+Example:
+\layout LyX-Code
+
+\layout LyX-Code
+
+/* place function test_func at 0x4000 */
+\layout LyX-Code
+
+#pragma code test_func 0x4000
+\layout List
+\labelwidthstring 00.00.0000
+
+udata pragma udata instructs the compiler to emit code so that linker will
+ place a variable at a specific memory bank
+\layout LyX-Code
+
+Example:
+\layout LyX-Code
+
+\layout LyX-Code
+
+/* places variable foo at bank2 */
+\layout LyX-Code
+
+#pragma udata bank2 foo
+\layout LyX-Code
+
+char foo;
+\layout Standard
+
+In order for this pragma to work extra SECTION directives should be added
+ in the .lkr script.
+ In the following example a sample .lkr file is shown:
+\layout LyX-Code
+
+\layout LyX-Code
+
+// Sample linker script for the PIC18F452 processor
+\layout LyX-Code
+
+LIBPATH .
+\layout LyX-Code
+
+CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
+\layout LyX-Code
+
+CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
+\layout LyX-Code
+
+ACCESSBANK NAME=accessram  START=0x0            END=0x7F
+\layout LyX-Code
+
+\layout LyX-Code
+
+DATABANK   NAME=gpr0       START=0x80           END=0xFF
+\layout LyX-Code
+
+DATABANK   NAME=gpr1       START=0x100          END=0x1FF
+\layout LyX-Code
+
+DATABANK   NAME=gpr2       START=0x200          END=0x2FF
+\layout LyX-Code
+
+DATABANK   NAME=gpr3       START=0x300          END=0x3FF
+\layout LyX-Code
+
+DATABANK   NAME=gpr4       START=0x400          END=0x4FF
+\layout LyX-Code
+
+DATABANK   NAME=gpr5       START=0x500          END=0x5FF
+\layout LyX-Code
+
+ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
+\layout LyX-Code
+
+\layout LyX-Code
+
+SECTION    NAME=CONFIG     ROM=config
+\layout LyX-Code
+
+\layout LyX-Code
+
+SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
+\layout LyX-Code
+
+SECTION    NAME=bank1      RAM=gpr1       # should be added to link
+\layout LyX-Code
+
+SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
+\layout LyX-Code
+
+SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
+\layout LyX-Code
+
+SECTION    NAME=bank4      RAM=gpr4
+\layout LyX-Code
+
+SECTION    NAME=bank5      RAM=gpr5
+\layout Standard
+
+The linker will recognise the section name set in the pragma statement and
+ will position the variable at the memory bank set with the RAM field at
+ the SECTION line in the linker script file.
+\layout List
+\labelwidthstring 00.00.0000
+
+library instructs the linker to use a library module.
+\newline 
+Usage:
+\layout LyX-Code
+
+#pragma library module_name
+\layout Standard
+
+
+\emph on 
+module_name
+\emph default 
+ can be any library or object file (including its path).
+ Note that there are four reserved keywords which have special meaning.
+ These are:
+\layout Standard
+\align center 
+
+\begin_inset  Tabular
+<lyxtabular version="3" rows="6" columns="3">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="block" valignment="top" leftline="true" width="20page%">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Keyword
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Description
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -14937,15 +16162,27 @@ Directory
 
 \layout Standard
 
-Description
+Module to link
 \end_inset 
 </cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-Target
+
+\series bold 
+ignore
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ignore all library pragmas
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -14953,7 +16190,9 @@ Target
 
 \layout Standard
 
-Command prefix
+
+\emph on 
+(none)
 \end_inset 
 </cell>
 </row>
@@ -14963,15 +16202,17 @@ Command prefix
 
 \layout Standard
 
-PREFIX/sdcc/include/pic16
+
+\series bold 
+c
 \end_inset 
 </cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-PIC16 specific headers
+link the C library
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -14979,25 +16220,31 @@ PIC16 specific headers
 
 \layout Standard
 
-Compiler
+
+\emph on 
+libc18f
+\emph default 
+.lib
 \end_inset 
 </cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
--I
+
+\series bold 
+math
 \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
 
-PREFIX/sdcc/lib/pic16
+link the Math libarary
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15005,15 +16252,31 @@ PREFIX/sdcc/lib/pic16
 
 \layout Standard
 
-PIC16 specific libraries
+
+\emph on 
+libm18f
+\emph default 
+.lib
 \end_inset 
 </cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-Linker
+
+\series bold 
+io
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+link the I/O library
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15021,64 +16284,71 @@ Linker
 
 \layout Standard
 
--L
+
+\emph on 
+libio18f*
+\emph default 
+.lib
 \end_inset 
 </cell>
 </row>
-</lyxtabular>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\end_inset 
+\layout Standard
 
 
-\layout Subsection
+\series bold 
+debug
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-Pragmas
 \layout Standard
 
-PIC16 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.
- This is an adhoc solution since gplink does not support yet stack.
- When the gplink issue is resolved the pragma will be deprecated
-\begin_inset Foot
-collapsed true
+link the debug library
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
 
 \emph on 
-It is important to initialize the stack, otherwise strange things can happen.
- Stack is not initialized by default because there are some sources that
- do not require it.
- (like library sources)
+libdebug
+\emph default 
+.lib
 \end_inset 
+</cell>
+</row>
+</lyxtabular>
 
-.
-\newline 
-The stack pragma should be used only once in a project.
- Multiple pragmas may result in indeterminate behaviour of the program.
-\newline 
-If you omit setting the pragma the port emits a warning message before linking.
- If not initializing the stack is desired ignore the message.
-\layout LyX-Code
-
-Example:
-\layout LyX-Code
-
-\layout LyX-Code
+\end_inset 
 
-/* initializes stack at RAM address 0x5ff*/
-\layout LyX-Code
 
-#pragma stack 0x5ff
-\layout LyX-Code
+\newline 
+* is the device number, i.e.
+ 452 for PIC18F452 MCU.
+\layout Standard
 
+This feature allows for linking with specific libraries withoug having to
+ explicit name them in the command line.
+ Note that the 
+\noun on 
+ignore
+\noun default 
+ keyword will reject all modules specified by the library pragma.
 \layout Subsection
 
 Header Files
+\begin_inset LatexCommand \label{sub:PIC16_Header-Files}
+
+\end_inset 
+
+
 \layout Standard
 
 There is one main header file that can be included to the source files using
@@ -15089,7 +16359,7 @@ pic18fregs.h
 \series default 
 .
  This header file contains the definitions for the processor special registers,
- so it is necessery if the soruce accesses them.
+ so it is necessary if the source accesses them.
  It can be included by adding the following line in the beginning of the
  file:
 \layout LyX-Code
@@ -15104,9 +16374,13 @@ The specific microcontroller is selected within the pic18fregs.h automatically,
 Libraries
 \layout Standard
 
-The libraries that pic16 port depends on are the microcontroller device
- libraries which contain the symbol definitions for the microcontroller
- special function registers.
+The libraries that PIC16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset 
+
+ port depends on are the microcontroller device libraries which contain
+ the symbol definitions for the microcontroller special function registers.
  These libraries have the format pic18fxxxx.lib, where 
 \emph on 
 xxxx
@@ -15122,12 +16396,53 @@ Libraries are created with gplib which is part of the gputils package
 \end_inset 
 
 .
+\layout Subsubsection
+
+Building the libraries
+\layout Standard
+
+Before using SDCC/pic16 there are some libraries that need to be compiled.
+ This process is not done automatically by SDCC since not all users use
+ SDCC for pic16 projects.
+ So each user should compile the libraries separately.
+\layout Standard
+
+The steps to compile the pic16 libraries under Linux are:
+\layout LyX-Code
+
+cd device/lib/pic16
+\layout LyX-Code
+
+./configure
+\layout LyX-Code
+
+make
+\layout LyX-Code
+
+cd ..
+\layout LyX-Code
+
+make model-pic16
+\layout LyX-Code
+
+su -c 'make install'     # install the libraries, you need the root password
+\layout Standard
+
+If you need to install the headers to, do:
+\layout LyX-Code
+
+cd device/include
+\layout LyX-Code
+
+su -c 'make install'     # install the headers, you need the root password
+\layout LyX-Code
+
 \layout Subsection
 
 Memory Models
 \layout Standard
 
-The following memory models are supported by PIC16 port:
+The following memory models are supported by the PIC16 port:
 \layout Itemize
 
 small model
@@ -15248,8 +16563,13 @@ near
  model's pointers.
 \layout Standard
 
-The standard device libraries (see 4.5.6) contain no reference to pointers,
- so they can be used with both memory models.
+The standard device libraries (see 
+\begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
+
+\end_inset 
+
+) contain no reference to pointers, so they can be used with both memory
+ models.
 \layout Subsection
 
 Stack
@@ -15267,13 +16587,21 @@ FSR1 is assigned as stack pointer
 FSR2 is assigned as frame pointer
 \layout Standard
 
-The following stack models are supported by PIC16 port
+The following stack models are supported by the PIC16 port
 \layout Itemize
 
-small model
+
+\noun on 
+small
+\noun default 
+ model
 \layout Itemize
 
-large model
+
+\noun on 
+large
+\noun default 
+ model
 \layout Standard
 
 
@@ -15385,11 +16713,27 @@ Frame pointer FSR2
 \layout Standard
 
 
-\series bold 
-Currently stack and frame pointers should be initialized explicit by the
- user at the desired Data RAM position (see 4.5.5 Pragma Stack).
- Uninitialized stack and frame pointers can result in unexpected behavior
- of the resulting binary.
+\noun on 
+Large 
+\noun default 
+stack model is currently not working properly throughout the code generator.
+ So its use is not advised.
+ Also there are some other points that need special care:
+\newline 
+
+\layout Enumerate
+
+Do not create stack sections with size more than one physical bank (that
+ is 256 bytes)
+\layout Enumerate
+
+Stack sections should no cross physical bank limits (i.e.
+ #pragma stack 0x50 0x100)
+\layout Standard
+
+These limitations are caused by the fact that only FSRxL is modified when
+ using SMALL stack model, so no more than 256 bytes of stack can be used.
+ This problem will disappear after LARGE model is fully implemented.
 \layout Subsection
 
 Function return values
@@ -15524,8 +16868,12 @@ on stack, FSR0 points to the beginning
 Interrupts
 \layout Standard
 
-When entering an interrupt, currently the PIC16 port automatically saves
- the following registers:
+When entering an interrupt, currently the PIC16
+\begin_inset LatexCommand \index{PIC16}
+
+\end_inset 
+
+ port automatically saves the following registers:
 \layout Itemize
 
 WREG
@@ -15543,7 +16891,17 @@ PROD (PRODL and PRODH)
 FSR0 (FSR0L and FSR0H)
 \layout Standard
 
-These registers are restored upon return from the interrupt routine
+These registers are restored upon return from the interrupt routine.
+\layout Standard
+
+When entering a high priority interrupt WREG, STATUS and BSR are not explicit
+ saved by software.
+ The hardware shadow registers for WREG, STATUS and BSR are used in these
+ cases.
+\layout Standard
+
+
 \begin_inset Foot
 collapsed false
 
@@ -15593,10 +16951,23 @@ on, which also builds and installs the debugger in the target directory
 Compiling for Debugging
 \layout Standard
 
-The \SpecialChar \-
-\SpecialChar \-
-debug option must be specified for all files for which debug information
- is to be generated.
+The -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-debug
+\begin_inset LatexCommand \index{-\/-debug}
+
+\end_inset 
+
+ option must be specified for all files for which debug information is to
+ be generated.
  The complier generates a .adb file for each of these files.
  The linker creates the .cdb
 \begin_inset LatexCommand \index{<file>.cdb}
@@ -15967,7 +17338,8 @@ The following is a list of key mapping for the debugger interface.
 \family typewriter 
 
 \newline 
-;; Current Listing :: 
+;;\SpecialChar ~
+Current Listing :: 
 \newline 
 ;;key\SpecialChar ~
 \SpecialChar ~
@@ -15983,7 +17355,6 @@ The following is a list of key mapping for the debugger interface.
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
 binding\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16022,8 +17393,7 @@ Comment
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-------\SpecialChar ~
+-------\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16045,11 +17415,13 @@ Comment
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
---------
+-------
 \newline 
 ;; 
 \newline 
-;; n\SpecialChar ~
+;;\SpecialChar ~
+n\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16063,7 +17435,7 @@ Comment
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-next-from-src\SpecialChar ~
+sdcdb-next-from-src\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16075,7 +17447,9 @@ Comment
 \SpecialChar ~
 SDCDB next command 
 \newline 
-;; b\SpecialChar ~
+;;\SpecialChar ~
+b\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16089,7 +17463,7 @@ SDCDB next command
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-back-from-src\SpecialChar ~
+sdcdb-back-from-src\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16101,7 +17475,9 @@ SDCDB next command
 \SpecialChar ~
 SDCDB back command 
 \newline 
-;; c\SpecialChar ~
+;;\SpecialChar ~
+c\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16115,7 +17491,7 @@ SDCDB back command
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-cont-from-src\SpecialChar ~
+sdcdb-cont-from-src\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16127,7 +17503,9 @@ SDCDB back command
 \SpecialChar ~
 SDCDB continue command
 \newline 
-;; s\SpecialChar ~
+;;\SpecialChar ~
+s\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16141,7 +17519,7 @@ SDCDB continue command
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-step-from-src\SpecialChar ~
+sdcdb-step-from-src\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16153,7 +17531,9 @@ SDCDB continue command
 \SpecialChar ~
 SDCDB step command 
 \newline 
-;; ?\SpecialChar ~
+;;\SpecialChar ~
+?\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16167,7 +17547,7 @@ SDCDB step command
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-whatis-c-sexp\SpecialChar ~
+sdcdb-whatis-c-sexp\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16225,9 +17605,12 @@ SDCDB ptypecommand for data at
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- buffer point 
+\SpecialChar ~
+buffer point 
 \newline 
-;; x\SpecialChar ~
+;;\SpecialChar ~
+x\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16241,7 +17624,7 @@ SDCDB ptypecommand for data at
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdbsrc-delete\SpecialChar ~
+sdcdbsrc-delete\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16303,9 +17686,11 @@ SDCDB Delete all breakpoints if no arg
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+\SpecialChar ~
 given or delete arg (C-u arg x) 
 \newline 
-;; m\SpecialChar ~
+;;\SpecialChar ~
+m\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16319,7 +17704,8 @@ given or delete arg (C-u arg x)
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdbsrc-frame\SpecialChar ~
+\SpecialChar ~
+sdcdbsrc-frame\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16434,7 +17820,8 @@ given or display frame arg
 \SpecialChar ~
 buffer point 
 \newline 
-;; !\SpecialChar ~
+;;\SpecialChar ~
+!\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16448,7 +17835,8 @@ buffer point
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdbsrc-goto-sdcdb\SpecialChar ~
+\SpecialChar ~
+sdcdbsrc-goto-sdcdb\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16460,7 +17848,8 @@ buffer point
 \SpecialChar ~
 Goto the SDCDB output buffer 
 \newline 
-;; p\SpecialChar ~
+;;\SpecialChar ~
+p\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16474,7 +17863,8 @@ Goto the SDCDB output buffer
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-print-c-sexp\SpecialChar ~
+\SpecialChar ~
+sdcdb-print-c-sexp\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16533,9 +17923,11 @@ SDCDB print command for data at
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- buffer point 
+\SpecialChar ~
+buffer point 
 \newline 
-;; g\SpecialChar ~
+;;\SpecialChar ~
+g\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16549,7 +17941,8 @@ SDCDB print command for data at
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdbsrc-goto-sdcdb\SpecialChar ~
+\SpecialChar ~
+sdcdbsrc-goto-sdcdb\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16561,7 +17954,8 @@ SDCDB print command for data at
 \SpecialChar ~
 Goto the SDCDB output buffer 
 \newline 
-;; t\SpecialChar ~
+;;\SpecialChar ~
+t\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16575,7 +17969,8 @@ Goto the SDCDB output buffer
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdbsrc-mode\SpecialChar ~
+\SpecialChar ~
+sdcdbsrc-mode\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16595,7 +17990,9 @@ Toggles Sdcdbsrc mode (turns it off)
 \newline 
 ;; 
 \newline 
-;; C-c C-f\SpecialChar ~
+;;\SpecialChar ~
+C-c\SpecialChar ~
+C-f\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16603,7 +18000,8 @@ Toggles Sdcdbsrc mode (turns it off)
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-finish-from-src\SpecialChar ~
+\SpecialChar ~
+sdcdb-finish-from-src\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16615,7 +18013,9 @@ SDCDB finish command
 \newline 
 ;; 
 \newline 
-;; C-x SPC\SpecialChar ~
+;;\SpecialChar ~
+C-x\SpecialChar ~
+SPC\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16623,7 +18023,8 @@ SDCDB finish command
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdb-break\SpecialChar ~
+\SpecialChar ~
+sdcdb-break\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16643,7 +18044,9 @@ SDCDB finish command
 \SpecialChar ~
 Set break for line with point 
 \newline 
-;; ESC t\SpecialChar ~
+;;\SpecialChar ~
+ESC\SpecialChar ~
+t\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16653,7 +18056,8 @@ Set break for line with point
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- sdcdbsrc-mode\SpecialChar ~
+\SpecialChar ~
+sdcdbsrc-mode\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16671,7 +18075,11 @@ Set break for line with point
 \SpecialChar ~
 Toggle Sdcdbsrc mode 
 \newline 
-;; ESC m\SpecialChar ~
+;;\SpecialChar ~
+ESC\SpecialChar ~
+m\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16680,8 +18088,8 @@ Toggle Sdcdbsrc mode
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+sdcdbsrc-srcmode\SpecialChar ~
 \SpecialChar ~
- sdcdbsrc-srcmode\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -16693,7 +18101,7 @@ Toggle Sdcdbsrc mode
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
- Toggle list mode 
+Toggle list mode 
 \newline 
 ;; 
 \newline 
@@ -16715,7 +18123,7 @@ Use the smallest data type to represent your data-value.
  promoted to 'signed int' before doing any operation.
  This promotion can be omitted, if the result is the same.
  The effect of the promotion rules together with the sign-extension is often
- supprising:
+ surprising:
 \begin_deeper 
 \layout Verse
 
@@ -17373,7 +18781,27 @@ sdcc/Changelog
 
 \layout Standard
 
-ASXXXX Assemblers and ASLINK Relocating Linker
+ASXXXX
+\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Assembler documentation}
+
+\end_inset 
+
+ Assemblers and ASLINK
+\begin_inset LatexCommand \index{aslink}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Linker documentation}
+
+\end_inset 
+
+ Relocating Linker
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -17886,7 +19314,7 @@ splint
 
 \layout Standard
 
-Statically checks c sources
+Statically checks c sources (has anyone adapted splint for SDCC?)
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -18242,7 +19670,7 @@ The SDCC project is hosted on the SDCC sourceforge site at
 
 .
  You'll find the complete set of mailing lists
-\begin_inset LatexCommand \index{Mailing list}
+\begin_inset LatexCommand \index{Mailing list(s)}
 
 \end_inset 
 
@@ -18459,8 +19887,16 @@ Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
 
 \end_inset 
 
-, lists and forums are archived and searchable so if you are lucky someone
- already had a similar problem.
+, lists
+\begin_inset LatexCommand \index{Mailing list(s)}
+
+\end_inset 
+
+ 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
@@ -18790,10 +20226,6 @@ void f () {
 \SpecialChar ~
 global = 2; 
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-return; 
-\newline 
 }
 \layout Subsection
 
@@ -18864,10 +20296,22 @@ Loop Optimizations
 \end_inset 
 
 
+\begin_inset LatexCommand \label{sub:Loop-Optimizations}
+
+\end_inset 
+
+
 \layout Standard
 
-Two types of loop optimizations are done by SDCC loop invariant lifting
- and strength reduction of loop induction variables.
+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.
@@ -19146,17 +20590,19 @@ Note the subexpressions
 
 \layout Standard
 
-SDCC changes switch statements to jump tables
+SDCC can optimize switch statements to jump tables
 \begin_inset LatexCommand \index{jump tables}
 
 \end_inset 
 
- when the following conditions are true.
+.
+ 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 case labels are in numerical sequence, the labels need not be in order,
- and the starting number need not be one or zero.
+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
 
@@ -19283,8 +20729,7 @@ case 3: ...\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-case 2: ...
+
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -19317,6 +20762,164 @@ case 6: ...\SpecialChar ~
 \SpecialChar ~
 case 3: ...
  
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+case 7: ...\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 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 ~
+\SpecialChar ~
+case 9: ...\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 6: ...
+\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 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+case 11: ...\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 8: ...
 \newline 
 }\SpecialChar ~
 \SpecialChar ~
@@ -19363,16 +20966,24 @@ Both the above switch statements will be implemented using a jump-table.
 \end_deeper 
 \layout Itemize
 
-The number of case labels is at least three, since it takes two conditional
- statements to handle the boundary conditions.
+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
 
-The number of case labels is less than 84, since each label takes 3 bytes
- and a jump-table can be utmost 256 bytes long.
+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 gaps in the numeric sequence or those that
have more that 84 case labels can be split into more than one switch statement
+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
 
@@ -19402,22 +21013,52 @@ case 4: ...
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 9: ...
+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: ...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+case 104: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 10: ...
+case 105: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 11: ...
+case 106: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 12: ...
+case 107: ...
  
 \newline 
 }
@@ -19449,6 +21090,21 @@ case 3: ...
 \SpecialChar ~
 case 4: ...
  
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+case 5: ...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+case 6: ...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+case 7: ...
 \newline 
 }
 \layout Standard
@@ -19462,27 +21118,37 @@ switch (i) {
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 9:\SpecialChar ~
+case 101: ...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+case 102: ...
+\newline 
+\SpecialChar ~
 \SpecialChar ~
-...
+case 103: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 10:\SpecialChar ~
-...
+case 104: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 11:\SpecialChar ~
-...
+case 105: ...
  
 \newline 
 \SpecialChar ~
 \SpecialChar ~
-case 12:\SpecialChar ~
-...
+case 106: ...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+case 107: ...
  
 \newline 
 }
@@ -19490,9 +21156,15 @@ case 12:\SpecialChar ~
 
 then both the switch statements will be implemented using jump-tables whereas
  the unmodified switch statement will not be.
- You might also consider inserting dummy cases 0 and 5 to 8 in this example.
-\newline 
+\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}
 
@@ -20118,7 +21790,12 @@ status Collapsed
 \emph default 
 ).
  E.g.
- some variants of the 8051 MCU allow only 
+ some variants of the 8051 MCU
+\begin_inset LatexCommand \index{MCS51 variants}
+
+\end_inset 
+
+ allow only 
 \family typewriter 
 ajmp
 \family default 
@@ -20544,33 +22221,6 @@ int i,j; /* are valid in ANSI but not valid in SDCC */
 \newline 
 }
 \end_deeper 
-\layout Itemize
-
-functions declared as pointers
-\begin_inset LatexCommand \index{Pointer (to function)}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{function pointers}
-
-\end_inset 
-
- must be dereferenced during the call.
-\begin_deeper 
-\layout Verse
-
-
-\family typewriter 
-int (*foo)();
-\newline 
-...
-\newline 
-/* has to be called like this */ 
-\newline 
-(*foo)(); /* ANSI standard allows calls to be made like 'foo()' */
-\end_deeper 
 \layout Section
 
 Cyclomatic Complexity
@@ -20871,7 +22521,16 @@ Figure II gives a table of iCode operations supported by the compiler.
 \series bold 
 \shape italic 
 \color red
-<Where is Figure II ?>
+<Where is Figure II?>
+\layout Comment
+
+In the original article Figure II was announced to be downloadable on 
+\shape italic 
+Circuit Cellar
+\shape default 
+'s web site.
+ Unfortunately it never seemed to have shown up there, so: where is Figure
+ II?
 \layout Paragraph*
 
 ICode Example