corrected spelling error
[fw/sdcc] / doc / sdccman.lyx
index d4618487e64f2df89f8fe33c012d584f7158b49f..c8d6fa4dc38dd6020c20cdf970b820bdd48a0d32 100644 (file)
@@ -1,4 +1,4 @@
-#LyX 1.4.4 created this file. For more info see http://www.lyx.org/
+#LyX 1.4.5 created this file. For more info see http://www.lyx.org/
 \lyxformat 245
 \begin_document
 \begin_header
@@ -104,11 +104,11 @@ SDCC Compiler User Guide
 \begin_layout Date
 
 \size normal
-SDCC 2.7.1
+SDCC 2.8.5
 \size footnotesize
 
 \newline
-$Date::             
+$Date::            $ 
 \newline
 $Revision$
 \end_layout
@@ -730,7 +730,7 @@ open source
 freeware
 \emph default
 ; source code for all the sub-packages (pre-processor, assemblers, linkers
- etc) is distributed with the package.
+ etc.) is distributed with the package.
  This documentation is maintained using a free open source word processor
  (LyX).
 \newline
@@ -836,8 +836,20 @@ It would be fine to add to each item, in which version was it changed.
 \begin_layout Itemize
 short is now equivalent to int (16 bits), it used to be equivalent to char
  (8 bits) which is not ANSI compliant.
