* device/lib/mcs51/crtcall.asm: new, added for indirect calls
[fw/sdcc] / doc / sdccman.lyx
index 6aa3baa8e174dc0f03181e0175a2a143ccfc1d9c..2972e85fc97895efe16a89afbc8ec9eefb710431 100644 (file)
@@ -7,7 +7,7 @@
   pdftitle={SDCC Compiler User Guide},
   pdfauthor={SDCC development team},
   pdfsubject={installation, user manual},
-  pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390                 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
+  pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
   pdfpagemode=UseOutlines,
   colorlinks=true,
   linkcolor=blue] {hyperref}
 \papersides 1
 \paperpagestyle fancy
 
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 Please note: double dashed longoptions (e.g.
  --version) are written this way: -
@@ -59,22 +65,25 @@ status Collapsed
 \end_inset 
 
 -
-\layout Comment
+\layout Standard
 
 Two resp.
  three consecutive dashes simply result in a long resp.
  extra long dash.
-\layout Comment
+\layout Standard
 
 Architecture specific stuff (like memory models, code examples) should maybe
  later go
-\layout Comment
+\layout Standard
 
 into seperate sections/chapters/appendices (it is hard to document PIC or
  Z80 in 
-\layout Comment
+\layout Standard
 
 a 8051 centered document) - for now simply add.
+\end_inset 
+
+
 \layout Title
 
 SDCC Compiler User Guide
@@ -82,16 +91,25 @@ SDCC Compiler User Guide
 
 
 \size normal 
-SDCC 2.6.2
+SDCC 2.6.4
 \size footnotesize 
 
 \newline 
 $Date$ 
 \newline 
 $Revision$
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 The above strings enclosed in $ are automatically updated by Subversion
+\end_inset 
+
+
 \layout Standard
 
 
@@ -1059,6 +1077,20 @@ status Collapsed
 \end_inset 
 
 -datadir see table below
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-datarootdir see table below
 \newline 
 
 \layout List
@@ -1351,7 +1383,7 @@ These defaults are:
 \align center 
 
 \begin_inset  Tabular
-<lyxtabular version="3" rows="8" columns="3">
+<lyxtabular version="3" rows="9" columns="3">
 <features>
 <column alignment="block" valignment="top" leftline="true" width="0in">
 <column alignment="block" valignment="top" leftline="true" width="0in">
@@ -1462,7 +1494,7 @@ BINDIR
 
 
 \emph on 
-$EXECPREFIX
+$EXEC_PREFIX
 \emph default 
 /bin
 \end_inset 
@@ -1474,7 +1506,7 @@ $EXECPREFIX
 
 
 \emph on 
-$EXECPREFIX
+$EXEC_PREFIX
 \emph default 
 
 \backslash 
@@ -1499,6 +1531,38 @@ DATADIR
 \layout Standard
 
 
+\emph on 
+$DATAROOTDIR
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+$DATAROOTDIR
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+DATAROOTDIR
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
 \emph on 
 $PREFIX
 \emph default 
@@ -1534,7 +1598,7 @@ DOCDIR
 
 
 \emph on 
-$DATADIR
+$DATAROOTDIR
 \emph default 
 /sdcc/doc
 \end_inset 
@@ -1546,7 +1610,7 @@ $DATADIR
 
 
 \emph on 
-$DATADIR
+$DATAROOTDIR
 \emph default 
 
 \backslash 
@@ -1784,7 +1848,7 @@ status Collapsed
 /
 \end_inset 
 
--datadir=
+-datarootdir=
 \begin_inset Quotes srd
 \end_inset 
 
@@ -1901,7 +1965,7 @@ status Collapsed
 /
 \end_inset 
 
--datadir=
+-datarootdir=
 \begin_inset Quotes srd
 \end_inset 
 
@@ -1917,7 +1981,9 @@ docdir=
 \begin_inset Quotes srd
 \end_inset 
 
-/sdcc/doc
+
+\backslash 
+${datarootdir}/doc
 \begin_inset Quotes srd
 \end_inset 
 
@@ -2058,7 +2124,7 @@ status Collapsed
 /
 \end_inset 
 
--datadir=
+-datarootdir=
 \begin_inset Quotes srd
 \end_inset 
 
@@ -2074,7 +2140,9 @@ docdir=
 \begin_inset Quotes srd
 \end_inset 
 
-/sdcc/doc
+
+\backslash 
+${datarootdir}/doc
 \begin_inset Quotes srd
 \end_inset 
 
@@ -2164,7 +2232,7 @@ status Collapsed
  However if options are changed, it can be necessary to delete the config.cache
  file.
 \layout Section
-
+\added_space_bottom medskip 
 Install paths
 \begin_inset LatexCommand \label{sub:Install-paths}
 
@@ -2177,7 +2245,7 @@ Install paths
 
 
 \layout Standard
-\added_space_top medskip \align center 
+\align center 
 
 \begin_inset  Tabular
 <lyxtabular version="3" rows="5" columns="4">
@@ -3267,10 +3335,19 @@ lib/
 
 \newline 
 
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 Don't delete any of the stray spaces in the table above without checking
  the HTML output (last line)!
+\end_inset 
+
+
 \layout Standard
 
 \SpecialChar ~
@@ -5846,11 +5923,20 @@ Processor Selection Options
 \end_inset 
 
 .
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 I think it is fair to direct users there for now.
  Open source is also about avoiding unnecessary work .
  But I didn't find the 'official' link.
+\end_inset 
+
+
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -5870,9 +5956,18 @@ I think it is fair to direct users there for now.
 
 -bit processors (p16f84 and variants.
  In development, not complete).
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 p16f627 p16f628 p16f84 p16f873 p16f877?
+\end_inset 
+
+
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -6122,6 +6217,33 @@ file"'.
 Like `-dD' except that the macro arguments and contents are omitted.
  Only `#define name' is included in the output.
 \layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+-pedantic-parse-number
+\begin_inset LatexCommand \index{-pedantic-parse-number}
+
+\end_inset 
+
+
+\size large 
+\bar under 
+\series default 
+\size default 
+\bar default 
+Pedentic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
+ and the macro LO_B(3) gets expanded.
+ See also #pragma pedantic_parse_number in section
+\begin_inset LatexCommand \ref{sec:Pragmas}
+
+\end_inset 
+
+\emph on 
+Note: this functionality is not in conformance with standard!
+\layout List
 \added_space_bottom bigskip \labelwidthstring 00.00.0000
 
 
@@ -6164,7 +6286,7 @@ gcc
 \end_inset 
 
 ), if you need more dedicated options please refer to the GCC\SpecialChar ~
-3.3.6\SpecialChar ~
+4.1.1\SpecialChar ~
 CPP\SpecialChar ~
 Manual
  at 
@@ -8178,6 +8300,46 @@ status Collapsed
 \labelwidthstring 00.00.0000
 
 
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-funsigned-char
+\begin_inset LatexCommand \index{-\/-funsigned-char}
+
+\end_inset 
+
+
+\series default 
+ The default signedness for every type is
+\family typewriter 
+ signed
+\family default 
+.
+ In some embedded environments the default signedness of
+\family typewriter 
+ char
+\family default 
+ is
+\family typewriter 
+ unsigned
+\family default 
+.
+ To set the signess for characters to unsigned, use the option --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.
+\layout List
+\labelwidthstring 00.00.0000
+
+
 \series bold 
 -
 \begin_inset ERT
@@ -8696,6 +8858,29 @@ status Collapsed
  Can be used for instance when using bank switching to put the const data
  in a bank.
 \layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-fdollars-in-identifiers
+\begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
+
+\end_inset 
+
+
+\series default 
+ Permit '$' as an identifier character
+\layout List
 \added_space_bottom bigskip \labelwidthstring 00.00.0000
 
 
@@ -12927,232 +13112,95 @@ Startup Code
 MCS51/DS390 Startup Code
 \layout Standard
 
-The compiler inserts a call to the C routine 
-\emph on 
-_sdcc_external_startup()
-\begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
+The compiler triggers the linker to link certain initialization modules
+ from the runtime library
+\begin_inset LatexCommand \index{Runtime library}
 
 \end_inset 
 
+ called crt<something>.
+ Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
+ GSINIT5) is not linked unless the --xstack option is used.
+ These modules are highly entangled by the use of special segments/areas,
+ but a common layout is shown below:
+\layout Verse
+
 
+\family typewriter 
 \series bold 
-\emph default 
-\series default 
-at the start of the CODE area.
- This routine is in the runtime library
-\begin_inset LatexCommand \index{Runtime library}
+\size footnotesize 
+(main.asm)
+\layout Verse
 
-\end_inset 
 
-.
- By default this routine returns 0, if this routine returns a non-zero value,
- the static & global variable initialization will be skipped and the function
- main will be invoked.
- Otherwise static & global variables will be initialized before the function
- main is invoked.
- You could add a 
-\emph on 
-_sdcc_external_startup()
-\emph default 
- routine to your program to override the default if you need to setup hardware
- or perform some other critical operation prior to static & global variable
- initialization
-\begin_inset LatexCommand \index{Variable initialization}
+\family typewriter 
+\size footnotesize 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area HOME (CODE)
+\newline 
+__interrupt_vect:
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ljmp __sdcc_gsinit_startup
+\layout Verse
 
-\end_inset 
 
-.
- On some mcs51 variants xdata
-\begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtstart.asm)
+\layout Verse
 
-\end_inset 
 
- memory has to be explicitly enabled before it can be accessed or if the
- watchdog
-\begin_inset LatexCommand \index{watchdog}
+\family typewriter 
+\size footnotesize 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area GSINIT0 (CODE)
+\newline 
+__sdcc_gsinit_startup::
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov sp,#__start__stack - 1
+\layout Verse
 
-\end_inset 
 
- needs to be disabled, this is the place to do it.
- The startup code clears all internal data memory, 256 bytes by default,
- but from 0 to n-1 if 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--iram-size
-\begin_inset LatexCommand \index{-\/-iram-size <Value>}
-
-\end_inset 
-
-n
-\emph default 
- is used.
- (recommended for Chipcon CC1010).
-\layout Standard
-\added_space_bottom bigskip 
-See also the compiler options 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--no-xinit
-\emph default 
--
-\emph on 
-opt
-\emph default 
-
-\begin_inset LatexCommand \index{-\/-no-xinit-opt}
-
-\end_inset 
-
-, 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--main-return
-\emph default 
-
-\begin_inset LatexCommand \index{-\/-main-return}
-
-\end_inset 
-
- and section 
-\begin_inset LatexCommand \ref{sub:MCS51-variants}
-
-\end_inset 
-
- about MCS51-variants.
-\layout Subsection
-
-HC08 Startup Code
-\layout Standard
-\added_space_bottom bigskip 
-The HC08
-\begin_inset LatexCommand \index{HC08}
-
-\end_inset 
-
- startup code follows the same scheme as the MCS51 startup code.
-\layout Subsection
-
-Z80 Startup Code
-\layout Standard
-\added_space_bottom bigskip 
-On the Z80
-\begin_inset LatexCommand \index{Z80}
-
-\end_inset 
-
- the startup code is inserted by linking with crt0.o which is generated from
- sdcc/device/lib/z80/crt0.s.
- If you need a different startup code you can use the compiler option 
-\emph on 
--
+\family typewriter 
 \series bold 
-\emph default 
-
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
-
-\series default 
-\emph on 
--no-std-crt0
-\emph default 
-
-\begin_inset LatexCommand \index{-\/-no-std-crt0}
-
-\end_inset 
-
- and provide your own crt0.o.
-\layout Section
-
-Inline Assembler Code
-\begin_inset LatexCommand \index{Assembler routines}
-
-\end_inset 
-
-
-\layout Subsection
-
-A Step by Step Introduction
-\begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
-
-\end_inset 
-
-
-\layout Standard
-
-Starting from a small snippet of c-code this example shows for the MCS51
- how to use inline assembly, access variables, a function parameter and
- an array in xdata memory.
- The example uses an MCS51 here but is easily adapted for other architectures.
- This is a buffer routine which should be optimized:
+\size footnotesize 
+(crtxstack.asm)
 \layout Verse
 
 
 \family typewriter 
 \size footnotesize 