- To maintain compatibility, old programs may be compiled using the --short-is-8b
-its commandline option (see 
+ To maintain compatibility, old programs may be compiled using the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-short-is-8bits commandline option (see 
 \begin_inset LatexCommand \vref{lyx:--short-is-8bits}
 
 \end_inset
@@ -856,7 +868,51 @@ char type parameters to vararg
 
 \end_inset
 
- functions are casted to int unless explicitly casted
+ functions are casted to int unless explicitly casted and 
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c89
+\begin_inset LatexCommand \index{-\/-std-c89}
+
+\end_inset
+
+\series default
+and
+\series bold
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c99
+\begin_inset LatexCommand \index{-\/-std-c99}
+
+\end_inset
+
+
+\series default
+ command line option are not defined 
 \begin_inset Marginal
 status collapsed
 
@@ -885,7 +941,97 @@ n", a, (char)a);
 \family default
 
 \newline
- will push a as an int and as a char resp.
+ will push a as an int and as a char resp if
+\series bold
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c89
+\begin_inset LatexCommand \index{-\/-std-c89}
+
+\end_inset
+
+\series default
+and
+\series bold
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c99
+\begin_inset LatexCommand \index{-\/-std-c99}
+
+\end_inset
+
+
+\series default
+ command line options are not defined,
+\newline
+ will push a as two ints if
+\series bold
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c89
+\begin_inset LatexCommand \index{-\/-std-c89}
+
+\end_inset
+
+\series default
+or
+\series bold
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c99
+\begin_inset LatexCommand \index{-\/-std-c99}
+
+\end_inset
+
+
+\series default
+ command line option is defined.
 \end_layout
 
 \begin_layout Itemize
@@ -1012,10 +1158,109 @@ b = !b; /* toggles b */
 In previous versions, both forms would have toggled the bit.
 \end_layout
 
-\begin_layout Standard
+\begin_layout Itemize
+in older versions, the preprocessor was always called with -std=c99 regardless
+ of the --std-xxx setting.
+ This is no longer true, and can cause compilation failures on code built
+ with --std-c89 but using c99 preprocessor features, such as one-line (//)
+ comments
+\end_layout
 
-\emph on
-<pending: more incompatibilities?>
+\begin_layout Itemize
+in versions older then 2.8.4 the pic16 *printf() and printf_tiny() library
+ functions supported undocumented and not standard compliant 'b' binary
+ format specifier ("%b", "%hb" and "%lb").
+ The 'b' specifier is now disabled by default.
+ It can be enabled by defining BINARY_SPECIFIER macro in files device/lib/pic16/
+libc/stdio/vfprintf.c and device/lib/pic16/libc/stdio/printf_tiny.c and recompilin
+g the library.
+\end_layout
+
+\begin_layout Itemize
+in versions older then 2.8.5 the unnamed bitfield structure members participated
+ in initialization, which is not conforming with ISO/IEC 9899:1999 standard
+ (see section Section 6.7.8 Initialization, clause 9)
+\newline
+
+\newline
+Old behavior, before
+ version 2.8.5:
+\family typewriter
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+struct {
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+int a : 2;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+char\InsetSpace ~
+ : 2;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+int b : 2;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+} s = {1, 2, 3};
+\family default
+
+\newline
+
+\family typewriter
+/* s.a = 1, s.b = 3 */
+\family default
+
+\newline
+
+\newline
+New behavior:
+\family typewriter
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+struct {
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+int a : 2;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+char\InsetSpace ~
+ : 2;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+int b : 2;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+} s = {1, 2};
+\family default
+
+\newline
+
+\family typewriter
+/* s.a = 1, s.b = 2 */
 \end_layout
 
 \begin_layout Section
@@ -1404,7 +1649,25 @@ status collapsed
 
 \end_inset
 
--disable-pic-port Excludes the PIC port
+-disable-pic-port Excludes the PIC14 port
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-disable-pic16-port Excludes the PIC16 port
 \end_layout
 
 \begin_layout List
@@ -1518,6 +1781,24 @@ status collapsed
  Lower runtime footprint.
 \end_layout
 
+\begin_layout List
+\labelwidthstring 00.00.0000
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-without-ccache Do not use ccache even if available
+\end_layout
+
 \begin_layout Standard
 Furthermore the environment variables CC, CFLAGS, ...
  the tools and their arguments can be influenced.
@@ -1534,14 +1815,14 @@ status collapsed
 
 \end_inset
 
--help` and the man/info pages of `configure` for details.
+-help' and the man/info pages of `configure' for details.
 \newline
 
 \newline
 The names of the
  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
- SDCC_LIB_NAME are defined by `configure` too.
+ SDCC_LIB_NAME are defined by `configure' too.
  At the moment it's not possible to change the default settings (it was
  simply never required).
 \newline
@@ -2811,7 +3092,7 @@ model
 
 \begin_layout Standard
 \noindent
-The install paths can still be changed during `make install` with e.g.:
+The install paths can still be changed during `make install' with e.g.:
 \end_layout
 
 \begin_layout LyX-Code
@@ -3941,6 +4222,36 @@ On Mac OS X 10.2.x it was reported, that the
 ./configure CC=gcc2 CXX=g++2
 \end_layout
 
+\begin_layout Standard
+Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
+ Xcode.
+ Run 'configure' with:
+\end_layout
+
+\begin_layout LyX-Code
+./configure 
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
+ ppc" 
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
+ ppc" 
+\backslash
+
+\end_layout
+
+\begin_layout LyX-Code
+CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
+\end_layout
+
 \begin_layout Subsection
 Cross compiling SDCC on Linux for Windows
 \end_layout
@@ -4611,8 +4922,8 @@ This is not only usefull for building different binaries, e.g.
  generated files are not scattered between the source files.
  And the best thing is: if you want to change a file you can leave the original
  file untouched in the source directory.
- Simply copy it to the build directory, edit it, enter `make clean`, `rm
- Makefile.dep` and `make`.
+ Simply copy it to the build directory, edit it, enter `make clean', `rm
+ Makefile.dep' and `make'.
  
 \series bold
 make
@@ -6249,6 +6560,28 @@ sdcclib libint.lib _moduint.rel
 \family sans
 \series bold
 sdcclib libint.lib _mulint.rel
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Or, if you preffer:
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
+\family default
 \series default
 
 \newline
@@ -6257,7 +6590,110 @@ sdcclib libint.lib _mulint.rel
 
 \begin_layout Standard
 If the file already exists in the library, it will be replaced.
- To see what modules and symbols are included in the library, options -s
+ If a list of .rel files is available, you can tell sdcclib to add those
+ files to a library.
+ For example, if the file 'myliblist.txt' contains
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_divsint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_divuint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_modsint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_moduint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_mulint.rel
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Use
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib -l libint.lib myliblist.txt
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Additionally, you can instruct sdcclib to compiles the files before adding
+ them to the library.
+ This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
+ For example:
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+set SDCCLIB_CC=sdcc -c
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib -l libint.lib myliblist.txt
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+To see what modules and symbols are included in the library, options -s
  and -m are available.
  For example:
 \newline
@@ -7709,6 +8145,11 @@ linkOption[,linkOption]
 
 \end_inset
 
+
+\begin_inset LatexCommand \label{lyx:-Wl option}
+
+\end_inset
+
 ...
  Pass the linkOption to the linker.
  If a bootloader is used an option like 
@@ -7721,6 +8162,8 @@ linkOption[,linkOption]
 \end_inset
 
  would be typical to set the start of the code segment.
+ Either use the double quotes around this option or use no space (e.g.
+ -Wl-bCSEG=0x1000).
  See also #pragma constseg and #pragma codeseg in section 
 \begin_inset LatexCommand \ref{sec:Pragmas}
 
@@ -8060,6 +8503,38 @@ status collapsed
  Causes the linker to use old style for allocating memory areas.
 \end_layout
 
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-acall-ajmp
+\series default
+\InsetSpace ~
+
+\begin_inset LatexCommand \index{-\/-acall-ajmp}
+
+\end_inset
+
+ Replaces the three byte instructions lcall/ljmp with the two byte instructions
+ acall/ajmp.
+ Only use this option if your code is in the same 2k block of memory.
+ You may need to use this option for some 8051 derivatives which lack the
+ lcall/ljmp instructions..
+\end_layout
+
 \begin_layout Standard
 \begin_inset VSpace bigskip
 \end_inset
@@ -8265,7 +8740,20 @@ status collapsed
 \labelwidthstring 00.00.0000
 
 \series bold
---stack-8-bit - switches off the 10-bit mode
+-
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-8-bit - switches off the 10-bit mode
 \end_layout
 
 \end_inset
@@ -8306,7 +8794,7 @@ status collapsed
 \series bold
 -
 \begin_inset ERT
-status collapsed
+status open
 
 \begin_layout Standard
 
@@ -8606,6 +9094,34 @@ Force a called function to always save BC.
 \begin_layout List
 \labelwidthstring 00.00.0000
 
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-std-crt0
+\series default
+
+\begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
+
+\end_inset
+
+ When linking, skip the standard crt0.o object file.
+ You must provide your own crt0.o for your system when linking.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
 \series bold
 -bo
 \series default
@@ -9404,7 +9920,41 @@ reentrant
  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.
+ It automatically implies -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-int-long-reent and -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-float-reent.
  
 \end_layout
 
@@ -9749,7 +10299,24 @@ status collapsed
  unsigned
 \family default
 .
- To set the signess for characters to unsigned, use the option --funsigned-char.
+ To set the signess for characters to unsigned, use the option -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-funsigned-char.
  If this option is set and no signedness keyword (unsigned/signed) is given,
  a char will be signed.
  All other types are unaffected.
@@ -9977,8 +10544,24 @@ status collapsed
 
 
 \series default
- Don't include peep-hole comments in the generated asm files even if --fverbose-
-asm option is specified.
+ Don't include peep-hole comments in the generated asm files even if -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-fverbose-asm option is specified.
 \end_layout
 
 \begin_layout List
@@ -10096,6 +10679,33 @@ status collapsed
 \begin_layout Standard
 
 
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-Werror
+\begin_inset LatexCommand \index{-\/-Werror}
+
+\end_inset
+
+
+\series default
+ Treat all warnings as errors.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
 \backslash
 /
 \end_layout
@@ -10342,6 +10952,11 @@ status collapsed
 
 \end_inset
 
+
+\begin_inset LatexCommand \label{lyx:-codeseg}
+
+\end_inset
+
 \InsetSpace ~
 <Name> The name to be used for the code
 \begin_inset LatexCommand \index{code}
@@ -10696,7 +11311,7 @@ status collapsed
 
 
 \series default
- Will create a dump of iCode's, after global subexpression elimination
+ Will create a dump of iCodes, after global subexpression elimination
 \begin_inset LatexCommand \index{Global subexpression elimination}
 
 \end_inset
@@ -10730,7 +11345,7 @@ status collapsed
 
 
 \series default
- Will create a dump of iCode's, after deadcode elimination
+ Will create a dump of iCodes, after deadcode elimination
 \begin_inset LatexCommand \index{Dead-code elimination}
 
 \end_inset
@@ -10767,7 +11382,7 @@ status collapsed
 \size large
  
 \size default
-Will create a dump of iCode's, after loop optimizations
+Will create a dump of iCodes, after loop optimizations
 \begin_inset LatexCommand \index{Loop optimization}
 
 \end_inset
@@ -10804,7 +11419,7 @@ status collapsed
 \size large
  
 \size default
-Will create a dump of iCode's, after live range analysis
+Will create a dump of iCodes, after live range analysis
 \begin_inset LatexCommand \index{Live range analysis}
 
 \end_inset
@@ -10873,7 +11488,7 @@ status collapsed
  
 \series default
 \bar default
-Will create a dump of iCode's, after register assignment
+Will create a dump of iCodes, after register assignment
 \begin_inset LatexCommand \index{Register assignment}
 
 \end_inset
@@ -10954,7 +11569,7 @@ Redirecting output on Windows Shells
 \end_layout
 
 \begin_layout Standard
-By default SDCC writes it's error messages to 
+By default SDCC writes its error messages to 
 \begin_inset Quotes sld
 \end_inset
 
@@ -12717,6 +13332,31 @@ The xdata storage class declares a variable that can reside anywhere in
 \end_inset
 
 
+\end_layout
+
+\begin_layout Section
+Other SDCC language extensions
+\begin_inset LatexCommand \index{Other SDCC language extensions}
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Binary constants
+\end_layout
+
+\begin_layout Standard
+SDCC supports the use of binary constants, such as 0b01100010.
+ This feature is only enabled when the compiler is invoked using --std-sdccxx.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
 \end_layout
 
 \begin_layout Section
@@ -15114,7 +15754,24 @@ The compiler triggers the linker to link certain initialization modules
 
  called crt<something>.
  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
- GSINIT5) is not linked unless the --xstack option is used.
+ GSINIT5) is not linked unless the -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-xstack option is used.
  These modules are highly entangled by the use of special segments/areas,
  but a common layout is shown below:
 \end_layout
@@ -15614,6 +16271,17 @@ mov a,r0
 \InsetSpace ~
 \InsetSpace ~
 \InsetSpace ~
+orl a,#(l_PSEG
+ >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
 jz 00006$
 \newline
 \InsetSpace ~
@@ -15624,8 +16292,7 @@ jz 00006$
 \InsetSpace ~
 \InsetSpace ~
 \InsetSpace ~
-mov
- r1,#s_PSEG
+mov r1,#s_PSEG
 \newline
 \InsetSpace ~
 \InsetSpace ~
@@ -15648,7 +16315,8 @@ mov __XPAGE,#(s_PSEG >> 8)
 clr a
 \newline
 00005$:\InsetSpace ~
-movx @r1,a
+movx
+ @r1,a
 \newline
 \InsetSpace ~
 \InsetSpace ~
@@ -15670,8 +16338,7 @@ inc r1
 \InsetSpace ~
 djnz r0,00005$
 \newline
-0
-0006$:
+00006$:
 \newline
 \InsetSpace ~
 \InsetSpace ~
@@ -15701,7 +16368,8 @@ mov a,r0
 \InsetSpace ~
 \InsetSpace ~
 \InsetSpace ~
-orl a,#(l_XSEG >> 8)
+orl a,#(l_XSEG >>
+ 8)
 \newline
 \InsetSpace ~
 \InsetSpace ~