-unsigned char __far
-\begin_inset LatexCommand \index{far (storage class)}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_far (storage class)}
-
-\end_inset 
-
- __at
-\begin_inset LatexCommand \index{at}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_at}
-
-\end_inset 
-
-(0x7f00) buf[0x100];
-\begin_inset LatexCommand \index{Aligned array}
-
-\end_inset 
-
-
-\newline 
-unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13161,6 +13209,13 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+.area GSINIT1 (CODE)
+\newline 
+__sdcc_init_xstack::
+\newline 
+; Need to initialize in GSINIT1 in case the user's __sdcc_external_startup
+ uses the xstack.
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13169,12 +13224,7 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* if interrupts
-\begin_inset LatexCommand \index{interrupt}
-
-\end_inset 
-
- are involved see
+mov __XPAGE,#(__start__xstack >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13184,6 +13234,19 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov _spx,#__start__xstack
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtstart.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13192,6 +13255,8 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+.area GSINIT2 (CODE)
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13200,6 +13265,8 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+lcall __sdcc_external_startup
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13208,6 +13275,8 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov a,dpl
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13216,61 +13285,31 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+jz __sdcc_init_data
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-section 
-\begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
-
-\end_inset 
-
- about
-\series bold 
- volatile
-\series default 
- */
-\newline 
-
-\newline 
-void to_buffer( unsigned char c ) 
-\newline 
-{
-\newline 
-\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-if( head != (unsigned char)(tail-1) )\SpecialChar ~
-/* cast 
-\series bold 
-needed
-\series default 
- to avoid promotion
-\begin_inset LatexCommand \index{promotion to signed int}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{type promotion}
-
-\end_inset 
-
- to integer */
-\begin_inset Marginal
-collapsed true
-
-\layout Standard
+ljmp __sdcc_program_startup
+\newline 
+__sdcc_init_data:
+\layout Verse
 
 
+\family typewriter 
 \series bold 
-\SpecialChar ~
-!
-\end_inset 
+\size footnotesize 
+(crtxinit.asm)
+\layout Verse
 
 
-\newline 
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13279,7 +13318,11 @@ collapsed true
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-buf[ head++ ] = c;\SpecialChar ~
+.area GSINIT3 (CODE)
+\newline 
+__mcs51_genXINIT::
+\newline 
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13287,6 +13330,8 @@ buf[ head++ ] = c;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov r1,#l_XINIT
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13295,249 +13340,120 @@ buf[ head++ ] = c;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* access to a 256 byte aligned array */
-\newline 
-} 
-\layout Standard
-
-If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
- then a corresponding buffer.asm file is generated.
- We define a new function 
-\family typewriter 
-to_buffer_asm()
-\family default 
- in file buffer.c in which we cut and paste the generated code, removing
- unwanted comments and some ':'.
- Then add 
-\begin_inset Quotes sld
-\end_inset 
-
-_asm
-\begin_inset Quotes srd
-\end_inset 
-
- and 
-\begin_inset Quotes sld
-\end_inset 
-
-_endasm;
-\begin_inset Quotes srd
-\end_inset 
-
- to the beginning and the end of the function body:
-\layout Verse
-
-
-\family typewriter 
-\size footnotesize 
-/* With a cut and paste from the .asm file, we have something to start with.
+mov a,r1
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-The function is not yet OK! (registers aren't saved) */ 
-\newline 
-void to_buffer_asm( unsigned char c ) 
-\newline 
-{ 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_asm
-\begin_inset LatexCommand \index{\_asm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_asm}
-
-\end_inset 
-
-
+\SpecialChar ~
+orl a,#(l_XINIT >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-r2,dpl 
-\newline 
-;buffer.c if( head != (unsigned char)(tail-1) ) \SpecialChar ~
-/* cast 
-\series bold 
-needed
-\series default 
- to avoid promotion
-\begin_inset LatexCommand \index{promotion to signed int}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{type promotion}
-
-\end_inset 
-
- to integer */
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+jz 00003$
+\newline 
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-a,_tail 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dec\SpecialChar ~
 \SpecialChar ~
-a 
+\SpecialChar ~
+mov r2,#((l_XINIT+255) >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-r3,a 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov dptr,#s_XINIT
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-a,_head 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov r0,#s_XISEG
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-cjne a,ar3,00106$ 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-ret
+mov __XPAGE,#(s_XISEG >> 8)
 \newline 
-00106$: 
-\newline 
-;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
-\begin_inset LatexCommand \index{Aligned array}
-
-\end_inset 
-
-
+00001$:\SpecialChar ~
+clr a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
-\SpecialChar ~
-r3,_head 
-\newline 
-\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-inc\SpecialChar ~
 \SpecialChar ~
-_head 
+movc a,@a+dptr
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-dpl,r3 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+movx @r0,a
+\newline 
+\SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-dph,#(_buf >> 8) 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-a,r2 
+inc dptr
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-movx @dptr,a 
-\newline 
-00103$: 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-ret
+inc r0
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_endasm
-\begin_inset LatexCommand \index{\_endasm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_endasm}
-
-\end_inset 
-
-;
-\newline 
-} 
-\layout Standard
-
-The new file buffer.c should compile with only one warning about the unreferenced
- function argument 'c'.
- Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
- (1) and finally have:
-\layout Verse
-
-
-\family typewriter 
-\size footnotesize 
-unsigned char __far __at(0x7f00) buf[0x100];
-\newline 
-unsigned char head, tail;
-\newline 
-#define USE_ASSEMBLY (1)
-\newline 
-
-\newline 
-#if !USE_ASSEMBLY
-\newline 
-
-\newline 
-void to_buffer( unsigned char c )
-\newline 
-{
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-if( head != (unsigned char)(tail-1) )
+cjne r0,#0,00002$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13547,41 +13463,20 @@ if( head != (unsigned char)(tail-1) )
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-buf[ head++ ] = c;
-\newline 
-}
-\newline 
-
-\newline 
-#else
-\newline 
-
+inc __XPAGE
 \newline 