@@ -15721,8 +16389,7 @@ jz 00008$
 \InsetSpace ~
 \InsetSpace ~
 \InsetSpace ~
-mov r1,#((l_XSEG
- + 255) >> 8)
+mov r1,#((l_XSEG + 255) >> 8)
 \newline
 \InsetSpace ~
 \InsetSpace ~
@@ -15745,7 +16412,8 @@ mov dptr,#s_XSEG
 clr a
 \newline
 00007$:\InsetSpace ~
-movx @dptr,a
+movx
+ @dptr,a
 \newline
 \InsetSpace ~
 \InsetSpace ~
@@ -15775,8 +16443,7 @@ djnz r0,00007$
 \InsetSpace ~
 \InsetSpace ~
 \InsetSpace ~
-djnz
- r1,00007$
+djnz r1,00007$
 \newline
 00008$:
 \end_layout
@@ -16069,6 +16736,75 @@ status collapsed
 \end_inset
 
  about MCS51-variants.
+\newline
+
+\end_layout
+
+\begin_layout Standard
+While these initialization modules are meant as generic startup code there
+ might be the need for customization.
+ Let's assume the return value of 
+\emph on
+_sdcc_external_startup()
+\emph default
+ in 
+\emph on
+crtstart.asm
+\emph default
+ should not be checked (or 
+\emph on
+_sdcc_external_startup()
+\emph default
+ should not be called at all).
+ The recommended way would be to copy 
+\emph on
+crtstart.asm
+\emph default
+ (f.e.
+ from 
+\begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
+
+\end_inset
+
+) into the source directory, adapt it there, then assemble it with 
+\emph on
+asx8051 -plosgff
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+\begin_inset Quotes sld
+\end_inset
+
+-plosgff
+\begin_inset Quotes srd
+\end_inset
+
+ are the assembler options used in 
+\begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+ crtstart.asm
+\emph default
+ and when linking your project explicitely specify 
+\emph on
+crtstart.rel
+\emph default
+.
+ As a bonus a listing of the relocated object file 
+\emph on
+crtstart.rst
+\emph default
+ is generated.
+\end_layout
+
+\begin_layout Standard
 \begin_inset VSpace bigskip
 \end_inset
 
@@ -21368,7 +22104,7 @@ less_pedantic
 
 \end_inset
 
-- the compiler will not warn you anymore for obvious mistakes, you'r on
+- the compiler will not warn you anymore for obvious mistakes, you're on
  your own now ;-( .
  See also the command line option -
 \begin_inset ERT
@@ -22133,7 +22869,7 @@ int foo ()
 
 \begin_layout Standard
 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
+ It is strongly recommended that the save and restore pragmas be used when
  changing options for a function.
 \newline
 
@@ -22165,7 +22901,7 @@ The compiler creates the following #defines
 
 \begin_layout Standard
 \begin_inset Tabular
-<lyxtabular version="3" rows="11" columns="2">
+<lyxtabular version="3" rows="15" columns="2">
 <features>
 <column alignment="left" valignment="top" leftline="true" width="3in">
 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
@@ -22535,7 +23271,7 @@ when
 \end_inset
 </cell>
 </row>
-<row topline="true" bottomline="true">
+<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
@@ -22561,6 +23297,158 @@ when
  is used
 \end_layout
 
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCC_REVISION
+\begin_inset LatexCommand \index{SDCC\_REVISION}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Always defined.
+ SDCC svn revision number
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCC_PARMS_IN_BANK1
+\begin_inset LatexCommand \index{SDCC\_PARMS\_IN\_BANK1}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+when 
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-parms-in-bank1
+\emph default
+ is used
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCC_FLOAT_REENT
+\begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+when 
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-float-reent
+\emph default
+ is used
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCC_INT_LONG_REENT
+\begin_inset LatexCommand \index{SDCC\_INT\_LONG\_REENT}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+when 
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-int-long-reent
+\emph default
+ is used
+\end_layout
+
 \end_inset
 </cell>
 </row>
@@ -22701,6 +23589,281 @@ Some MCS51 variants offer features like Double DPTR
  These are currently not used for the MCS51 port.
  If you absolutely need them you can fall back to inline assembly or submit
  a patch to SDCC.
+\end_layout
+
+\begin_layout Subsection
+Bankswitching
+\end_layout
+
+\begin_layout Standard
+Bankswitching
+\begin_inset LatexCommand \index{Bankswitching}
+
+\end_inset
+
+ (a.k.a.
+ code banking
+\begin_inset LatexCommand \index{code banking}
+
+\end_inset
+
+) is a technique to increase the code space above the 64k limit of the 8051.
+\end_layout
+
+\begin_layout Subsubsection
+Hardware
+\end_layout
+
+\begin_layout Standard
+\begin_inset Tabular
+<lyxtabular version="3" rows="3" columns="4">
+<features>
+<column alignment="center" valignment="top" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell multicolumn="1" alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+8000-FFFF
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+bank1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+bank2
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+bank3
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell multicolumn="1" alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0000-7FFF
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+common
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="1" alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell multicolumn="1" alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SiLabs C8051F120 example
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="2" alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\newline
+
+\newline
+Usually the hardware uses some sfr (an output port or an internal sfr) to
+ select a bank and put it in the banked area of the memory map.
+ The selected bank usually becomes active immediately upon assignment to
+ this sfr and when running inside a bank it will switch out this code it
+ is currently running.
+ Therefor you cannot jump or call directly from one bank to another and
+ need to use a so-called trampoline in the common area.
+ For SDCC an example trampoline is in crtbank.asm and you may need to change
+ it to your 8051 derivative or schematic.
+ The presented code is written for the C8051F120.
+\newline
+
+\newline
+When calling a banked function
+ SDCC will put the LSB of the functions address in register R0, the MSB
+ in R1 and the bank in R2 and then call this trampoline 
+\emph on
+__sdcc_banked_call
+\emph default
+.
+ The current selected bank is saved on the stack, the new bank is selected
+ and an indirect jump is made.
+ When the banked function returns it jumps to 
+\emph on
+__sdcc_banked_ret
+\emph default
+ which restores the previous bank and returns to the caller.
+\end_layout
+
+\begin_layout Subsubsection
+Software
+\end_layout
+
+\begin_layout Standard
+When writing banked software using SDCC you need to use some special keywords
+ and options.
+ You also need to take over a bit of work from the linker.
+\newline
+
+\newline
+To create a function
+ that can be called from another bank it requires the keyword 
+\emph on
+banked
+\emph default
+
+\begin_inset LatexCommand \index{banked}
+
+\end_inset
+
+.
+ The caller must see this in the prototype of the callee and the callee
+ needs it for a proper return.
+ Called functions within the same bank as the caller do not need the 
+\emph on
+banked
+\emph default
+ keyword nor do functions in the common area.
+ Beware: SDCC does not know or check if functions are in the same bank.
+ This is your responsibility!
+\newline
+
+\newline
+Normally all functions you write end up in
+ the segment CSEG.
+ If you want a function explicitly to reside in the common area put it in
+ segment HOME.
+ This applies for instance to interrupt service routines as they should
+ not be banked.
+\end_layout
+
+\begin_layout Standard
+Functions that need to be in a switched bank must be put in a named segment.
+ The name can be mostly anything upto eight characters (e.g.
+ BANK1).
+ To do this you either use -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-codeseg BANK1 (See 
+\begin_inset LatexCommand \ref{lyx:-codeseg}
+
+\end_inset
+
+) on the command line when compiling or #pragma codeseg BANK1 (See 
+\begin_inset LatexCommand \ref{sec:Pragmas}
+
+\end_inset
+
+) at the top of the C source file.
+ The segment name always applies to the whole source file and generated
+ object so functions for different banks need to be defined in different
+ source files.
+\newline
+
+\newline
+When linking your objects you need to tell the linker where
+ to put your segments.
+ To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
+00 (See 
+\begin_inset LatexCommand \ref{lyx:-Wl option}
+
+\end_inset
+
+).
+ This sets the virtual start address of this segment.
+ It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
+ The linker will not check for overflows, again this is your responsibility.
+\end_layout
+
+\begin_layout Standard
 \begin_inset VSpace bigskip
 \end_inset
 