-void to_buffer( unsigned char c )
-\newline 
-{
+00002$:\SpecialChar ~
+djnz r1,00001$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-c; // to avoid warning: unreferenced function argument
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_asm
-\begin_inset LatexCommand \index{\_asm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_asm}
-
-\end_inset 
-
-
+djnz r2,00001$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13591,9 +13486,21 @@ _asm
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; save used registers here.
+mov __XPAGE,#0xFF
 \newline 
+00003$:
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtclear.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13602,10 +13509,9 @@ _asm
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; If we were still using r2,r3 we would have to push them here.
+.area GSINIT4 (CODE)
 \newline 
-; if( head != (unsigned char)(tail-1) )
+__mcs51_genRAMCLEAR::
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13615,8 +13521,7 @@ _asm
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
- a,_tail
+clr a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13626,8 +13531,10 @@ mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dec\SpecialChar ~
- a
+mov r0,#(l_IRAM-1)
+\newline 
+00004$:\SpecialChar ~
+mov @r0,a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13637,9 +13544,21 @@ dec\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-xrl\SpecialChar ~
- a,_head
+djnz r0,00004$
 \newline 
+; _mcs51_genRAMCLEAR() end
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtxclear.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13648,7 +13567,9 @@ xrl\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; we could do an ANL a,#0x0f here to use a smaller buffer (see below)
+.area GSINIT4 (CODE)
+\newline 
+__mcs51_genXRAMCLEAR::
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13658,9 +13579,7 @@ xrl\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-jz\SpecialChar ~
-\SpecialChar ~
- t_b_end$
+mov r0,#l_PSEG
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13670,9 +13589,7 @@ jz\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-;
-\newline 
-; buf[ head++ ] = c;
+mov a,r0
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13682,29 +13599,27 @@ jz\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
- a,dpl \SpecialChar ~
+jz 00006$
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; dpl holds lower byte of function argument
-\newline 
 \SpecialChar ~
 \SpecialChar ~
+mov r1,#s_PSEG
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
- dpl,_head \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; buf is 0x100 byte aligned so head can be used directly
+mov __XPAGE,#(s_PSEG >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13714,8 +13629,10 @@ mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
- dph,#(_buf>>8)
+clr a
+\newline 
+00005$:\SpecialChar ~
+movx @r1,a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13725,7 +13642,7 @@ mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-movx @dptr,a
+inc r1
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13735,8 +13652,9 @@ movx @dptr,a
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-inc \SpecialChar ~
-_head
+djnz r0,00005$
+\newline 
+00006$:
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13746,9 +13664,7 @@ _head
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; we could do an ANL _head,#0x0f here to use a smaller buffer (see above)
-\newline 
-t_b_end$:
+mov r0,#l_XSEG
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13758,239 +13674,37 @@ t_b_end$:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; restore used registers here 
+mov a,r0
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_endasm
-\begin_inset LatexCommand \index{\_endasm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_endasm}
-
-\end_inset 
-
-;
-\newline 
-}
-\newline 
-#endif
-\layout Standard
-
-The inline assembler code can contain any valid code understood by the assembler
-, this includes any assembler directives and comment lines.
- The assembler does not like some characters like ':' or ''' in comments.
- You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
-\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{Assembler documentation}
-
-\end_inset 
-
- or online at 
-\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
-
-\end_inset 
-
 \SpecialChar ~
-.
-\layout Standard
-
-The compiler does not do any validation of the code within the 
-\family typewriter 
-_asm
-\begin_inset LatexCommand \index{\_asm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_asm}
-
-\end_inset 
-
- ...
- _endasm
-\size footnotesize 
-
-\begin_inset LatexCommand \index{\_endasm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_endasm}
-
-\end_inset 
-
-
-\size default 
-;
-\family default 
- keyword pair.
- Specifically it will not know which registers are used and thus register
- pushing/popping
-\begin_inset LatexCommand \index{push/pop}
-
-\end_inset 
-
- has to be done manually.
-\layout Standard
-
-It is recommended that each assembly instruction (including labels) be placed
- in a separate line (as the example shows).
- When the -
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--
-\emph on 
-peep-asm
-\begin_inset LatexCommand \index{-\/-peep-asm}
-
-\end_inset 
-
-
-\emph default 
- command line option is used, the inline assembler code will be passed through
- the peephole optimizer
-\begin_inset LatexCommand \index{Peephole optimizer}
-
-\end_inset 
-
-.
- There are only a few (if any) cases where this option makes sense, it might
- cause some unexpected changes in the inline assembler code.
- Please go through the peephole optimizer rules defined in file 
-\emph on 
-SDCCpeeph.def
-\emph default 
- before using this option.
-\layout Subsection
-
-Naked Functions
-\begin_inset LatexCommand \label{sub:Naked-Functions}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{Naked functions}
-
-\end_inset 
-
-
-\layout Standard
-
-A special keyword may be associated with a function declaring it as 
-\emph on 
-_naked
-\begin_inset LatexCommand \index{\_naked}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_naked}
-
-\end_inset 
-
-.
-\emph default 
-The 
-\emph on 
-_naked
-\emph default 
- function modifier attribute prevents the compiler from generating prologue
-\begin_inset LatexCommand \index{function prologue}
-
-\end_inset 
-
- and epilogue
-\begin_inset LatexCommand \index{function epilogue}
-
-\end_inset 
-
- code for that function.
- This means that the user is entirely responsible for such things as saving
- any registers that may need to be preserved, selecting the proper register
- bank, generating the 
-\emph on 
-return
-\emph default 
- instruction at the end, etc.
- Practically, this means that the contents of the function must be written
- in inline assembler.
- This is particularly useful for interrupt functions, which can have a large
- (and often unnecessary) prologue/epilogue.
- For example, compare the code generated by these two functions:
-\layout Verse
-
-
-\family typewriter 
-volatile
-\begin_inset LatexCommand \index{volatile}
-
-\end_inset 
-
- data unsigned char counter;
-\newline 
-
-\newline 
-void simpleInterrupt(void) __interrupt
-\begin_inset LatexCommand \index{interrupt}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_interrupt}
-
-\end_inset 
-
- (1)
-\newline 
-{
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+orl a,#(l_XSEG >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-counter++;
-\newline 
-}
-\newline 
-
-\newline 
-void nakedInterrupt(void) __interrupt (2) __naked
-\newline 
-{
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+jz 00008$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_asm
-\begin_inset LatexCommand \index{\_asm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_asm}
-
-\end_inset 
-
-
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov r1,#((l_XSEG + 255) >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13998,12 +13712,22 @@ _asm
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-inc\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov dptr,#s_XSEG
+\newline 
 \SpecialChar ~
 \SpecialChar ~
-_counter ; does not change flags, no need to save psw
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+clr a
+\newline 
+00007$:\SpecialChar ~
+movx @dptr,a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14011,211 +13735,169 @@ _counter ; does not change flags, no need to save psw
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-reti\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc dptr
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; MUST explicitly include ret or reti in _naked function.
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+djnz r0,00007$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_endasm
-\begin_inset LatexCommand \index{\_endasm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_endasm}
-
-\end_inset 
-
-;
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+djnz r1,00007$
 \newline 
-}
-\layout Standard
-
-For an 8051 target, the generated simpleInterrupt looks like:
+00008$:
 \layout Verse
 
 
 \family typewriter 
-Note, this is an 
-\emph on 
-outdated
-\emph default 
- example, recent versions of SDCC generate
-\newline 
-the 
-\emph on 
-same
-\emph default 
- code for simpleInterrupt() and nakedInterrupt()!
-\newline 
+\series bold 
+\size footnotesize 
+(crtxstack.asm)
+\layout Verse
 
-\newline 
-_simpleInterrupt:
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-push\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-acc
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-push\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
-b
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-push\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dpl
+.area GSINIT5 (CODE)
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-push\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-dph
+; Need to initialize in GSINIT5 because __mcs51_genXINIT modifies __XPAGE
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-push\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-psw
+; and __mcs51_genRAMCLEAR modifies _spx.
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-psw,#0x00
+mov __XPAGE,#(__start__xstack >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-inc\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_counter
-\newline 
+mov _spx,#__start__xstack
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(application modules)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-psw
-\newline 
+.area GSINIT (CODE)
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(main.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dph
+.area GSFINAL (CODE)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dpl
+ljmp __sdcc_program_startup
+\newline 
+;--------------------------------------------------------
+\newline 
+; Home
+\newline 
+;--------------------------------------------------------
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-b
+.area HOME (CODE)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-acc
+.area CSEG (CODE)
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-reti
-\layout Standard
-
-whereas nakedInterrupt looks like:
-\layout Verse
-
-
-\family typewriter 
-_nakedInterrupt:
+__sdcc_program_startup:
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-inc\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-_counter ; does not change flags, no need to save psw
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
 \SpecialChar ~
-reti\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+lcall _main
+\newline 
+; return from main will lock up
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -14224,372 +13906,3038 @@ reti\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; MUST explicitly include ret or reti in _naked function
+sjmp .
 \layout Standard
 
-The related directive #pragma exclude
-\begin_inset LatexCommand \index{\#pragma exclude}
+One of these modules (crtstart.asm) contains a call to the C routine 
+\emph on 
+_sdcc_external_startup()
+\begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
 
 \end_inset 
 
- allows a more fine grained control over pushing & popping
-\begin_inset LatexCommand \index{push/pop}
+
+\series bold 
+\emph default 
+\series default 
+at the start of the CODE area.
+ This routine is also in the runtime library
+\begin_inset LatexCommand \index{Runtime library}
 
 \end_inset 
 
- the registers.
-\layout Standard
+ and returns 0 by default.
+ If this routine returns a non-zero value, the static & global variable
+ initialization will be skipped and the function main will be invoked.
+ Otherwise static & global variables will be initialized before the function
+ main is invoked.
+ You could add an 
+\emph on 
+_sdcc_external_startup()
+\emph default 
+ routine to your program to override the default if you need to setup hardware
+ or perform some other critical operation prior to static & global variable
+ initialization
+\begin_inset LatexCommand \index{Variable initialization}
 
-While there is nothing preventing you from writing C code inside a 
-\family typewriter 
-_naked
-\family default 
- function, there are many ways to shoot yourself in the foot doing this,
- and it is recommended that you stick to inline assembler.
-\layout Subsection
+\end_inset 
 
-Use of Labels within Inline Assembler
-\layout Standard
+.
+ On some mcs51 variants xdata
+\begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
 
-SDCC allows the use of in-line assembler with a few restrictions regarding
- labels.
- In older versions of the compiler all labels defined within inline assembler
- code 
+\end_inset 
+
+ memory has to be explicitly enabled before it can be accessed or if the
+ watchdog
+\begin_inset LatexCommand \index{watchdog}
+
+\end_inset 
+
+ needs to be disabled, this is the place to do it.
+ The startup code clears all internal data memory, 256 bytes by default,
+ but from 0 to n-1 if 
 \emph on 
-had to be
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-iram-size
+\begin_inset LatexCommand \index{-\/-iram-size <Value>}
+
+\end_inset 
+
+n
 \emph default 
- of the form 
+ is used.
+ (recommended for Chipcon CC1010).
+\layout Standard
+\added_space_bottom bigskip 
+See also the compiler options 
 \emph on 
-nnnnn$
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-no-xinit
 \emph default 
- where nnnn is a number less than 100 (which implies a limit of utmost 100
- inline assembler labels 
+-
 \emph on 
-per function
+opt
 \emph default 
-\noun on 
-)
-\noun default 
-.
-\layout Verse
 
-
-\family typewriter 
-_asm
-\begin_inset LatexCommand \index{\_asm}
+\begin_inset LatexCommand \index{-\/-no-xinit-opt}
 
 \end_inset 
 
+, 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
 
-\begin_inset LatexCommand \index{\_\_asm}
+\layout Standard
 
+\backslash 
+/
 \end_inset 
 
+-main-return
+\emph default 
+
+\begin_inset LatexCommand \index{-\/-main-return}
+
+\end_inset 
+
+ and section 
+\begin_inset LatexCommand \ref{sub:MCS51-variants}
+
+\end_inset 
+
+ about MCS51-variants.
+\layout Subsection
+
+HC08 Startup Code
+\layout Standard
+\added_space_bottom bigskip 
+The HC08
+\begin_inset LatexCommand \index{HC08}
+
+\end_inset 
+
+ startup code follows the same scheme as the MCS51 startup code.
+\layout Subsection
+
+Z80 Startup Code
+\layout Standard
+\added_space_bottom bigskip 
+On the Z80
+\begin_inset LatexCommand \index{Z80}
+
+\end_inset 
+
+ the startup code is inserted by linking with crt0.o which is generated from
+ sdcc/device/lib/z80/crt0.s.
+ If you need a different startup code you can use the compiler option 
+\emph on 
+-
+\series bold 
+\emph default 
+
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+
+\series default 
+\emph on 
+-no-std-crt0
+\emph default 
+
+\begin_inset LatexCommand \index{-\/-no-std-crt0}
+
+\end_inset 
+
+ and provide your own crt0.o.
  
+\layout Section
+
+Inline Assembler Code
+\begin_inset LatexCommand \index{Assembler routines}
+
+\end_inset 
+
+
+\layout Subsection
+
+A Step by Step Introduction
+\begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
+
+\end_inset 
+
+
+\layout Standard
+
+Starting from a small snippet of c-code this example shows for the MCS51
+ how to use inline assembly, access variables, a function parameter and
+ an array in xdata memory.
+ The example uses an MCS51 here but is easily adapted for other architectures.
+ This is a buffer routine which should be optimized:
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
+unsigned char __far
+\begin_inset LatexCommand \index{far (storage class)}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_far (storage class)}
+
+\end_inset 
+
+ __at
+\begin_inset LatexCommand \index{at}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_at}
+
+\end_inset 
+
+(0x7f00) buf[0x100];
+\begin_inset LatexCommand \index{Aligned array}
+
+\end_inset 
+
+
 \newline 
+unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-b,#10 
-\newline 
-00001$: 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-djnz\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-b,00001$ 
-\newline 
-_endasm
-\begin_inset LatexCommand \index{\_endasm}
-
-\end_inset 
-
-
-\begin_inset LatexCommand \index{\_\_endasm}
-
-\end_inset 
-
- ;
-\layout Standard
-
-Inline assembler code cannot reference any C-Labels, however it can reference
- labels
-\begin_inset LatexCommand \index{Labels}
+\SpecialChar ~
+/* if interrupts
+\begin_inset LatexCommand \index{interrupt}
 
 \end_inset 
 
- defined by the inline assembler, e.g.:
-\layout Verse
-
-
-\family typewriter 
-foo() { 
+ are involved see
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* some c code */ 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_asm 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; some assembler code 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-ljmp $0003 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_endasm; 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* some more c code */ 
-\newline 
-clabel:\SpecialChar ~
 \SpecialChar ~
-/* inline assembler cannot reference this label */ 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_asm
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-$0003: ;label (can be referenced by inline assembler only) 
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_endasm
-\begin_inset LatexCommand \index{\_endasm}
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+section 
+\begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
 
 \end_inset 
 
+ about
+\series bold 
+ volatile
+\series default 
+ */
+\newline 
 
-\begin_inset LatexCommand \index{\_\_endasm}
-
-\end_inset 
-
- ; 
+\newline 
+void to_buffer( unsigned char c ) 
+\newline 
+{
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* some more c code */
-\newline 
-}
-\layout Standard
-
-In other words inline assembly code can access labels defined in inline
- assembly within the scope of the function.
- The same goes the other way, i.e.
- labels defines in inline assembly can not be accessed by C statements.
-\layout Section
-
-Interfacing with Assembler Code
-\begin_inset LatexCommand \index{Assembler routines}
+if( head != (unsigned char)(tail-1) )\SpecialChar ~
+/* cast 
+\series bold 
+needed
+\series default 
+ to avoid promotion
+\begin_inset LatexCommand \index{promotion to signed int}
 
 \end_inset 
 
 
-\layout Subsection
-
-Global Registers used for Parameter Passing
-\begin_inset LatexCommand \index{Parameter passing}
+\begin_inset LatexCommand \index{type promotion}
 
 \end_inset 
 
+ to integer */
+\begin_inset Marginal
+collapsed true
 
 \layout Standard
 
-The compiler always uses the global registers 
-\emph on 
-DPL, DPH
-\begin_inset LatexCommand \index{DPTR, DPH, DPL}
 
+\series bold 
+\SpecialChar ~
+!
 \end_inset 
 
 
-\begin_inset LatexCommand \index{DPTR}
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+buf[ head++ ] = c;\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* access to a 256 byte aligned array */
+\newline 
+} 
+\layout Standard
+
+If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
+ then a corresponding buffer.asm file is generated.
+ We define a new function 
+\family typewriter 
+to_buffer_asm()
+\family default 
+ in file buffer.c in which we cut and paste the generated code, removing
+ unwanted comments and some ':'.
+ Then add 
+\begin_inset Quotes sld
+\end_inset 
+
+_asm
+\begin_inset Quotes srd
+\end_inset 
+
+ and 
+\begin_inset Quotes sld
+\end_inset 
+
+_endasm;
+\begin_inset Quotes srd
+\end_inset 
+
+ to the beginning and the end of the function body:
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
+/* With a cut and paste from the .asm file, we have something to start with.
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+The function is not yet OK! (registers aren't saved) */ 
+\newline 
+void to_buffer_asm( unsigned char c ) 
+\newline 
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_asm
+\begin_inset LatexCommand \index{\_asm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_asm}
+
+\end_inset 
+
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+r2,dpl 
+\newline 
+;buffer.c if( head != (unsigned char)(tail-1) ) \SpecialChar ~
+/* cast 
+\series bold 
+needed
+\series default 
+ to avoid promotion
+\begin_inset LatexCommand \index{promotion to signed int}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{type promotion}
+
+\end_inset 
+
+ to integer */
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+a,_tail 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dec\SpecialChar ~
+\SpecialChar ~
+a 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+r3,a 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+a,_head 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+cjne a,ar3,00106$ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ret
+\newline 
+00106$: 
+\newline 
+;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
+\begin_inset LatexCommand \index{Aligned array}
+
+\end_inset 
+
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+r3,_head 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc\SpecialChar ~
+\SpecialChar ~
+_head 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+dpl,r3 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+dph,#(_buf >> 8) 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+a,r2 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+movx @dptr,a 
+\newline 
+00103$: 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ret
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_endasm
+\begin_inset LatexCommand \index{\_endasm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_endasm}
+
+\end_inset 
+
+;
+\newline 
+} 
+\layout Standard
+
+The new file buffer.c should compile with only one warning about the unreferenced
+ function argument 'c'.
+ Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
+ (1) and finally have:
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
+unsigned char __far __at(0x7f00) buf[0x100];
+\newline 
+unsigned char head, tail;
+\newline 
+#define USE_ASSEMBLY (1)
+\newline 
+
+\newline 
+#if !USE_ASSEMBLY
+\newline 
+
+\newline 
+void to_buffer( unsigned char c )
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+if( head != (unsigned char)(tail-1) )
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+buf[ head++ ] = c;
+\newline 
+}
+\newline 
+
+\newline 
+#else
+\newline 
+
+\newline 
+void to_buffer( unsigned char c )
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+c; // to avoid warning: unreferenced function argument
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_asm
+\begin_inset LatexCommand \index{\_asm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_asm}
+
+\end_inset 
+
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; save used registers here.
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; If we were still using r2,r3 we would have to push them here.
+\newline 
+; if( head != (unsigned char)(tail-1) )
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+ a,_tail
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dec\SpecialChar ~
+ a
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+xrl\SpecialChar ~
+ a,_head
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; we could do an ANL a,#0x0f here to use a smaller buffer (see below)
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+jz\SpecialChar ~
+\SpecialChar ~
+ t_b_end$
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+;
+\newline 
+; buf[ head++ ] = c;
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+ a,dpl \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; dpl holds lower byte of function argument
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+ dpl,_head \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; buf is 0x100 byte aligned so head can be used directly
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+ dph,#(_buf>>8)
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+movx @dptr,a
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc \SpecialChar ~
+_head
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; we could do an ANL _head,#0x0f here to use a smaller buffer (see above)
+\newline 
+t_b_end$:
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; restore used registers here 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_endasm
+\begin_inset LatexCommand \index{\_endasm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_endasm}
+
+\end_inset 
+
+;
+\newline 
+}
+\newline 
+#endif
+\layout Standard
+
+The inline assembler code can contain any valid code understood by the assembler
+, this includes any assembler directives and comment lines.
+ The assembler does not like some characters like ':' or ''' in comments.
+ You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
+\begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Assembler documentation}
+
+\end_inset 
+
+ or online at 
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
+
+\end_inset 
+
+\SpecialChar ~
+.
+\layout Standard
+
+The compiler does not do any validation of the code within the 
+\family typewriter 
+_asm
+\begin_inset LatexCommand \index{\_asm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_asm}
+
+\end_inset 
+
+ ...
+ _endasm
+\size footnotesize 
+
+\begin_inset LatexCommand \index{\_endasm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_endasm}
+
+\end_inset 
+
+
+\size default 
+;
+\family default 
+ keyword pair.
+ Specifically it will not know which registers are used and thus register
+ pushing/popping
+\begin_inset LatexCommand \index{push/pop}
+
+\end_inset 
+
+ has to be done manually.
+\layout Standard
+
+It is recommended that each assembly instruction (including labels) be placed
+ in a separate line (as the example shows).
+ When the -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-
+\emph on 
+peep-asm
+\begin_inset LatexCommand \index{-\/-peep-asm}
+
+\end_inset 
+
+
+\emph default 
+ command line option is used, the inline assembler code will be passed through
+ the peephole optimizer
+\begin_inset LatexCommand \index{Peephole optimizer}
+
+\end_inset 
+
+.
+ There are only a few (if any) cases where this option makes sense, it might
+ cause some unexpected changes in the inline assembler code.
+ Please go through the peephole optimizer rules defined in file 
+\emph on 
+SDCCpeeph.def
+\emph default 
+ before using this option.
+\layout Subsection
+
+Naked Functions
+\begin_inset LatexCommand \label{sub:Naked-Functions}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Naked functions}
+
+\end_inset 
+
+
+\layout Standard
+
+A special keyword may be associated with a function declaring it as 
+\emph on 
+_naked
+\begin_inset LatexCommand \index{\_naked}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_naked}
+
+\end_inset 
+
+.
+\emph default 
+The 
+\emph on 
+_naked
+\emph default 
+ function modifier attribute prevents the compiler from generating prologue
+\begin_inset LatexCommand \index{function prologue}
+
+\end_inset 
+
+ and epilogue
+\begin_inset LatexCommand \index{function epilogue}
+
+\end_inset 
+
+ code for that function.
+ This means that the user is entirely responsible for such things as saving
+ any registers that may need to be preserved, selecting the proper register
+ bank, generating the 
+\emph on 
+return
+\emph default 
+ instruction at the end, etc.
+ Practically, this means that the contents of the function must be written
+ in inline assembler.
+ This is particularly useful for interrupt functions, which can have a large
+ (and often unnecessary) prologue/epilogue.
+ For example, compare the code generated by these two functions:
+\layout Verse
+
+
+\family typewriter 
+volatile
+\begin_inset LatexCommand \index{volatile}
+
+\end_inset 
+
+ data unsigned char counter;
+\newline 
+
+\newline 
+void simpleInterrupt(void) __interrupt
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_interrupt}
+
+\end_inset 
+
+ (1)
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+counter++;
+\newline 
+}
+\newline 
+
+\newline 
+void nakedInterrupt(void) __interrupt (2) __naked
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_asm
+\begin_inset LatexCommand \index{\_asm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_asm}
+
+\end_inset 
+
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_counter ; does not change flags, no need to save psw
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+reti\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; MUST explicitly include ret or reti in _naked function.
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_endasm
+\begin_inset LatexCommand \index{\_endasm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_endasm}
+
+\end_inset 
+
+;
+\newline 
+}
+\layout Standard
+
+For an 8051 target, the generated simpleInterrupt looks like:
+\layout Verse
+
+
+\family typewriter 
+Note, this is an 
+\emph on 
+outdated
+\emph default 
+ example, recent versions of SDCC generate
+\newline 
+the 
+\emph on 
+same
+\emph default 
+ code for simpleInterrupt() and nakedInterrupt()!
+\newline 
+
+\newline 
+_simpleInterrupt:
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+acc
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+b
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dpl
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dph
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+psw
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+psw,#0x00
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_counter
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+pop\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+psw
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+pop\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dph
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+pop\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dpl
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+pop\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+b
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+pop\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+acc
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+reti
+\layout Standard
+
+whereas nakedInterrupt looks like:
+\layout Verse
+
+
+\family typewriter 
+_nakedInterrupt:
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_counter ; does not change flags, no need to save psw
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+reti\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; MUST explicitly include ret or reti in _naked function
+\layout Standard
+
+The related directive #pragma exclude
+\begin_inset LatexCommand \index{\#pragma exclude}
+
+\end_inset 
+
+ allows a more fine grained control over pushing & popping
+\begin_inset LatexCommand \index{push/pop}
+
+\end_inset 
+
+ the registers.
+\layout Standard
+
+While there is nothing preventing you from writing C code inside a 
+\family typewriter 
+_naked
+\family default 
+ function, there are many ways to shoot yourself in the foot doing this,
+ and it is recommended that you stick to inline assembler.
+\layout Subsection
+
+Use of Labels within Inline Assembler
+\layout Standard
+
+SDCC allows the use of in-line assembler with a few restrictions regarding
+ labels.
+ In older versions of the compiler all labels defined within inline assembler
+ code 
+\emph on 
+had to be
+\emph default 
+ of the form 
+\emph on 
+nnnnn$
+\emph default 
+ where nnnn is a number less than 100 (which implies a limit of utmost 100
+ inline assembler labels 
+\emph on 
+per function
+\emph default 
+\noun on 
+)
+\noun default 
+.
+\layout Verse
+
+
+\family typewriter 
+_asm
+\begin_inset LatexCommand \index{\_asm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_asm}
+
+\end_inset 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+b,#10 
+\newline 
+00001$: 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+djnz\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+b,00001$ 
+\newline 
+_endasm
+\begin_inset LatexCommand \index{\_endasm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_endasm}
+
+\end_inset 
+
+ ;
+\layout Standard
+
+Inline assembler code cannot reference any C-Labels, however it can reference
+ labels
+\begin_inset LatexCommand \index{Labels}
+
+\end_inset 
+
+ defined by the inline assembler, e.g.:
+\layout Verse
+
+
+\family typewriter 
+foo() { 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* some c code */ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_asm 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; some assembler code 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ljmp $0003 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_endasm; 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* some more c code */ 
+\newline 
+clabel:\SpecialChar ~
+\SpecialChar ~
+/* inline assembler cannot reference this label */ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_asm
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+$0003: ;label (can be referenced by inline assembler only) 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_endasm
+\begin_inset LatexCommand \index{\_endasm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_endasm}
+
+\end_inset 
+
+ ; 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* some more c code */
+\newline 
+}
+\layout Standard
+
+In other words inline assembly code can access labels defined in inline
+ assembly within the scope of the function.
+ The same goes the other way, i.e.
+ labels defines in inline assembly can not be accessed by C statements.
+\layout Section
+
+Interfacing with Assembler Code
+\begin_inset LatexCommand \index{Assembler routines}
+
+\end_inset 
+
+
+\layout Subsection
+
+Global Registers used for Parameter Passing
+\begin_inset LatexCommand \index{Parameter passing}
+
+\end_inset 
+
+
+\layout Standard
+
+The compiler always uses the global registers 
+\emph on 
+DPL, DPH
+\begin_inset LatexCommand \index{DPTR, DPH, DPL}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{DPTR}
+
+\end_inset 
+
+, B
+\begin_inset LatexCommand \index{B (mcs51, ds390 register)}
+
+\end_inset 
+
+\emph default 
+and
+\emph on 
+ ACC
+\begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
+
+\end_inset 
+
+
+\emph default 
+ to pass the first parameter to a routine.
+ The second parameter onwards is either allocated on the stack (for reentrant
+ routines or if -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-stack-auto is used) or in data / xdata memory (depending on the memory
+ model).
+\layout Subsection
+
+Assembler Routine (non-reentrant)
+\layout Standard
+
+In the following example
+\begin_inset LatexCommand \index{reentrant}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
+
+\end_inset 
+
+ the function c_func calls an assembler routine asm_func, which takes two
+ parameters
+\begin_inset LatexCommand \index{function parameter}
+
+\end_inset 
+
+.
+\layout Verse
+
+
+\family typewriter 
+extern int asm_func(unsigned char, unsigned char);
+\newline 
+
+\newline 
+int c_func (unsigned char i, unsigned char j)
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return asm_func(i,j);
+\newline 
+}
+\newline 
+
+\newline 
+int main()
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return c_func(10,9);
+\newline 
+}
+\layout Standard
+
+The corresponding assembler function is:
+\layout Verse
+
+
+\family typewriter 
+.globl _asm_func_PARM_2 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.globl _asm_func 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area OSEG 
+\newline 
+_asm_func_PARM_2:
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.ds    1 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area CSEG 
+\newline 
+_asm_func: 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+a,dpl 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+add\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+a,_asm_func_PARM_2 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dpl,a 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dph
+\begin_inset LatexCommand \index{DPTR, DPH, DPL}
+
+\end_inset 
+
+,#0x00 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ret
+\layout Standard
+
+Note here that the return values
+\begin_inset LatexCommand \index{return value}
+
+\end_inset 
+
+ are placed in 'dpl' - One byte return value, 'dpl' LSB & 'dph' MSB for
+ two byte values.
+ 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
+b' & 'acc' for four byte values.
+\layout Standard
+
+The parameter naming convention is _<function_name>_PARM_<n>, where n is
+ the parameter number starting from 1, and counting from the left.
+ The first parameter is passed in 
+\begin_inset Quotes eld
+\end_inset 
+
+dpl
+\begin_inset Quotes erd
+\end_inset 
+
+ for a one byte parameter, 
+\begin_inset Quotes eld
+\end_inset 
+
+dptr
+\begin_inset Quotes erd
+\end_inset 
+
+ for two bytes, 
+\begin_inset Quotes eld
+\end_inset 
+
+b,dptr
+\begin_inset Quotes erd
+\end_inset 
+
+ for three bytes and 
+\begin_inset Quotes eld
+\end_inset 
+
+acc,b,dptr
+\begin_inset Quotes erd
+\end_inset 
+
+ for a four bytes parameter.
+ The variable name for the second parameter will be _<function_name>_PARM_2.
+\newline 
+
+\newline 
+Assemble the assembler routine with the following command:
+\newline 
+
+\newline 
+
+\family sans 
+\series bold 
+asx8051 -losg asmfunc.asm
+\newline 
+
+\newline 
+
+\family default 
+\series default 
+Then compile and link the assembler routine to the C source file with the
+ following command:
+\newline 
+
+\newline 
+
+\family sans 
+\series bold 
+sdcc cfunc.c asmfunc.rel
+\layout Subsection
+
+Assembler Routine (reentrant)
+\layout Standard
+
+In this case
+\begin_inset LatexCommand \index{reentrant}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{Assembler routines (reentrant)}
+
+\end_inset 
+
+ the second parameter
+\begin_inset LatexCommand \index{function parameter}
+
+\end_inset 
+
+ onwards will be passed on the stack, the parameters are pushed from right
+ to left i.e.
+ after the call the leftmost parameter will be on the top of the stack.
+ Here is an example:
+\layout Verse
+
+
+\family typewriter 
+extern int asm_func(unsigned char, unsigned char);
+\newline 
+
+\newline 
+int c_func (unsigned char i, unsigned char j) reentrant 
+\newline 
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return asm_func(i,j); 
+\newline 
+} 
+\newline 
+
+\newline 
+int main() 
+\newline 
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return c_func(10,9); 
+\newline 
+}
+\layout Standard
+
+The corresponding assembler routine is:
+\layout Verse
+
+
+\family typewriter 
+.globl _asm_func 
+\newline 
+_asm_func: 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+push  _bp 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov _bp,sp 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov r2,dpl
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov a,_bp 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+add a,#0xfd 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov r0,a 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+add  a,#0xfc ;?
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov  r1,a 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov  a,@r0 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+add  a,r2 ;?
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov  dpl,a 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov  dph,#0x00 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov  sp,_bp 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+pop  _bp 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ret
+\layout Standard
+\added_space_bottom bigskip 
+The compiling and linking procedure remains the same, however note the extra
+ entry & exit linkage required for the assembler code, _bp is the stack
+ frame pointer and is used to compute the offset into the stack for parameters
+ and local variables.
+\layout Section
+
+int (16 bit)
+\begin_inset LatexCommand \index{int (16 bit)}
+
+\end_inset 
+
+ and long (32 bit)
+\begin_inset LatexCommand \index{long (32 bit)}
+
+\end_inset 
+
+ Support
+\layout Standard
+
+For signed & unsigned int (16 bit) and long (32 bit) variables, division,
+ multiplication and modulus operations are implemented by support routines.
+ These support routines are all developed in ANSI-C to facilitate porting
+ to other MCUs, although some model specific assembler optimizations are
+ used.
+ The following files contain the described routines, all of them can be
+ found in <installdir>/share/sdcc/lib.
+\newline 
+
+\layout Standard
+\align center 
+
+\begin_inset  Tabular
+<lyxtabular version="3" rows="11" columns="2">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+Function
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+Description
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_mulint.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+16 bit multiplication
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_divsint.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ signed 16 bit division (calls _divuint)
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_divuint.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ unsigned 16 bit division
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_modsint.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+signed 16 bit modulus (calls _moduint)
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_moduint.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+unsigned 16 bit modulus
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_mullong.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+32 bit multiplication
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_divslong.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ signed 32 division (calls _divulong)
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_divulong.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+unsigned 32 division
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+_modslong.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ signed 32 bit modulus (calls _modulong)
+\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
+
+_modulong.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+unsigned 32 bit modulus
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset 
+
+
+\newline 
+
+\layout Standard
+
+Since they are compiled as 
+\emph on 
+non-reentrant
+\emph default 
+
+\begin_inset LatexCommand \index{reentrant}
+
+\end_inset 
+
+, interrupt
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset 
+
+ service routines should not do any of the above operations.
+ If this is unavoidable then the above routines will need to be compiled
+ with the 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-stack-auto
+\begin_inset LatexCommand \index{-\/-stack-auto}
+
+\end_inset 
+
+
+\emph default 
+ option, after which the source program will have to be compiled with 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-int-long-reent
+\begin_inset LatexCommand \index{-\/-int-long-reent}
+
+\end_inset 
+
+
+\emph default 
+ option.
+ Notice that you don't have to call these routines directly.
+ The compiler will use them automatically every time an integer operation
+ is required.
+\layout Section
+
+Floating Point Support
+\begin_inset LatexCommand \index{Floating point support}
+
+\end_inset 
+
+
+\layout Standard
+
+SDCC supports IEEE (single precision 4 bytes) floating point numbers.
+ The floating point support routines are derived from gcc's floatlib.c and
+ consist of the following routines:
+\newline 
+
+\layout Standard
+\align center 
+
+\size footnotesize 
+
+\begin_inset  Tabular
+<lyxtabular version="3" rows="17" columns="2">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+Function 
+\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">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fsadd.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+add floating point numbers
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fssub.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+subtract floating point numbers 
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fsdiv.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+divide floating point numbers 
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fsmul.c 
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+multiply floating point numbers 
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fs2uchar.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert floating point to unsigned char
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fs2char.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert floating point to signed char
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fs2uint.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert floating point to unsigned int
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fs2int.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert floating point to signed int
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fs2ulong.
+\family default 
+\series default 
+\shape default 
+\size default 
+\emph default 
+\bar default 
+\noun default 
+c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert floating point to unsigned long
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_fs2long.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert floating point to signed long
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_uchar2fs.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert unsigned char to floating point
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_char2fs.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert char to floating point number
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_uint2fs.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert unsigned int to floating point
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_int2fs.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert int to floating point numbers
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_ulong2fs.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert unsigned long to floating point number
+\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
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+_long2fs.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+convert long to floating point number
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset 
+
+
+\newline 
+
+\layout Standard
+\added_space_bottom bigskip 
+These support routines are developed in ANSI-C so there is room for space
+ and speed improvement
+\begin_inset Foot
+collapsed false
+
+\layout Standard
 
+These floating point routines (
+\emph on 
+not
+\emph default 
+ sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
 \end_inset 
 
-, B
-\begin_inset LatexCommand \index{B (mcs51, ds390 register)}
-
-\end_inset 
+.
+ Note if all these routines are used simultaneously the data space might
+ overflow.
+ For serious floating point usage the large model might be needed.
+ Also notice that you don't have to call this routines directly.
+ The compiler will use them automatically every time a floating point operation
+ is required.
+\layout Section
 
-\emph default 
-and
-\emph on 
- ACC
-\begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
+Library Routines
+\begin_inset LatexCommand \index{Libraries}
 
 \end_inset 
 
 
-\emph default 
- to pass the first parameter to a routine.
- The second parameter onwards is either allocated on the stack (for reentrant
- routines or if -
-\begin_inset ERT
-status Collapsed
-
 \layout Standard
 
-\backslash 
-/
-\end_inset 
 
--stack-auto is used) or in data / xdata memory (depending on the memory
- model).
+\emph on 
+<pending: this is messy and incomplete - a little more information is in
+ sdcc/doc/libdoc.txt
+\emph default 
+ >
 \layout Subsection
 
-Assembler Routine (non-reentrant)
-\layout Standard
-
-In the following example
-\begin_inset LatexCommand \index{reentrant}
+Compiler support routines (_gptrget, _mulint etc.)
+\layout Subsection
 
-\end_inset 
+Stdclib functions (puts, printf, strcat etc.)
+\layout Subsubsection
 
+<stdio.h>
+\layout Paragraph
 
-\begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
+getchar(), putchar()
+\layout Standard
 
-\end_inset 
 
- the function c_func calls an assembler routine asm_func, which takes two
- parameters
-\begin_inset LatexCommand \index{function parameter}
+\begin_inset LatexCommand \index{<stdio.h>}
 
 \end_inset 
 
-.
-\layout Verse
+As usual on embedded systems you have to provide your own 
+\family typewriter 
+getchar()
+\begin_inset LatexCommand \index{getchar()}
 
+\end_inset 
 
+\family default 
+and 
 \family typewriter 
-extern int asm_func(unsigned char, unsigned char);
-\newline 
+putchar()
+\begin_inset LatexCommand \index{putchar()}
 
-\newline 
-int c_func (unsigned char i, unsigned char j)
-\newline 
-{
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return asm_func(i,j);
-\newline 
-}
-\newline 
+\end_inset 
 
-\newline 
-int main()
-\newline 
-{
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return c_func(10,9);
-\newline 
-}
-\layout Standard
 
-The corresponding assembler function is:
+\family default 
+ routines.
+ SDCC does not know whether the system connects to a serial line with or
+ without handshake, LCD, keyboard or other device.
+ And whether a 
+\family typewriter 
+lf
+\family default 
+ to 
+\family typewriter 
+crlf
+\family default 
+ conversion within 
+\family typewriter 
+putchar()
+\family default 
+ is intended.
+ You'll find examples for serial routines f.e.
+ in sdcc/device/lib.
+ For the mcs51 this minimalistic polling 
+\family typewriter 
+putchar()
+\family default 
+ routine might be a start:
 \layout Verse
 
 
 \family typewriter 
-.globl _asm_func_PARM_2 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.globl _asm_func 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.area OSEG 
-\newline 
-_asm_func_PARM_2:
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.ds    1 
+void putchar (char c) { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+while (!TI)\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.area CSEG 
-\newline 
-_asm_func: 
+ /* assumes UART is initialized */
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14599,347 +16947,406 @@ _asm_func:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-a,dpl 
+;
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-a,_asm_func_PARM_2 
+TI = 0;
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-dpl,a 
+SBUF = c;
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-dph
-\begin_inset LatexCommand \index{DPTR, DPH, DPL}
+}
+\layout Paragraph
+
+printf()
+\layout Standard
+
+The default
+\family typewriter 
+ printf()
+\begin_inset LatexCommand \index{printf()}
+
+\end_inset 
+
+
+\family default 
+ implementation in
+\family typewriter 
+ printf_large.c
+\family default 
+ does not support float (except on ds390).
+ To enable this recompile it with the option 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+DUSE_FLOATS=1
+\begin_inset LatexCommand \index{USE\_FLOATS}
+
+\end_inset 
+
+
+\emph default 
+ on the command line.
+ Use
+\emph on 
+ -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-model-large
+\begin_inset LatexCommand \index{-\/-model-large}
 
 \end_inset 
 
-,#0x00 
+
+\emph default 
+ for the mcs51 port, since this uses a lot of memory.
+\layout Standard
+
+If you're short on code memory you might want to use 
+\family typewriter 
+printf_small()
+\begin_inset LatexCommand \index{printf\_small()}
+
+\end_inset 
+
+
+\family default 
+\emph on 
+instead
+\emph default 
+ of
+\family typewriter 
+ printf().
+
+\family default 
+ For the mcs51 there additionally are assembly versions 
+\family typewriter 
+printf_tiny()
+\begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
+
+\end_inset 
+
+
+\family default 
+ (subset of printf using less than 270 bytes) and 
+\family typewriter 
+printf_fast()
+\begin_inset LatexCommand \index{printf\_fast() (mcs51)}
+
+\end_inset 
+
+\family default 
+and
+\family typewriter 
+ printf_fast_f()
+\begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
+
+\end_inset 
+
+
+\family default 
+ (floating-point aware version of printf_fast) which should fit the requirements
+ of many embedded systems (printf_fast() can be customized by unsetting
+ #defines to 
+\emph on 
+not
+\emph default 
+ support long variables and field widths).
+ Be sure to use only one of these printf options within a project.
 \newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-ret
+
+\layout Standard
+
+Feature matrix of different 
+\emph on 
+printf
+\emph default 
+ options on mcs51.
+\layout Standard
+
+
+\begin_inset  Tabular
+<lyxtabular version="3" rows="14" columns="7">
+<features islongtable="true">
+<column alignment="left" valignment="center" leftline="true" width="14col%">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="12col%">
+<column alignment="center" valignment="top" leftline="true" width="10col%">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
+<column alignment="center" valignment="top" rightline="true" width="0">
+<row topline="true" bottomline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
 \layout Standard
 
-Note here that the return values
-\begin_inset LatexCommand \index{return value}
 
+\series bold 
+\size large 
+mcs51
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- are placed in 'dpl' - One byte return value, 'dpl' LSB & 'dph' MSB for
- two byte values.
- 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
-b' & 'acc' for four byte values.
 \layout Standard
 
-The parameter naming convention is _<function_name>_PARM_<n>, where n is
- the parameter number starting from 1, and counting from the left.
- The first parameter is passed in 
-\begin_inset Quotes eld
+printf
+\begin_inset LatexCommand \index{printf}
+
 \end_inset 
 
-dpl
-\begin_inset Quotes erd
+
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- for a one byte parameter, 
-\begin_inset Quotes eld
+\layout Standard
+
+printf 
+\size scriptsize 
+USE_FLOATS=1
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-dptr
-\begin_inset Quotes erd
+\layout Standard
+
+printf_small
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- for two bytes, 
-\begin_inset Quotes eld
+\layout Standard
+
+printf_fast
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-b,dptr
-\begin_inset Quotes erd
+\layout Standard
+
+printf_fast_f
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
- for three bytes and 
-\begin_inset Quotes eld
+\layout Standard
+
+printf_tiny
 \end_inset 
+</cell>
+</row>
+<row topline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-acc,b,dptr
-\begin_inset Quotes erd
+\layout Standard
+
+filename
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- for a four bytes parameter.
- The variable name for the second parameter will be _<function_name>_PARM_2.
-\newline 
+\layout Standard
 
-\newline 
-Assemble the assembler routine with the following command:
-\newline 
 
-\newline 
+\size scriptsize 
+printf_large.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family sans 
-\series bold 
-asx8051 -losg asmfunc.asm
-\newline 
+\layout Standard
 
-\newline 
 
-\family default 
-\series default 
-Then compile and link the assembler routine to the C source file with the
- following command:
-\newline 
+\size scriptsize 
+printf_large.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\newline 
+\layout Standard
 
-\family sans 
-\series bold 
-sdcc cfunc.c asmfunc.rel
-\layout Subsection
 
-Assembler Routine (reentrant)
+\size scriptsize 
+printfl.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size scriptsize 
+printf_fast.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
 \layout Standard
 
-In this case
-\begin_inset LatexCommand \index{reentrant}
 
+\size scriptsize 
+printf_fast_f.c
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\begin_inset LatexCommand \index{Assembler routines (reentrant)}
 
+\size scriptsize 
+printf_tiny.c
 \end_inset 
+</cell>
+</row>
+<row topline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- the second parameter
-\begin_inset LatexCommand \index{function parameter}
+\layout Standard
 
+
+\begin_inset Quotes sld
 \end_inset 
 
- onwards will be passed on the stack, the parameters are pushed from right
- to left i.e.
- after the call the leftmost parameter will be on the top of the stack.
- Here is an example:
-\layout Verse
+Hello World
+\begin_inset Quotes srd
+\end_inset 
 
+ size
+\layout Standard
 
-\family typewriter 
-extern int asm_func(unsigned char, unsigned char);
-\newline 
+small / large
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\newline 
-int c_func (unsigned char i, unsigned char j) reentrant 
-\newline 
-{ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return asm_func(i,j); 
-\newline 
-} 
-\newline 
+\layout Standard
+
+1.7k / 2.4k
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\newline 
-int main() 
-\newline 
-{ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return c_func(10,9); 
-\newline 
-}
 \layout Standard
 
-The corresponding assembler routine is:
-\layout Verse
+4.3k / 5.6k
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
+
+1.2k / 1.8k
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family typewriter 
-.globl _asm_func 
-\newline 
-_asm_func: 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-push  _bp 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov _bp,sp 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov r2,dpl
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov a,_bp 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add a,#0xfd 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov r0,a 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add  a,#0xfc ;?
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov  r1,a 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov  a,@r0 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add  a,r2 ;?
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov  dpl,a 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov  dph,#0x00 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov  sp,_bp 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-pop  _bp 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-ret
 \layout Standard
-\added_space_bottom bigskip 
-The compiling and linking procedure remains the same, however note the extra
- entry & exit linkage required for the assembler code, _bp is the stack
- frame pointer and is used to compute the offset into the stack for parameters
- and local variables.
-\layout Section
 
-int (16 bit)
-\begin_inset LatexCommand \index{int (16 bit)}
+1.3k / 1.3k
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
+1.9k / 1.9k
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
- and long (32 bit)
-\begin_inset LatexCommand \index{long (32 bit)}
+\layout Standard
+
+0.44k / 0.44k
+\end_inset 
+</cell>
+</row>
+<row topline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+code size
+\layout Standard
 
+small / large
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
- Support
 \layout Standard
 
-For signed & unsigned int (16 bit) and long (32 bit) variables, division,
- multiplication and modulus operations are implemented by support routines.
- These support routines are all developed in ANSI-C to facilitate porting
- to other MCUs, although some model specific assembler optimizations are
- used.
- The following files contain the described routines, all of them can be
- found in <installdir>/share/sdcc/lib.
-\newline 
+1.4k / 2.0k
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
-\align center 
 
-\begin_inset  Tabular
-<lyxtabular version="3" rows="11" columns="2">
-<features>
-<column alignment="left" valignment="top" leftline="true" width="0">
-<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
-<row topline="true" bottomline="true">
+2.8k / 3.7k
+\end_inset 
+</cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+0.45k / 0.47k (+ _ltoa)
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\series bold 
-Function
+\layout Standard
+
+1.2k / 1.2k
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -14947,9 +17354,15 @@ Function
 
 \layout Standard
 
+1.6k / 1.6k
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\series bold 
-Description
+\layout Standard
+
+0.26k / 0.26k
 \end_inset 
 </cell>
 </row>
@@ -14959,43 +17372,117 @@ Description
 
 \layout Standard
 
-_mulint.c 
+formats
 \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
 
-16 bit multiplication
+cdi
+\emph on 
+o
+\emph default 
+psux
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-_divsint.c 
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+cd
+\family default 
+\series default 
+\shape default 
+\size default 
+\emph default 
+\bar default 
+\noun default 
+f
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+i
+\family default 
+\series default 
+\shape default 
+\size default 
+\emph on 
+\bar default 
+\noun default 
+o
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+psux
 \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
 
- signed 16 bit division (calls _divuint)
+c
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+d
+\family default 
+\series default 
+\shape default 
+\size default 
+\emph on 
+\bar default 
+\noun default 
+o
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+s
+\family default 
+\series default 
+\shape default 
+\size default 
+\emph default 
+\bar default 
+\noun default 
+x
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-_divuint.c 
+cdsux
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15003,17 +17490,7 @@ _divuint.c
 
 \layout Standard
 
- unsigned 16 bit division
-\end_inset 
-</cell>
-</row>
-<row topline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
-
-\layout Standard
-
-_modsint.c
+cdfsux
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15021,7 +17498,7 @@ _modsint.c
 
 \layout Standard
 
-signed 16 bit modulus (calls _moduint)
+cdsux
 \end_inset 
 </cell>
 </row>
@@ -15031,43 +17508,39 @@ signed 16 bit modulus (calls _moduint)
 
 \layout Standard
 
-_moduint.c
+long (32 bit) support
 \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
 
-unsigned 16 bit modulus
+x
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-_mullong.c
+x
 \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
 
-32 bit multiplication
+x
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-_divslong.c 
+x
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15075,17 +17548,16 @@ _divslong.c
 
 \layout Standard
 
- signed 32 division (calls _divulong)
-\end_inset 
-</cell>
-</row>
-<row topline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
-
-\layout Standard
 
-_divulong.c 
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+x
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15093,7 +17565,7 @@ _divulong.c
 
 \layout Standard
 
-unsigned 32 division
+-
 \end_inset 
 </cell>
 </row>
@@ -15103,144 +17575,39 @@ unsigned 32 division
 
 \layout Standard
 
-_modslong.c
+byte arguments on stack
 \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
 
- signed 32 bit modulus (calls _modulong)
+b
 \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
 
-_modulong.c
+b
 \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
 
-unsigned 32 bit modulus
-\end_inset 
-</cell>
-</row>
-</lyxtabular>
-
-\end_inset 
-
-
-\newline 
-
-\layout Standard
-
-Since they are compiled as 
-\emph on 
-non-reentrant
-\emph default 
-
-\begin_inset LatexCommand \index{reentrant}
-
-\end_inset 
-
-, interrupt
-\begin_inset LatexCommand \index{interrupt}
-
-\end_inset 
-
- service routines should not do any of the above operations.
- If this is unavoidable then the above routines will need to be compiled
- with the 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--stack-auto
-\begin_inset LatexCommand \index{-\/-stack-auto}
-
-\end_inset 
-
-
-\emph default 
- option, after which the source program will have to be compiled with 
-\emph on 
 -
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--int-long-reent
-\begin_inset LatexCommand \index{-\/-int-long-reent}
-
-\end_inset 
-
-
-\emph default 
- option.
- Notice that you don't have to call these routines directly.
- The compiler will use them automatically every time an integer operation
- is required.
-\layout Section
-
-Floating Point Support
-\begin_inset LatexCommand \index{Floating point support}
-
 \end_inset 
-
-
-\layout Standard
-
-SDCC supports IEEE (single precision 4 bytes) floating point numbers.
- The floating point support routines are derived from gcc's floatlib.c and
- consist of the following routines:
-\newline 
-
-\layout Standard
-\align center 
-
-\size footnotesize 
-
-\begin_inset  Tabular
-<lyxtabular version="3" rows="17" columns="2">
-<features>
-<column alignment="left" valignment="top" leftline="true" width="0">
-<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
-<row topline="true" bottomline="true">
+</cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-Function 
+-
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15248,26 +17615,7 @@ Function
 
 \layout Standard
 
-Description
-\end_inset 
-</cell>
-</row>
-<row topline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
-\begin_inset Text
-
-\layout Standard
-
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fsadd.c
+-
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15275,16 +17623,7 @@ _fsadd.c
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-add floating point numbers
+-
 \end_inset 
 </cell>
 </row>
@@ -15294,124 +17633,61 @@ add floating point numbers
 
 \layout Standard
 
+float format
+\begin_inset LatexCommand \index{Floating point support}
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fssub.c 
 \end_inset 
-</cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
-\begin_inset Text
-
-\layout Standard
 
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-subtract floating point numbers 
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fsdiv.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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-divide floating point numbers 
+%f
 \end_inset 
-</cell>
-</row>
-<row topline="true">
+</cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fsmul.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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-multiply floating point numbers 
+-
 \end_inset 
 </cell>
-</row>
-<row topline="true">
-<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+%f
+\begin_inset Foot
+collapsed true
+
+\layout Standard
+
+Range limited to +/- 4294967040, precision limited to 8 digits past decimal
+\end_inset 
+
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fs2uchar.c
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15419,16 +17695,7 @@ _fs2uchar.c
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert floating point to unsigned char
+-
 \end_inset 
 </cell>
 </row>
@@ -15438,88 +17705,39 @@ convert floating point to unsigned char
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fs2char.c
+float formats %e %g
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert floating point to signed char
+-
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fs2uint.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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert floating point to unsigned int
+-
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fs2int.c
+-
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15527,116 +17745,57 @@ _fs2int.c
 
 \layout Standard
 
+-
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert floating point to signed int
+\layout Standard
+
+-
 \end_inset 
 </cell>
 </row>
-<row topline="true">
+<row topline="true" bottomline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fs2ulong.
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
-c
+field width
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert floating point to unsigned long
+x
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fs2long.c
+x
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert floating point to signed long
+-
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_uchar2fs.c
+x
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15644,107 +17803,81 @@ _uchar2fs.c
 
 \layout Standard
 
+x
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert unsigned char to floating point
+-
 \end_inset 
 </cell>
 </row>
-<row topline="true">
+<row bottomline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+string speed
+\begin_inset Foot
+collapsed true
+
+\layout Standard
+
+Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
+\backslash 
+r', '
+\backslash 
+n'); standard 8051 @ 22.1184 MHz, empty putchar()
+\end_inset 
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_char2fs.c
+,
+\layout Standard
+
+small / large
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert char to floating point number
+1.52 / 2.59 ms
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+1.53 / 2.62 ms
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_uint2fs.c
+0.92 / 0.93 ms
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert unsigned int to floating point
+0.45 / 0.45 ms
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_int2fs.c
+0.46 / 0.46 ms
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15752,300 +17885,237 @@ _int2fs.c
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert int to floating point numbers
+0.45 / 0.45 ms
 \end_inset 
 </cell>
 </row>
-<row topline="true">
+<row bottomline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+int speed
+\begin_inset Foot
+collapsed true
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_ulong2fs.c
+\layout Standard
+
+Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
+ putchar()
+\end_inset 
+
+,
+\layout Standard
+
+small / large
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert unsigned long to floating point number
+3.01 / 3.61 ms
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_long2fs.c
+3.01 / 3.61 ms
 \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
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-convert long to floating point number
+3.51 / 18.13 ms
 \end_inset 
 </cell>
-</row>
-</lyxtabular>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
+0.22 / 0.22 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\newline 
+0.23 / 0.23 ms
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
-\added_space_bottom bigskip 
-These support routines are developed in ANSI-C so there is room for space
- and speed improvement
+
+0.25 / 0.25 ms
 \begin_inset Foot
-collapsed false
+collapsed true
 
 \layout Standard
 
-These floating point routines (
-\emph on 
-not
-\emph default 
- sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
+printf_tiny integer speed is data dependent, worst case is 0.33 ms
 \end_inset 
 
-.
- Note if all these routines are used simultaneously the data space might
- overflow.
- For serious floating point usage the large model might be needed.
- Also notice that you don't have to call this routines directly.
- The compiler will use them automatically every time a floating point operation
- is required.
-\layout Section
-
-Library Routines
-\begin_inset LatexCommand \index{Libraries}
 
 \end_inset 
-
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
+long speed
+\begin_inset Foot
+collapsed true
 
-\emph on 
-<pending: this is messy and incomplete - a little more information is in
- sdcc/doc/libdoc.txt
-\emph default 
- >
-\layout Subsection
-
-Compiler support routines (_gptrget, _mulint etc.)
-\layout Subsection
-
-Stdclib functions (puts, printf, strcat etc.)
-\layout Subsubsection
-
-<stdio.h>
 \layout Standard
 
+Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
+ empty putchar()
+\end_inset 
 
-\begin_inset LatexCommand \index{<stdio.h>}
+,
+\layout Standard
 
+small / large
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-As usual on embedded systems you have to provide your own 
-\family typewriter 
-getchar()
-\begin_inset LatexCommand \index{getchar()}
+\layout Standard
 
+5.37 / 6.31 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family default 
-and 
-\family typewriter 
-putchar()
-\begin_inset LatexCommand \index{putchar()}
+\layout Standard
 
+5.37 / 6.31 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-
-\family default 
- routines.
- SDCC does not know whether the system connects to a serial line with or
- without handshake, LCD, keyboard or other device.
- And whether a 
-\family typewriter 
-lf
-\family default 
- to 
-\family typewriter 
-crlf
-\family default 
- conversion within 
-\family typewriter 
-putchar()
-\family default 
- is intended.
- You'll find examples for serial routines f.e.
- in sdcc/device/lib.
 \layout Standard
 
-The default
-\family typewriter 
- printf()
-\begin_inset LatexCommand \index{printf()}
-
+8.71 / 40.65 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\family default 
-implementation in
-\family typewriter 
- printf_large.c
-\family default 
- does not support float (except on ds390).
- To enable this recompile it with the option 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
+0.40 / 0.40 ms
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
+0.40 / 0.40 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-DUSE_FLOATS=1
-\begin_inset LatexCommand \index{USE\_FLOATS}
+\layout Standard
 
+-
 \end_inset 
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\emph default 
- on the command line.
- Use
-\emph on 
- -
-\begin_inset ERT
-status Collapsed
+float speed
+\begin_inset Foot
+collapsed true
 
 \layout Standard
 
-\backslash 
-/
+Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
+ empty putchar()
 \end_inset 
 
--model-large
-\begin_inset LatexCommand \index{-\/-model-large}
+,
+\layout Standard
 
+small / large
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-
-\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()
-\begin_inset LatexCommand \index{printf\_small()}
-
+-
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\family default 
-\emph on 
-instead
-\emph default 
- of
-\family typewriter 
- printf().
+7.49 / 22.47 ms
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\family default 
- For the mcs51 there additionally are assembly versions 
-\family typewriter 
-printf_tiny()
-\begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
+\layout Standard
 
+-
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\family default 
- (subset of printf using less than 270 bytes) and 
-\family typewriter 
-printf_fast()
-\begin_inset LatexCommand \index{printf\_fast() (mcs51)}
+-
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
 
+1.04 / 1.04 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\family default 
-and
-\family typewriter 
- printf_fast_f()
-\begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
+\layout Standard
+
+-
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
 
 \end_inset 
 
 
-\family default 
- (floating-point aware version of printf_fast) which should fit the requirements
- of many embedded systems (printf_fast() can be customized by unsetting
- #defines to 
-\emph on 
-not
-\emph default 
- support long variables and field widths).
 \layout Subsubsection
 
 <malloc.h>
@@ -16077,17 +18147,14 @@ As of SDCC 2.6.2 you no longer need to call an initialization routine before
 
 \family typewriter 
 sdcc -c _heap.c -D HEAD_SIZE=2048
-\newline 
+\layout Standard
 
-\family default 
 And then link it with:
 \layout Verse
 
 
 \family typewriter 
 sdcc main.rel _heap.rel
-\newline 
-
 \layout Subsection
 
 Math functions (sinf, powf, sqrtf etc.)
@@ -16118,15 +18185,24 @@ Libraries
 LGPL
 \emph default 
 .
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 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
  enough for many embedded programmers.
+\end_inset 
+
+
 \layout Standard
 
 If you have ported some library or want to share experience about some code
@@ -16886,6 +18962,60 @@ The preprocessor SDCPP
 \layout Itemize
 
 
+\series bold 
+pedantic_parse_number
+\series default 
+
+\begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
+
+\end_inset 
+
+ (+ | -) - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are
+ parsed properly and the macro LO_B(3) gets expanded.
+ Default is off.
+ Below is an example on how to use this pragma.
+
+\emph on 
+ Note: this functionality is not in conformance with standard!
+\layout Verse
+
+
+\family typewriter 
+#pragma pedantic_parse_number +
+\begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
+
+\end_inset 
+
+
+\newline 
+
+\newline 
+#define LO_B(x) ((x) & 0xff)
+\newline 
+
+\newline 
+unsigned char foo(void)
+\newline 
+{
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+unsigned char c=0xfe-LO_B(3);
+\newline 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+return c;
+\newline 
+}
+\newline 
+
+\layout Itemize
+
+
 \series bold 
 preproc_asm
 \series default 
@@ -16958,6 +19088,78 @@ void foo (void)
 } 
 \newline 
 
+\layout Itemize
+
+
+\series bold 
+sdcc_hash
+\series default 
+
+\begin_inset LatexCommand \index{\#pragma sdcc\_hash}
+
+\end_inset 
+
+ (+ | -) - Allow "naked" hash in macro definition, for example:
+\newline 
+
+\family typewriter 
+#define DIR_LO(x) #(x & 0xff)
+\family default 
+
+\newline 
+Default is off.
+ Below is an example on how to use this pragma.
+\layout Verse
+
+
+\family typewriter 
+#pragma preproc_asm +
+\newline 
+#pragma sdcc_hash +
+\begin_inset LatexCommand \index{\#pragma sdcc\_hash}
+
+\end_inset 
+
+
+\newline 
+
+\newline 
+#define ROMCALL(x) 
+\backslash 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov R6_B3, #(x & 0xff) 
+\backslash 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov R7_B3, #((x >> 8) & 0xff) 
+\backslash 
+
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+lcall __romcall
+\newline 
+
+\newline 
+...
+\newline 
+_asm
+\newline 
+ROMCALL(72)
+\newline 
+_endasm;
+\newline 
+...
+\newline 
+
 \layout Standard
 
 The pragma's are intended to be used to turn-on or off certain optimizations
@@ -17500,17 +19702,33 @@ sfr
 
 
 \family typewriter 
-__sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family */
+__sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
+ MPAGE */
+\layout Verse
+
+
+\family typewriter 
+__sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
+ a.k.a.
+ MPAGE */
+\layout Verse
+
+
+\family typewriter 
+__sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
+ XPAGE */
 \layout Verse
 
 
 \family typewriter 
-__sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips */
+__sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
+ EMI0CN */
 \layout Verse
 
 
 \family typewriter 
-__sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips */
+__sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
+ EMI0CN */
 \layout Standard
 
 For more exotic implementations further customizations may be needed.
@@ -17634,7 +19852,7 @@ The port to the Freescale/Motorola HC08
  Some of the SDCC's standard C library functions have embedded non-HC08
  inline assembly and so are not yet usable.
 \layout Standard
-\added_space_bottom bigskip 
+\added_space_bottom bigskip \pagebreak_bottom 
 The HC08 port passes the regression test suite (see section 
 \begin_inset LatexCommand \ref{sec:Quality-control}
 
@@ -17642,7 +19860,7 @@ The HC08 port passes the regression test suite (see section
 
 ).
 \layout Section
-\pagebreak_top 
+
 The PIC14 port
 \layout Standard
 
@@ -17686,19 +19904,13 @@ The linker organizes allocation for the code page and RAM banks.
  used.
  The compiler treats all functions of a single C file as being in the same
  code page unless it is non static.
- The compiler treats all local variables of a single C file as being in
- the same RAM bank unless it is an extern.
 \newline 
 
 \newline 
 To get the best follow these guide lines:
 \layout Enumerate
 
-make local functions static, as non static functions require code page selection
- overhead.
-\layout Enumerate
-
-Make local variables static as extern variables require RAM bank selection
+Make local functions static, as non static functions require code page selection
  overhead.
 \layout Enumerate
 
@@ -17707,10 +19919,11 @@ For devices that have multiple code pages it is more efficient to use the
  for the 16F877 use 4 separate files and i.e.
  for the 16F874 use 2 separate files.
  This way the linker can put the code for each file into different code
- pages and the compiler can allocate reusable variables more efficiently
- and there's less page selection overhead.
- And as for any 8 bit micro (especially for PIC 14 as they have a very simple
- instruction set) use 'unsigned char' whereever possible instead of 'int'.
+ pages and there's less page selection overhead.
+\layout Enumerate
+
+And as for any 8 bit micro (especially for PIC 14 as they have a very simple
+ instruction set), use 'unsigned char' whereever possible instead of 'int'.
 \layout Subsection
 
 Creating a device include file 
@@ -17727,7 +19940,7 @@ For generating a device include file
 Interrupt code
 \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 
@@ -17739,7 +19952,7 @@ For the interrupt function, use the keyword 'interrupt'
 
 
 \family typewriter 
-void Intr(void) interrupt 0
+void Intr(void) __interrupt 0
 \newline 
 {
 \newline 
@@ -17923,6 +20136,45 @@ status Collapsed
 \end_inset 
 
  disable (slightly faulty) optimization on pCode
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-stack-loc
+\begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
+
+\end_inset 
+
+ sets the lowest address of the argument passing stack (defaults to a suitably
+ large shared databank to reduce BANKSEL overhead)
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-stack-size
+\begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
+
+\end_inset 
+
+ sets the size if the argument passing stack (default: 16, minimum: 4)
 \layout Subsection
 
 The library
@@ -17996,7 +20248,7 @@ Known bugs
 
 initialized data
 \layout Standard
-
+\pagebreak_bottom 
 Currently, data can only be initialized if it resides in the source file
  together with 
 \emph on 
@@ -18024,7 +20276,7 @@ collapsed true
 
 
 \layout Section
-\pagebreak_top 
+
 The PIC16
 \begin_inset LatexCommand \index{PIC16}
 
@@ -18370,7 +20622,7 @@ status Collapsed
 /
 \end_inset 
 
--stack-model=[model] Used in conjuction with the command above.
+-pstack-model=[model] Used in conjuction with the command above.
  Defines the stack model to be used, valid stack models are : 
 \begin_deeper 
 \layout List
@@ -22410,7 +24662,13 @@ quit
 \layout Subsection
 
 Interfacing SDCDB with DDD
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 The screenshot was converted from png to eps with: 
 \begin_inset Quotes sld
@@ -22422,11 +24680,14 @@ bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
 
  which produces a pretty compact eps file which is free from compression
  artifacts.
-\layout Comment
+\layout Standard
 
 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
  as this broke the build system on Sourceforge (pdf-file was broken.
  pdflatex does not accept eps files).
+\end_inset 
+
+
 \layout Standard
 
 The 
@@ -22504,7 +24765,22 @@ and DDD was invoked with
 \newline 
 
 \newline 
-ddd -debugger 'sdcdb -cpu 8032 ddd_example'
+ddd -debugger "sdcdb -cpu 8032 ddd_example"
+\layout Standard
+
+
+\begin_inset Note
+collapsed false
+
+\layout Standard
+
+Check that the double quotes or an apostroph within the command line survive
+ the LyX tool chain.
+ Previously the apostrophs got slanted in the PDF output so a cut and paste
+ did not work.
+\end_inset 
+
+
 \layout Subsection
 
 Interfacing SDCDB with XEmacs
@@ -22577,7 +24853,7 @@ sdcdbsrc-serial nil
 
 The following is a list of key mapping for the debugger interface.
 \layout Standard
-
+\pagebreak_bottom 
 \SpecialChar ~
 
 \family typewriter 
@@ -23352,7 +25628,7 @@ Toggle list mode
 \newline 
 
 \layout Chapter
-\pagebreak_top 
+
 TIPS
 \layout Standard
 
@@ -23498,70 +25774,6 @@ Declare the variables to be local
  whenever possible, especially loop control variables (induction).
 \layout Itemize
 
-Since the compiler does not always do implicit integral promotion, the programme
-r should do an explicit cast when integral promotion is required.
-\layout Itemize
-
-Reducing the size of division, multiplication & modulus operations can reduce
- code size substantially.
- Take the following code for example.
-\begin_deeper 
-\layout Verse
-
-
-\family typewriter 
-foobar(unsigned int p1, unsigned char ch)
-\newline 
-{
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-unsigned char ch1 = p1 % ch ;
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-....
-\newline 
-}
-\layout Standard
-
-For the modulus operation the variable ch will be promoted to unsigned int
- first then the modulus operation will be performed (this will lead to a
- call to support routine _moduint()), and the result will be casted to a
- char.
- If the code is changed to 
-\layout Verse
-
-
-\family typewriter 
-foobar(unsigned int p1, unsigned char ch)
-\newline 
-{
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-unsigned char ch1 = (unsigned char)p1 % ch ;
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-....
-\newline 
-}
-\layout Standard
-
-It would substantially reduce the code generated (future versions of the
- compiler will be smart enough to detect such optimization opportunities).
-\end_deeper 
-\layout Itemize
-
 Have a look at the assembly listing to get a 
 \begin_inset Quotes sld
 \end_inset 
@@ -23779,6 +25991,8 @@ Tools
 
 \layout Standard
 
+
+\series bold 
 Name
 \end_inset 
 </cell>
@@ -23787,6 +26001,8 @@ Name
 
 \layout Standard
 
+
+\series bold 
 Purpose
 \end_inset 
 </cell>
@@ -23795,6 +26011,8 @@ Purpose
 
 \layout Standard
 
+
+\series bold 
 Directory
 \end_inset 
 </cell>
@@ -23805,7 +26023,12 @@ Directory
 
 \layout Standard
 
-ucSsim
+uCsim
+\begin_inset LatexCommand \index{uCsim}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -24193,14 +26416,16 @@ Documentation
 \begin_inset  Tabular
 <lyxtabular version="3" rows="10" columns="2">
 <features>
-<column alignment="left" valignment="top" leftline="true" width="0">
-<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
-<row topline="true" bottomline="true">
+<column alignment="block" valignment="top" leftline="true" width="40col%">
+<column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
+<row topline="true" bottomline="true" endhead="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+
+\series bold 
 Subject / Title
 \end_inset 
 </cell>
@@ -24209,7 +26434,9 @@ Subject / Title
 
 \layout Standard
 
-Where to get / filename
+
+\series bold 
+Filename / Where to get
 \end_inset 
 </cell>
 </row>
@@ -24228,6 +26455,22 @@ SDCC Compiler User Guide
 \layout Standard
 
 You're reading it right now
+\emph on 
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24246,6 +26489,22 @@ Changelog of SDCC
 \layout Standard
 
 sdcc/Changelog
+\emph on 
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24265,7 +26524,9 @@ ASXXXX
 
 \end_inset 
 
- Assemblers and ASLINK
+ Assemblers and
+\newline 
+ASLINK
 \begin_inset LatexCommand \index{aslink}
 
 \end_inset 
@@ -24283,7 +26544,23 @@ ASXXXX
 
 \layout Standard
 
-sdcc/as/doc/asxhtm.html
+sdcc/as/doc/asxhtm.html 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24306,7 +26583,23 @@ SDCC regression test
 
 \layout Standard
 
-sdcc/doc/test_suite_spec.pdf
+sdcc/doc/test_suite_spec.pdf 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24324,7 +26617,23 @@ Various notes
 
 \layout Standard
 
-sdcc/doc/*
+sdcc/doc/* 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24347,7 +26656,23 @@ Notes on debugging with SDCDB
 
 \layout Standard
 
-sdcc/debugger/README
+sdcc/debugger/README 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at
+\emph default 
+:
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24357,7 +26682,12 @@ sdcc/debugger/README
 
 \layout Standard
 
-Software simulator for microcontrollers
+uCsim
+\begin_inset LatexCommand \index{uCsim}
+
+\end_inset 
+
+ Software simulator for microcontrollers
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -24382,8 +26712,23 @@ sdcc/sim/ucsim/doc
 \emph default 
 \bar default 
 \noun default 
-\color default
-/index.html
+/index.html 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24406,7 +26751,23 @@ Temporary notes on the pic16
 
 \layout Standard
 
-sdcc/src/pic16/NOTES
+sdcc/src/pic16/NOTES 
+\emph on 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\newline 
+
+\emph default 
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24441,8 +26802,23 @@ cdbfileformat.pd
 \emph default 
 \bar default 
 \noun default 
-\color default
 f
+\emph on 
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill 
+online at:
+\emph default 
+
+\newline 
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
+
+\end_inset 
+
+
 \end_inset 
 </cell>
 </row>
@@ -24481,6 +26857,8 @@ Related open source tools
 
 \layout Standard
 
+
+\series bold 
 Name
 \end_inset 
 </cell>
@@ -24489,6 +26867,8 @@ Name
 
 \layout Standard
 
+
+\series bold 
 Purpose
 \end_inset 
 </cell>
@@ -24497,6 +26877,8 @@ Purpose
 
 \layout Standard
 
+
+\series bold 
 Where to get
 \end_inset 
 </cell>
@@ -24967,7 +27349,7 @@ Related documentation / recommended reading
 <lyxtabular version="3" rows="7" columns="3">
 <features>
 <column alignment="left" valignment="top" leftline="true" width="0pt">
-<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
 <row topline="true" bottomline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
@@ -24975,6 +27357,8 @@ Related documentation / recommended reading
 
 \layout Standard
 
+
+\series bold 
 Name
 \end_inset 
 </cell>
@@ -24983,6 +27367,8 @@ Name
 
 \layout Standard
 
+
+\series bold 
 Subject / Title
 \end_inset 
 </cell>
@@ -24991,6 +27377,8 @@ Subject / Title
 
 \layout Standard
 
+
+\series bold 
 Where to get
 \end_inset 
 </cell>
@@ -25245,6 +27633,7 @@ s or correctness of the application notes
 \layout Standard
 
 
+\series bold 
 \size footnotesize 
 Vendor
 \end_inset 
@@ -25255,6 +27644,7 @@ Vendor
 \layout Standard
 
 
+\series bold 
 \size footnotesize 
 Subject / Title
 \end_inset 
@@ -25265,6 +27655,7 @@ Subject / Title
 \layout Standard
 
 
+\series bold 
 \size footnotesize 
 Where to get
 \end_inset 
@@ -25986,18 +28377,27 @@ web site or at
 \end_inset 
 
 .
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 I did insert a reference to Paul's web site here although it seems rather
  dedicated to a specific 8032 board (I think it's okay because it f.e.
  shows LCD/Harddisc interface and has a free 8051 monitor.
  Independent 8032 board vendors face hard competition of heavily subsidized
  development boards anyway).
-\layout Comment
+\layout Standard
 
 Maybe we should include some links to real world applications.
  Preferably pointer to pointers (one for each architecture) so this stays
  manageable here?
+\end_inset 
+
+
 \layout Section
 
 Quality control
@@ -26226,11 +28626,11 @@ give back to the public as you are probably at least partially publically
 give students a chance to publically prove their skills and to possibly
  see a world wide impact
 \layout Standard
-
+\pagebreak_bottom 
 then SDCC is probably among the first choices.
  Well, probably SDCC might be the only choice.
 \layout Chapter
-\pagebreak_top 
+
 SDCC Technical Data
 \layout Section
 
@@ -27314,13 +29714,22 @@ case 107: ...
 
 then both the switch statements will be implemented using jump-tables whereas
  the unmodified switch statement will not be.
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 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).
+\end_inset 
+
+
 \layout Standard
 
 The pragma nojtbound
@@ -31464,7 +33873,13 @@ src/mcs51/gen.c
 \end_inset 
 
 
-\layout Comment
+\layout Standard
+
+
+\begin_inset Note
+collapsed true
+
+\layout Standard
 
 In the original article Figure II was announced to be downloadable on 
 \shape italic 
@@ -31472,6 +33887,9 @@ Circuit Cellar
 \shape default 
 's web site.
  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
+\end_inset 
+
+
 \layout Paragraph*
 
 ICode Example