@@ -22832,39 +23995,43 @@ The HC08 port passes the regression test suite (see section
 \end_inset
 
 
-\newpage
-
 \end_layout
 
 \begin_layout Section
-The PIC14 port
-\end_layout
+The PIC14
+\begin_inset LatexCommand \index{PIC14}
 
-\begin_layout Standard
-The PIC14 port adds support for Microchip(TM)'s 14
-\begin_inset ERT
-status open
+\end_inset
+
+ port
+\end_layout
 
 \begin_layout Standard
+The PIC14 port adds support for Microchip
+\begin_inset LatexCommand \index{Microchip}
 
+\end_inset
 
-\backslash
-,
-\end_layout
 
+\begin_inset Formula $^{\text{TM}}$
 \end_inset
 
-bit PIC
+ PIC
 \begin_inset LatexCommand \index{PIC14}
 
 \end_inset
 
- MCUs.
+
+\begin_inset Formula $^{\text{TM}}$
+\end_inset
+
+ MCUs with 14 bit wide instructions.
  This port is not yet mature and still lacks many features.
  However, it can work for simple code.
 \end_layout
 
 \begin_layout Standard
+\noindent
 Currently supported devices include:
 \end_layout
 
@@ -22894,24 +24061,33 @@ Currently supported devices include:
 \end_layout
 
 \begin_layout Standard
-16F: 627, 627a, 628, 628a, 630, 636, 639, 648a, 676, 684, 685, 687, 688,
- 689, 690
+16CR: 620a, 73, 74, 76, 77
 \end_layout
 
 \begin_layout Standard
-16F: 716, 72, 73, 737, 74, 76, 767, 77, 777, 785
+16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
+ 687, 688, 689, 690
+\end_layout
+
+\begin_layout Standard
+16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
 \end_layout
 
 \begin_layout Standard
 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
- 877, 877a, 88
+ 877, 877a, 88, 886, 887
 \end_layout
 
 \begin_layout Standard
-16F: 913, 914, 916, 917
+16F: 913, 914, 916, 917, 946
 \end_layout
 
 \begin_layout Standard
+26HV: 626, 785
+\end_layout
+
+\begin_layout Standard
+\noindent
 An up-to-date list of currently supported devices can be obtained via 
 \family typewriter
 sdcc -mpic14 -phelp foo.c
@@ -22972,7 +24148,7 @@ For devices that have multiple code pages it is more efficient to use the
 
 \begin_layout Enumerate
 And as for any 8 bit micro (especially for PIC14 as they have a very simple
- instruction set), use 'unsigned char' wherever possible instead of 'int'.
+ instruction set), use `unsigned char' wherever possible instead of `int'.
 \end_layout
 
 \begin_layout Subsection
@@ -23045,7 +24221,7 @@ Interrupt Code
 \end_layout
 
 \begin_layout Standard
-For the interrupt function, use the keyword '__interrupt'
+For the interrupt function, use the keyword `__interrupt'
 \begin_inset LatexCommand \index{PIC14!interrupt}
 
 \end_inset
@@ -23329,15 +24505,7 @@ device/lib
 \end_layout
 
 \begin_layout Subsubsection
-error: missing definition for symbol 
-\begin_inset Quotes sld
-\end_inset
-
-__gptrget1
-\begin_inset Quotes srd
-\end_inset
-
-
+error: missing definition for symbol ``__gptrget1''
 \end_layout
 
 \begin_layout Standard
@@ -23360,15 +24528,7 @@ libsdcc.lib
 \end_layout
 
 \begin_layout Subsubsection
-Processor mismatch in file 
-\begin_inset Quotes sld
-\end_inset
-
-XXX
-\begin_inset Quotes srd
-\end_inset
-
-.
+Processor mismatch in file ``XXX''.
 \end_layout
 
 \begin_layout Standard
@@ -23419,7 +24579,7 @@ Function arguments
 
 \begin_layout Standard
 Functions with variable argument lists (like printf) are not yet supported.
- Similarly, taking the argument of the first argument passed into a function
+ Similarly, taking the address of the first argument passed into a function
  does not work: It is currently passed in WREG and has no address...
 \end_layout
 
@@ -23452,20 +24612,27 @@ The PIC16
 \end_layout
 
 \begin_layout Standard
-The PIC16
-\begin_inset LatexCommand \index{PIC16}
+The PIC16 port adds support for Microchip
+\begin_inset LatexCommand \index{Microchip}
 
 \end_inset
 
- port is the portion of SDCC that is responsible to produce code for the
- Microchip
-\begin_inset LatexCommand \index{Microchip}
 
+\begin_inset Formula $^{\text{TM}}$
 \end_inset
 
-(TM) microcontrollers with 16 bit core.
- Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx.
- Currently supported devices are:
+ PIC
+\begin_inset LatexCommand \index{PIC}
+
+\end_inset
+
+
+\begin_inset Formula $^{\text{TM}}$
+\end_inset
+
+ MCUs with 16 bit wide instructions.
+ Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
+; devices supported by the port include:
 \end_layout
 
 \begin_layout Standard
@@ -23477,19 +24644,44 @@ The PIC16
 \end_layout
 
 \begin_layout Standard
-18F: 2220, 2221, 2320, 2321, 2331, 2431, 2455, 2525, 2550, 2620
+18F: 2220, 2221, 2320, 2321, 2331, 2410, 2420, 2423, 2431, 2450, 2455, 2480,
+ 24j10
+\end_layout
+
+\begin_layout Standard
+18F: (2510,) 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 2610, 2620,
+ 2680, 2682, 2685
 \end_layout
 
 \begin_layout Standard
-18F: 4220, 4221, 4320, 4321, 4331, 4431, 4455, 4520, 4525, 4550, 4620
+18F: 4220, 4221, 4320, 4321, 4331, 4410, 4420, 4423, 4431, 4450, 4455, 4480,
+ 44j10
 \end_layout
 
 \begin_layout Standard
-18F: 6520, 6620, 6680, 6720
+18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 4610, 4620,
+ 4680, 4682, 4685
 \end_layout
 
 \begin_layout Standard
-18F: 8520, 8620, 8680, 8720
+18F: 6520, 6585, 6620, 6680, 66j60, 66j65, 6720, 67j60
+\end_layout
+
+\begin_layout Standard
+18F: 8520, 8585, 8620, 8680, 86j60, 86j65, 8720, 87j60
+\end_layout
+
+\begin_layout Standard
+18F: 96j60, 96j65, 97j60
+\end_layout
+
+\begin_layout Standard
+\noindent
+An up-to-date list of supported devices is also available via '
+\family typewriter
+sdcc -mpic16 -plist
+\family default
+'.
 \end_layout
 
 \begin_layout Subsection
@@ -23750,7 +24942,7 @@ status collapsed
 
 \end_inset
 
--optimize-goto Try to use (conditional) BRA instead of GOTO.
+-no-optimize-goto Do not use (conditional) BRA instead of GOTO.
 \end_layout
 
 \begin_layout Description
@@ -24272,6 +25464,7 @@ nnn = SMALL or LARGE respectively according to the stack model used
 \end_layout
 
 \begin_layout Standard
+\noindent
 In addition the following macros are defined when calling assembler:
 \end_layout
 
@@ -24880,6 +26073,7 @@ libdebug
 \end_layout
 
 \begin_layout Standard
+\noindent
 This feature allows for linking with specific libraries withoug having to
  explicit name them in the command line.
  Note that the 
@@ -25077,6 +26271,11 @@ The specific microcontroller is selected within the pic18fregs.h automatically,
 
 \begin_layout Subsection
 Libraries
+\begin_inset LatexCommand \label{sub:pic16Libraries}
+
+\end_inset
+
+
 \end_layout
 
 \begin_layout Standard
@@ -25102,6 +26301,7 @@ xxxx
 \end_layout
 
 \begin_layout Standard
+\noindent
 Libraries are created with gplib which is part of the gputils package 
 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
 
@@ -25116,13 +26316,11 @@ Building the libraries
 
 \begin_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.
-\end_layout
-
-\begin_layout Standard
-The steps to compile the pic16 libraries under Linux and Mac OS X are:
+ This process is done automatically if gputils are found at SDCC's compile
+ time.
+ Should you require to rebuild the pic16 libraries manually, these are the
+ steps required to do so under Linux or Mac OS X (cygwin might work as well,
+ but is untested):
 \end_layout
 
 \begin_layout LyX-Code
@@ -25130,11 +26328,7 @@ cd device/lib/pic16
 \end_layout
 
 \begin_layout LyX-Code
-./configure
-\end_layout
-
-\begin_layout LyX-Code
-make
+./configure.gnu
 \end_layout
 
 \begin_layout LyX-Code
@@ -25149,6 +26343,10 @@ make model-pic16
 su -c 'make install'     # install the libraries, you need the root password
 \end_layout
 
+\begin_layout LyX-Code
+cd ../..
+\end_layout
+
 \begin_layout Standard
 If you need to install the headers too, do:
 \end_layout
@@ -25161,26 +26359,6 @@ cd device/include
 su -c 'make install'     # install the headers, you need the root password
 \end_layout
 
-\begin_layout Standard
-There exist a special target to build the I/O libraries.
- This target is not automatically build because it will build the I/O library
- for 
-\emph on
-every
-\emph default
- supported device.
- This way building will take quite a lot of time.
- Users are advised to edit the 
-\series bold
-device/lib/pic16/pics.build
-\series default
- file and then execute:
-\end_layout
-
-\begin_layout LyX-Code
-make lib-io
-\end_layout
-
 \begin_layout Subsection
 Adding New Devices to the Port
 \end_layout
@@ -25188,7 +26366,7 @@ Adding New Devices to the Port
 \begin_layout Standard
 Adding support for a new 16
 \begin_inset ERT
-status open
+status collapsed
 
 \begin_layout Standard
 
@@ -25226,37 +26404,28 @@ mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
 \begin_layout Enumerate
 Add DEVICE to 
 \family typewriter
-/path/to/sdcc/device/lib/pics.all
+/path/to/sdcc/device/lib/pic16/pics.all
 \family default
- (and 
-\family typewriter
-.build
-\family default
-).
+
 \newline
 Note: No 18f prefix here!
 \end_layout
 
 \begin_layout Enumerate
-Adjus
+Edi
 \family typewriter
-/path/to/sdcc/device/lib/pic16/libio/*.ignore
-\family default
-
+/path/to/sdcc/device/include/pic16/adc.h
 \newline
-Add your DEVICE if it does not compile in 
-\family typewriter
-adc
-\family default
-, 
-\family typewriter
-i2c
+
 \family default
-, or 
+Add the new devices to the correct ADC style class (depending on the number
+ of ADC channels).
+\newline
+Do not touch 
 \family typewriter
-usart
+adc.h
 \family default
-.
+ if the device does not offer any ADC at all.
 \end_layout
 
 \begin_layout Enumerate
@@ -25264,33 +26433,118 @@ Edit
 \family typewriter
 /path/to/sdcc/device/include/pic16/pic18fregs.h
 \family default
-.
- The file format is self-explanatory, just add
+
+\newline
+The file format is self-explanatory, just add
 \newline
 
 \family typewriter
 #elif defined(picDEVICE)
 \newline
-# include <picDEVICE.h>
+#
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+\backslash
+\end_layout
+
+\end_inset
+
+include <picDEVICE.h>
 \family default
 
 \newline
-at the right place (keep it sorted).
+at the right place (keep the file sorted, please).
 \end_layout
 
 \begin_layout Enumerate
 Edit 
 \family typewriter
-/path/to/sdcc/src/pic16/devices.inc
+/path/to/sdcc/device/include/pic16devices.txt
+\newline
+
+\family default
+Copy and modify an existing entry or create a new one and insert it at the
+ correct place (keep the file sorted, please).
+\end_layout
+
+\begin_layout Enumerate
+Add the device to 
+\family typewriter
+/path/to/sdcc/device/lib/pic16/libdev/Makefile.am
+\family default
+
+\newline
+Copy an existing entry and adjust the device name.
+\end_layout
+
+\begin_layout Enumerate
+Add the device to 
+\family typewriter
+/path/to/sdcc/device/lib/pic16/libio/Makefile.am
+\family default
+
+\newline
+Copy the record from the 18f2220 and adjust the device name.
+\newline
+If the new device
+ does not offer ADC, I
+\begin_inset Formula $^{\text{2}}$
+\end_inset
+
+C, and/or (E)USART functionality as assumed by the library, remove the lines
+ with references to 
+\family typewriter
+adc/*.c
+\family default
+, 
+\family typewriter
+usart/*.c
+\family default
+, or 
+\family typewriter
+usart/*.c
+\family default
+, respectively.
+\end_layout
+
+\begin_layout Enumerate
+Update 
+\family typewriter
+libdev/Makefile.in
+\family default
+ and 
+\family typewriter
+libio/Makefile.in
+\family default
+ using
+\newline
+
+\family typewriter
+./bootstrap.sh
+\family default
+
+\newline
+in 
+\family typewriter
+/path/to/sdcc/device/lib/pic16
 \family default
 .
- Copy and modify an existing entry and insert it at the correct place (keep
- the file sorted).
- The file is hardly documented, look at the entries for the 18f2221...
 \end_layout
 
 \begin_layout Enumerate
-Recompile SDCC, including the pic16 libraries.
+Recompile the pic16 libraries as described in 
+\begin_inset LatexCommand \ref{sub:pic16Libraries}
+
+\end_inset
+
+.
 \end_layout
 
 \begin_layout Subsection
@@ -25605,6 +26859,7 @@ Frame pointer FSR2
 \end_layout
 
 \begin_layout Standard
+\noindent
 
 \noun on
 Large 
@@ -26093,7 +27348,7 @@ not
  Address of the specific interrupt.
  This is not a problem for the LOW priority interrupts, but it is a problem
  for the RESET and the HIGH priority interrupts because code may be written
- at the next interrupt´s vector address and cause undeterminate program
+ at the next interrupt's vector address and cause undeterminate program
  behaviour if that interrupt is raised.
 \begin_inset Foot
 status open
@@ -26111,7 +27366,7 @@ disabled
 \end_layout
 
 \begin_layout Enumerate
-when the ISR is small enough not to reach the next interrupt´s vector address.
+when the ISR is small enough not to reach the next interrupt's vector address.
 \end_layout
 
 \end_inset
@@ -26124,7 +27379,7 @@ when the ISR is small enough not to reach the next interrupt
 \emph on
 n
 \emph default
is possible to be omitted.
may be omitted.
  This way a function is generated similar to an ISR, but it is not assigned
  to any interrupt.
 \end_layout
@@ -26454,6 +27709,7 @@ unimplemented pointer type
 \end_layout
 
 \begin_layout Standard
+\noindent
 Generic pointer are read and written with a set of library functions which
  read/write 1, 2, 3, 4 bytes.
 \end_layout
@@ -26502,6 +27758,7 @@ pointer.
 \end_layout
 
 \begin_layout Standard
+\noindent
 \align center
 \begin_inset Tabular
 <lyxtabular version="3" rows="2" columns="7">
@@ -26655,10 +27912,12 @@ upper byte high nubble is 0x2n, the rest are zeroes
 \end_layout
 
 \begin_layout Standard
+\noindent
 Currently implemented there are 3 types of streams defined:
 \end_layout
 
 \begin_layout Standard
+\noindent
 \align center
 \begin_inset Tabular
 <lyxtabular version="3" rows="4" columns="4">
@@ -26833,10 +28092,12 @@ Writes/Reads characters via used defined functions
 \end_layout
 
 \begin_layout Standard
+\noindent
 The stream identifiers are declared as macros in the stdio.h header.
 \end_layout
 
 \begin_layout Standard
+\noindent
 In the libc library there exist the functions that are used to write to
  each of the above streams.
  These are
@@ -27458,6 +28719,7 @@ TMR3 overflow interrupt
 \end_layout
 
 \begin_layout Standard
+\noindent
 The prototypes for these names are defined in the header file 
 \emph on
 signal.h
@@ -27466,6 +28728,7 @@ signal.h
 \end_layout
 
 \begin_layout Standard
+\noindent
 In order to simplify signal handling, a number of macros is provided:
 \end_layout
 
@@ -27675,8 +28938,35 @@ status collapsed
 Known Bugs
 \end_layout
 
+\begin_layout Subsubsection
+Extended Instruction Set
+\end_layout
+
 \begin_layout Standard
-The PIC16 Port currently does not pass SDCC's regression test
+The PIC16 port emits code which is incompatible with the extended instruction
+ set available with many newer devices.
+ Make sure to always explicitly disable it, usually using
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
+\end_layout
+
+\begin_layout Standard
+\noindent
+Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
+ instead of _XINST_OFF_4L.
+\end_layout
+
+\begin_layout Subsubsection
+Regression Tests
+\end_layout
+
+\begin_layout Standard
+The PIC16 port currently passes most but not all of the tests in SDCC's
+ regression test
 \begin_inset LatexCommand \index{Regression test (PIC16)}
 
 \end_inset
@@ -27686,10 +28976,8 @@ The PIC16 Port currently does not pass SDCC's regression test
 
 \end_inset
 
-) and thus the snapshot build regression tests for the PIC16 target are
- currently disabled for all hosts
-\emph on
-.
+), thus no automatic regression tests are currently performed for the PIC16
+ target.
 \end_layout
 
 \begin_layout Chapter
@@ -30711,11 +31999,11 @@ Related open source tools
 \begin_layout Standard
 \align left
 \begin_inset Tabular
-<lyxtabular version="3" rows="14" columns="3">
+<lyxtabular version="3" rows="16" columns="3">
 <features>
 <column alignment="left" valignment="top" leftline="true" width="0pt">
 <column alignment="block" valignment="top" leftline="true" width="30line%">
-<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
 <row topline="true" bottomline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
@@ -31222,6 +32510,111 @@ Debugger, serves nicely as GUI to SDCDB
 \end_inset
 
 
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+d52
+\begin_inset LatexCommand \index{d52}
+
+\end_inset
+
+
+\begin_inset LatexCommand \index{d52 (disassembler)}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Disassembler, can count instruction cycles
+\begin_inset LatexCommand \index{instruction cycles (count)}
+
+\end_inset
+
+, use with options -pnd
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+\begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+cmake
+\begin_inset LatexCommand \index{cmake}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Cross platform build system, generates Makefiles
+\begin_inset LatexCommand \index{Makefile}
+
+\end_inset
+
+ and project workspaces
+\begin_inset LatexCommand \index{project workspace}
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+\begin_inset LatexCommand \url{http://www.cmake.org}
+
+\end_inset
+
+ \InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+and a dedicated wiki entry: 
+\begin_inset LatexCommand \url{http://www.cmake.org/Wiki/CmakeSdcc}
+
+\end_inset
+
+
 \end_layout
 
 \end_inset
@@ -32248,7 +33641,24 @@ Subversion Source Code Repository
 The output of 
 \family sans
 \series bold
-sdcc --version
+sdcc -
+\family default
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\family sans
+-version
 \family default
 \series default
  or the filenames of the snapshot versions of SDCC include date and its
@@ -32305,18 +33715,18 @@ Historically there often were long delays between official releases and
 \end_inset
 
 .
A release wiki
The SDCC Wiki
 \begin_inset LatexCommand \index{wiki}
 
 \end_inset
 
 
-\begin_inset LatexCommand \index{Release wiki}
+\begin_inset LatexCommand \index{SDCC Wiki}
 
 \end_inset
 
  at 
-\begin_inset LatexCommand \url{http://sdcc.sf.net/release_wiki/}
+\begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
 
 \end_inset
 
@@ -32404,9 +33814,9 @@ regression tests
 \end_inset
 
  check that SDCC itself compiles flawlessly on several host platforms (i386,
- Opteron, 64 bit Alpha, ppc64, Mac OS 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.
+ Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, 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
@@ -35476,6 +36886,34 @@ replace { lcall %1 } by { acall %1 }
 replace { ljmp %1 } by { ajmp %1 }
 \end_layout
 
+\begin_layout Standard
+(NOTE: from version 2.7.3 on, you can use option -
+\emph on
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\emph default
+-acall-ajmp
+\begin_inset LatexCommand \index{-\/-acall-ajmp}
+
+\end_inset
+
+, which also takes care of aligning the interrupt vectors properly.)
+\newline
+
+\end_layout
+
 \begin_layout Standard
 The 
 \emph on
@@ -36036,7 +37474,11 @@ status collapsed
 
 \end_inset
 
- or -
+\series default
+or
+\series bold
+ -
 \begin_inset ERT
 status collapsed
 
@@ -36072,6 +37514,124 @@ t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
  '__data' instead of 'data'.
 \end_layout
 
+\begin_layout Itemize
+Integer promotion of variable arguments is not performed if the argument
+ is explicitly taypecasted unless the
+\series bold
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c89
+\begin_inset LatexCommand \index{-\/-std-c89}
+
+\end_inset
+
+\series default
+or
+\series bold
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c99
+\begin_inset LatexCommand \index{-\/-std-c99}
+
+\end_inset
+
+
+\series default
+ command line options are used.
+\end_layout
+
+\begin_deeper
+\begin_layout Verse
+
+\family typewriter
+void vararg_func (char *str, ...) { str; }
+\newline
+
+\newline
+void main (void)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+char c = 10;
+\newline
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+/* argument
+ u is promoted to int before
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+* passing to function */
+\newline
+\InsetSpace ~
+\InsetSpace ~
+vararg_func ("%c", c);
+\newline
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+/*
+ argument u is not promoted to int,
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+* it is passed as char to function
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+* if
+ --std-cXX is not defined;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+* is promoted to int before passing
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+* to function
+ if --std-cXX is defined */
+\newline
+\InsetSpace ~
+\InsetSpace ~
+vararg_func ("%bc", (char)u);
+\newline
+}
+\end_layout
+
+\end_deeper
 \begin_layout Section
 Cyclomatic Complexity
 \begin_inset LatexCommand \index{Cyclomatic complexity}
@@ -36230,13 +37790,13 @@ As mentioned in the optimization section the peep-hole optimizer is rule
 \end_layout
 
 \begin_layout Standard
-More information is available in a wiki
+More information is available on SDCC 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}
+\begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
 
 \end_inset
 
@@ -39723,7 +41283,7 @@ Acknowledgments
 \end_layout
 
 \begin_layout Standard
-\begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/#Who}
 
 \end_inset