]> git.gag.com Git - fw/sdcc/blobdiff - doc/sdccman.lyx
* device/lib/mcs51/crtcall.asm: new, added for indirect calls
[fw/sdcc] / doc / sdccman.lyx
index eb16337ed11ee2e862c4ece108fe103efdf91ed1..2972e85fc97895efe16a89afbc8ec9eefb710431 100644 (file)
 \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
@@ -89,9 +98,18 @@ SDCC 2.6.4
 $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
 
 
@@ -2214,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}
 
@@ -2227,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">
@@ -3317,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 ~
@@ -5896,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
 
@@ -5920,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
 
@@ -8255,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
@@ -13027,232 +13112,141 @@ 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()}
-
-\end_inset 
-
-
-\series bold 
-\emph default 
-\series default 
-at the start of the CODE area.
- This routine is in the runtime library
+The compiler triggers the linker to link certain initialization modules
+ from the runtime library
 \begin_inset LatexCommand \index{Runtime library}
 
 \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}
-
-\end_inset 
-
-.
- On some mcs51 variants xdata
-\begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
-
-\end_inset 
-
- memory has to be explicitly enabled before it can be accessed or if the
- watchdog
-\begin_inset LatexCommand \index{watchdog}
+ 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
 
-\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
+\family typewriter 
+\series bold 
+\size footnotesize 
+(main.asm)
+\layout Verse
 
-\layout Standard
 
-\backslash 
-/
-\end_inset 
+\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
 
--iram-size
-\begin_inset LatexCommand \index{-\/-iram-size <Value>}
 
-\end_inset 
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtstart.asm)
+\layout Verse
 
-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
+\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
 
-\backslash 
-/
-\end_inset 
 
--no-xinit
-\emph default 
--
-\emph on 
-opt
-\emph default 
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtxstack.asm)
+\layout Verse
 
-\begin_inset LatexCommand \index{-\/-no-xinit-opt}
 
-\end_inset 
+\family typewriter 
+\size footnotesize 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\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 ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov __XPAGE,#(__start__xstack >> 8)
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov _spx,#__start__xstack
+\layout Verse
 
-, 
-\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 
--
-\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 
+\series bold 
+\size footnotesize 
+(crtstart.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 ~
@@ -13261,6 +13255,8 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+.area GSINIT2 (CODE)
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13269,12 +13265,7 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* if interrupts
-\begin_inset LatexCommand \index{interrupt}
-
-\end_inset 
-
- are involved see
+lcall __sdcc_external_startup
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13284,12 +13275,19 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov a,dpl
+\newline 
+\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+jz __sdcc_init_data
+\newline 
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13297,6 +13295,21 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+ljmp __sdcc_program_startup
+\newline 
+__sdcc_init_data:
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtxinit.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13305,6 +13318,10 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+.area GSINIT3 (CODE)
+\newline 
+__mcs51_genXINIT::
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13313,6 +13330,8 @@ unsigned char head, tail;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov r1,#l_XINIT
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13321,55 +13340,17 @@ unsigned char head, tail;\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 
-{
+mov a,r1
 \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
-
-
-\series bold 
 \SpecialChar ~
-!
-\end_inset 
-
-
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+orl a,#(l_XINIT >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13379,7 +13360,8 @@ collapsed true
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-buf[ head++ ] = c;\SpecialChar ~
+jz 00003$
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13388,6 +13370,8 @@ buf[ head++ ] = c;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov r2,#((l_XINIT+255) >> 8)
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13395,249 +13379,207 @@ 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.
+\SpecialChar ~
+mov dptr,#s_XINIT
 \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 ~
+mov r0,#s_XISEG
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-r2,dpl 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov __XPAGE,#(s_XISEG >> 8)
 \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 */
+00001$:\SpecialChar ~
+clr a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-a,_tail 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+movc a,@a+dptr
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dec\SpecialChar ~
 \SpecialChar ~
-a 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+movx @r0,a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-r3,a 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc dptr
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-a,_head 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc r0
 \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 
-
-
+cjne r0,#0,00002$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-r3,_head 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+inc __XPAGE
+\newline 
+00002$:\SpecialChar ~
+djnz r1,00001$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-inc\SpecialChar ~
 \SpecialChar ~
-_head 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+djnz r2,00001$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-dpl,r3 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov __XPAGE,#0xFF
 \newline 
+00003$:
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtclear.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-dph,#(_buf >> 8) 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area GSINIT4 (CODE)
+\newline 
+__mcs51_genRAMCLEAR::
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
 \SpecialChar ~
-a,r2 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+clr a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-movx @dptr,a 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov r0,#(l_IRAM-1)
 \newline 
-00103$: 
+00004$:\SpecialChar ~
+mov @r0,a
 \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 
-
-;
+djnz r0,00004$
 \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:
+; _mcs51_genRAMCLEAR() end
 \layout Verse
 
 
 \family typewriter 
+\series bold 
 \size footnotesize 
-unsigned char __far __at(0x7f00) buf[0x100];
-\newline 
-unsigned char head, tail;
-\newline 
-#define USE_ASSEMBLY (1)
-\newline 
+(crtxclear.asm)
+\layout Verse
 
-\newline 
-#if !USE_ASSEMBLY
-\newline 
 
+\family typewriter 
+\size footnotesize 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area GSINIT4 (CODE)
 \newline 
-void to_buffer( unsigned char c )
-\newline 
-{
+__mcs51_genXRAMCLEAR::
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-if( head != (unsigned char)(tail-1) )
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov r0,#l_PSEG
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13647,41 +13589,27 @@ if( head != (unsigned char)(tail-1) )
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-buf[ head++ ] = c;
-\newline 
-}
-\newline 
-
-\newline 
-#else
-\newline 
-
-\newline 
-void to_buffer( unsigned char c )
-\newline 
-{
+mov a,r0
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-c; // to avoid warning: unreferenced function argument
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+jz 00006$
 \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,#s_PSEG
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13691,8 +13619,7 @@ _asm
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; save used registers here.
+mov __XPAGE,#(s_PSEG >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13702,10 +13629,10 @@ _asm
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; If we were still using r2,r3 we would have to push them here.
+clr a
 \newline 
-; if( head != (unsigned char)(tail-1) )
+00005$:\SpecialChar ~
+movx @r1,a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13715,8 +13642,7 @@ _asm
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
- a,_tail
+inc r1
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13726,8 +13652,9 @@ mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dec\SpecialChar ~
- a
+djnz r0,00005$
+\newline 
+00006$:
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13737,8 +13664,7 @@ dec\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-xrl\SpecialChar ~
- a,_head
+mov r0,#l_XSEG
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13748,7 +13674,7 @@ xrl\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; we could do an ANL a,#0x0f here to use a smaller buffer (see below)
+mov a,r0
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13758,9 +13684,7 @@ xrl\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-jz\SpecialChar ~
-\SpecialChar ~
- t_b_end$
+orl a,#(l_XSEG >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13770,9 +13694,7 @@ jz\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-;
-\newline 
-; buf[ head++ ] = c;
+jz 00008$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13782,29 +13704,30 @@ jz\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
- a,dpl \SpecialChar ~
+mov r1,#((l_XSEG + 255) >> 8)
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; dpl holds lower byte of function argument
-\newline 
 \SpecialChar ~
 \SpecialChar ~
+mov dptr,#s_XSEG
+\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
+clr a
+\newline 
+00007$:\SpecialChar ~
+movx @dptr,a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13814,8 +13737,7 @@ mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
- dph,#(_buf>>8)
+inc dptr
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13825,7 +13747,7 @@ mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-movx @dptr,a
+djnz r0,00007$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13835,9 +13757,21 @@ movx @dptr,a
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-inc \SpecialChar ~
-_head
+djnz r1,00007$
 \newline 
+00008$:
+\layout Verse
+
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(crtxstack.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -13846,9 +13780,11 @@ _head
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; we could do an ANL _head,#0x0f here to use a smaller buffer (see above)
+.area GSINIT5 (CODE)
 \newline 
-t_b_end$:
+; Need to initialize in GSINIT5 because __mcs51_genXINIT modifies __XPAGE
+\newline 
+; and __mcs51_genRAMCLEAR modifies _spx.
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -13858,94 +13794,195 @@ t_b_end$:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-; restore used registers here 
+mov __XPAGE,#(__start__xstack >> 8)
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_endasm
-\begin_inset LatexCommand \index{\_endasm}
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov _spx,#__start__xstack
+\layout Verse
 
-\end_inset 
 
+\family typewriter 
+\series bold 
+\size footnotesize 
+(application modules)
+\layout Verse
 
-\begin_inset LatexCommand \index{\_\_endasm}
 
-\end_inset 
+\family typewriter 
+\size footnotesize 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area GSINIT (CODE)
+\layout Verse
 
-;
+
+\family typewriter 
+\series bold 
+\size footnotesize 
+(main.asm)
+\layout Verse
+
+
+\family typewriter 
+\size footnotesize 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area GSFINAL (CODE)
 \newline 
-}
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ljmp __sdcc_program_startup
 \newline 
-#endif
+;--------------------------------------------------------
+\newline 
+; Home
+\newline 
+;--------------------------------------------------------
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area HOME (CODE)
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+.area CSEG (CODE)
+\newline 
+__sdcc_program_startup:
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+lcall _main
+\newline 
+; return from main will lock up
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+sjmp .
 \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)}
+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 
 
 
-\begin_inset LatexCommand \index{Assembler documentation}
+\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 
 
- or online at 
-\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
+ 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}
 
 \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}
+ On some mcs51 variants xdata
+\begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
 
 \end_inset 
 
- ...
- _endasm
-\size footnotesize 
-
-\begin_inset LatexCommand \index{\_endasm}
+ 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 
+-
+\begin_inset ERT
+status Collapsed
 
-\begin_inset LatexCommand \index{\_\_endasm}
+\layout Standard
 
+\backslash 
+/
 \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}
+-iram-size
+\begin_inset LatexCommand \index{-\/-iram-size <Value>}
 
 \end_inset 
 
- has to be done manually.
+n
+\emph default 
+ is used.
+ (recommended for Chipcon CC1010).
 \layout Standard
-
-It is recommended that each assembly instruction (including labels) be placed
- in a separate line (as the example shows).
- When the -
+\added_space_bottom bigskip 
+See also the compiler options 
+\emph on 
+-
 \begin_inset ERT
 status Collapsed
 
@@ -13955,438 +13992,376 @@ status Collapsed
 /
 \end_inset 
 
+-no-xinit
+\emph default 
 -
 \emph on 
-peep-asm
-\begin_inset LatexCommand \index{-\/-peep-asm}
+opt
+\emph default 
+
+\begin_inset LatexCommand \index{-\/-no-xinit-opt}
 
 \end_inset 
 
+, 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
 
-\emph default 
- command line option is used, the inline assembler code will be passed through
- the peephole optimizer
-\begin_inset LatexCommand \index{Peephole optimizer}
+\layout Standard
 
+\backslash 
+/
 \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
+-main-return
 \emph default 
- before using this option.
-\layout Subsection
 
-Naked Functions
-\begin_inset LatexCommand \label{sub:Naked-Functions}
+\begin_inset LatexCommand \index{-\/-main-return}
 
 \end_inset 
 
-
-\begin_inset LatexCommand \index{Naked functions}
+ and section 
+\begin_inset LatexCommand \ref{sub:MCS51-variants}
 
 \end_inset 
 
+ about MCS51-variants.
+\layout Subsection
 
+HC08 Startup Code
 \layout Standard
-
-A special keyword may be associated with a function declaring it as 
-\emph on 
-_naked
-\begin_inset LatexCommand \index{\_naked}
+\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
 
-\begin_inset LatexCommand \index{\_\_naked}
+Z80 Startup Code
+\layout Standard
+\added_space_bottom bigskip 
+On the Z80
+\begin_inset LatexCommand \index{Z80}
 
 \end_inset 
 
-.
-\emph default 
-The 
+ 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 
-_naked
+-
+\series bold 
 \emph default 
- function modifier attribute prevents the compiler from generating prologue
-\begin_inset LatexCommand \index{function prologue}
 
-\end_inset 
+\begin_inset ERT
+status Collapsed
 
- and epilogue
-\begin_inset LatexCommand \index{function epilogue}
+\layout Standard
 
+\backslash 
+/
 \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 
+
+\series default 
 \emph on 
-return
+-no-std-crt0
 \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
 
+\begin_inset LatexCommand \index{-\/-no-std-crt0}
 
-\family typewriter 
-volatile
-\begin_inset LatexCommand \index{volatile}
+\end_inset 
+
+ and provide your own crt0.o.
+\layout Section
+
+Inline Assembler Code
+\begin_inset LatexCommand \index{Assembler routines}
 
 \end_inset 
 
- data unsigned char counter;
-\newline 
 
-\newline 
-void simpleInterrupt(void) __interrupt
-\begin_inset LatexCommand \index{interrupt}
+\layout Subsection
+
+A Step by Step Introduction
+\begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
 
 \end_inset 
 
 
-\begin_inset LatexCommand \index{\_\_interrupt}
+\layout Standard
 
-\end_inset 
+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
 
- (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}
+\family typewriter 
+\size footnotesize 
+unsigned char __far
+\begin_inset LatexCommand \index{far (storage class)}
 
 \end_inset 
 
 
-\begin_inset LatexCommand \index{\_\_asm}
+\begin_inset LatexCommand \index{\_\_far (storage class)}
 
 \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}
+ __at
+\begin_inset LatexCommand \index{at}
 
 \end_inset 
 
 
-\begin_inset LatexCommand \index{\_\_endasm}
+\begin_inset LatexCommand \index{\_\_at}
 
 \end_inset 
 
-;
-\newline 
-}
-\layout Standard
-
-For an 8051 target, the generated simpleInterrupt looks like:
-\layout Verse
+(0x7f00) buf[0x100];
+\begin_inset LatexCommand \index{Aligned array}
 
+\end_inset 
 
-\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 ~
+unsigned char head, tail;\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
+/* if interrupts
+\begin_inset LatexCommand \index{interrupt}
+
+\end_inset 
+
+ are involved see
 \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
+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 ~
-pop\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
+
+
+\series bold 
 \SpecialChar ~
+!
+\end_inset 
+
+
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dpl
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop\SpecialChar ~
 \SpecialChar ~
+buf[ head++ ] = c;\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-b
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-acc
-\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-reti
+/* access to a 256 byte aligned array */
+\newline 
+} 
 \layout Standard
 
-whereas nakedInterrupt looks like:
+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 
-_nakedInterrupt:
+\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 ~
-inc\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_counter ; does not change flags, no need to save psw
+_asm
+\begin_inset LatexCommand \index{\_asm}
+
+\end_inset 
+
+
+\begin_inset LatexCommand \index{\_\_asm}
+
+\end_inset 
+
+
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-reti\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
+mov\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}
+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{\_\_asm}
+\begin_inset LatexCommand \index{type promotion}
 
 \end_inset 
 
+ to integer */
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 mov\SpecialChar ~
 \SpecialChar ~
+a,_tail 
+\newline 
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-b,#10 
+dec\SpecialChar ~
+\SpecialChar ~
+a 
 \newline 
-00001$: 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+r3,a 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-djnz\SpecialChar ~
+mov\SpecialChar ~
+\SpecialChar ~
+a,_head 
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-b,00001$ 
+\SpecialChar ~
+cjne a,ar3,00106$ 
 \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 ~
+\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 
 
- defined by the inline assembler, e.g.:
-\layout Verse
-
 
-\family typewriter 
-foo() { 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* some c code */ 
-\newline 
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
+mov\SpecialChar ~
 \SpecialChar ~
-_asm 
+r3,_head 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+inc\SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-; some assembler code 
+_head 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
+mov\SpecialChar ~
 \SpecialChar ~
-\SpecialChar ~
-ljmp $0003 
+dpl,r3 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_endasm; 
+mov\SpecialChar ~
+\SpecialChar ~
+dph,#(_buf >> 8) 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-/* some more c code */ 
-\newline 
-clabel:\SpecialChar ~
+mov\SpecialChar ~
 \SpecialChar ~
-/* inline assembler cannot reference this label */ 
+a,r2 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-_asm
+movx @dptr,a 
+\newline 
+00103$: 
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-$0003: ;label (can be referenced by inline assembler only) 
+ret
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14507,145 +14484,120 @@ _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 
-
+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
 
-\layout Subsection
 
-Global Registers used for Parameter Passing
-\begin_inset LatexCommand \index{Parameter passing}
+\family typewriter 
+\size footnotesize 
+unsigned char __far __at(0x7f00) buf[0x100];
+\newline 
+unsigned char head, tail;
+\newline 
+#define USE_ASSEMBLY (1)
+\newline 
 
-\end_inset 
+\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 
 
-\layout Standard
+\newline 
+#else
+\newline 
 
-The compiler always uses the global registers 
-\emph on 
-DPL, DPH
-\begin_inset LatexCommand \index{DPTR, DPH, DPL}
+\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{DPTR}
+\begin_inset LatexCommand \index{\_\_asm}
 
 \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 
-
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+; save used registers here.
 \newline 
-int main()
+\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 ~
-return c_func(10,9);
-\newline 
-}
-\layout Standard
-
-The corresponding assembler function is:
-\layout Verse
-
-
-\family typewriter 
-.globl _asm_func_PARM_2 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+mov\SpecialChar ~
+ a,_tail
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14655,7 +14607,8 @@ The corresponding assembler function is:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-.globl _asm_func 
+dec\SpecialChar ~
+ a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14665,9 +14618,18 @@ The corresponding assembler function is:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-.area OSEG 
+xrl\SpecialChar ~
+ a,_head
 \newline 
-_asm_func_PARM_2:
+\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 ~
@@ -14677,7 +14639,9 @@ _asm_func_PARM_2:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-.ds    1 
+jz\SpecialChar ~
+\SpecialChar ~
+ t_b_end$
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14687,9 +14651,9 @@ _asm_func_PARM_2:
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-.area CSEG 
+;
 \newline 
-_asm_func: 
+; buf[ head++ ] = c;
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14700,12 +14664,15 @@ _asm_func:
 \SpecialChar ~
 \SpecialChar ~
 mov\SpecialChar ~
+ a,dpl \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-a,dpl 
-\newline 
 \SpecialChar ~
+; dpl holds lower byte of function argument
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
@@ -14713,11 +14680,12 @@ a,dpl
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-add\SpecialChar ~
 \SpecialChar ~
+mov\SpecialChar ~
+ dpl,_head \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-a,_asm_func_PARM_2 
+; buf is 0x100 byte aligned so head can be used directly
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14728,10 +14696,17 @@ a,_asm_func_PARM_2
 \SpecialChar ~
 \SpecialChar ~
 mov\SpecialChar ~
+ dph,#(_buf>>8)
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dpl,a 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+movx @dptr,a
 \newline 
 \SpecialChar ~
 \SpecialChar ~
@@ -14741,16 +14716,20 @@ dpl,a
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov\SpecialChar ~
+inc \SpecialChar ~
+_head
+\newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-dph
-\begin_inset LatexCommand \index{DPTR, DPH, DPL}
-
-\end_inset 
-
-,#0x00 
+\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 ~
-ret
-\layout Standard
+; restore used registers here 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+_endasm
+\begin_inset LatexCommand \index{\_endasm}
+
+\end_inset 
 
-Note here that the return values
-\begin_inset LatexCommand \index{return value}
+
+\begin_inset LatexCommand \index{\_\_endasm}
 
 \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.
+;
+\newline 
+}
+\newline 
+#endif
 \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 
+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)}
 
-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 
+\begin_inset LatexCommand \index{Assembler documentation}
 
- for two bytes, 
-\begin_inset Quotes eld
 \end_inset 
 
-b,dptr
-\begin_inset Quotes erd
-\end_inset 
+ or online at 
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
 
- for three bytes and 
-\begin_inset Quotes eld
 \end_inset 
 
-acc,b,dptr
-\begin_inset Quotes erd
+\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 
 
- 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 
+\begin_inset LatexCommand \index{\_\_asm}
 
-\newline 
+\end_inset 
 
-\family sans 
-\series bold 
-asx8051 -losg asmfunc.asm
-\newline 
+ ...
+ _endasm
+\size footnotesize 
 
-\newline 
+\begin_inset LatexCommand \index{\_endasm}
 
-\family default 
-\series default 
-Then compile and link the assembler routine to the C source file with the
- following command:
-\newline 
+\end_inset 
 
-\newline 
 
-\family sans 
-\series bold 
-sdcc cfunc.c asmfunc.rel
-\layout Subsection
+\begin_inset LatexCommand \index{\_\_endasm}
 
-Assembler Routine (reentrant)
+\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
 
-In this case
-\begin_inset LatexCommand \index{reentrant}
+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}
 
-\begin_inset LatexCommand \index{Assembler routines (reentrant)}
+\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 
 
- the second parameter
-\begin_inset LatexCommand \index{function parameter}
+.
+ 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 
 
- 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:
+
+\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 
-extern int asm_func(unsigned char, unsigned char);
+volatile
+\begin_inset LatexCommand \index{volatile}
+
+\end_inset 
+
+ data unsigned char counter;
 \newline 
 
 \newline 
-int c_func (unsigned char i, unsigned char j) reentrant 
+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 ~
-return asm_func(i,j); 
+counter++;
 \newline 
-} 
+}
 \newline 
 
 \newline 
-int main() 
+void nakedInterrupt(void) __interrupt (2) __naked
 \newline 
-{ 
+{
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-return c_func(10,9); 
+_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
 
-The corresponding assembler routine is:
+For an 8051 target, the generated simpleInterrupt looks like:
 \layout Verse
 
 
 \family typewriter 
-.globl _asm_func 
+Note, this is an 
+\emph on 
+outdated
+\emph default 
+ example, recent versions of SDCC generate
 \newline 
-_asm_func: 
+the 
+\emph on 
+same
+\emph default 
+ code for simpleInterrupt() and nakedInterrupt()!
+\newline 
+
+\newline 
+_simpleInterrupt:
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-push  _bp 
-\newline 
-\SpecialChar ~
+push\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov _bp,sp 
+acc
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov r2,dpl
-\newline 
-\SpecialChar ~
+push\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov a,_bp 
+b
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-add a,#0xfd 
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dpl
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov r0,a 
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+dph
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-add  a,#0xfc ;?
+push\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+psw
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov  r1,a 
-\newline 
+mov\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov  a,@r0 
+psw,#0x00
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-add  a,r2 ;?
-\newline 
+inc\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov  dpl,a 
+_counter
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov  dph,#0x00 
-\newline 
+pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-mov  sp,_bp 
+psw
 \newline 
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-pop  _bp 
-\newline 
+pop\SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
 \SpecialChar ~
-ret
+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 
+
+.
+ 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 
+
+
+\layout Standard
+
+
+\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 Paragraph
+
+getchar(), putchar()
+\layout Standard
+
+
+\begin_inset LatexCommand \index{<stdio.h>}
+
+\end_inset 
+
+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 
+putchar()
+\begin_inset LatexCommand \index{putchar()}
+
+\end_inset 
+
+
+\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 
+void putchar (char c) { 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+while (!TI)\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ /* assumes UART is initialized */
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+;
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+TI = 0;
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+SBUF = c;
+\newline 
+}
+\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
-\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)}
+\backslash 
+/
+\end_inset 
+
+DUSE_FLOATS=1
+\begin_inset LatexCommand \index{USE\_FLOATS}
 
 \end_inset 
 
- and long (32 bit)
-\begin_inset LatexCommand \index{long (32 bit)}
+
+\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 
 
- Support
+
+\emph default 
+ for the mcs51 port, since this uses a lot of memory.
 \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.
+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 
 
 \layout Standard
-\align center 
+
+Feature matrix of different 
+\emph on 
+printf
+\emph default 
+ options on mcs51.
+\layout Standard
+
 
 \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">
+<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
+
+
+\series bold 
+\size large 
+mcs51
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+printf
+\begin_inset LatexCommand \index{printf}
+
+\end_inset 
+
+
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\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
+
+\layout Standard
+
+printf_small
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+printf_fast
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+printf_fast_f
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\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
+
+\layout Standard
+
+filename
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size scriptsize 
+printf_large.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size scriptsize 
+printf_large.c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\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
+
+
+\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
+
+
+\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
+
+\layout Standard
+
+
+\begin_inset Quotes sld
+\end_inset 
+
+Hello World
+\begin_inset Quotes srd
+\end_inset 
+
+ size
+\layout Standard
+
+small / large
+\end_inset 
+</cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-
-\series bold 
-Function
+1.7k / 2.4k
 \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
 
-
-\series bold 
-Description
+4.3k / 5.6k
 \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 
+1.2k / 1.8k
 \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
+1.3k / 1.3k
 \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 
+1.9k / 1.9k
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15085,53 +17301,52 @@ _divsint.c
 
 \layout Standard
 
- signed 16 bit division (calls _divuint)
+0.44k / 0.44k
 \end_inset 
 </cell>
 </row>
-<row topline="true">
+<row topline="true" endhead="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-_divuint.c 
+code size
+\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
 
- unsigned 16 bit division
+1.4k / 2.0k
 \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
+2.8k / 3.7k
 \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 modulus (calls _moduint)
+0.45k / 0.47k (+ _ltoa)
 \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
+1.2k / 1.2k
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15139,71 +17354,143 @@ _moduint.c
 
 \layout Standard
 
-unsigned 16 bit modulus
+1.6k / 1.6k
 \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
 
-_mullong.c
+0.26k / 0.26k
 \end_inset 
 </cell>
-<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-32 bit multiplication
+formats
 \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 
+cdi
+\emph on 
+o
+\emph default 
+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 32 division (calls _divulong)
+
+\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>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-_divulong.c 
+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>
-<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 division
+cdsux
 \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
 
-_modslong.c
+cdfsux
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15211,136 +17498,124 @@ _modslong.c
 
 \layout Standard
 
- signed 32 bit modulus (calls _modulong)
+cdsux
 \end_inset 
 </cell>
 </row>
-<row topline="true" bottomline="true">
+<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
-_modulong.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 32 bit modulus
+x
 \end_inset 
 </cell>
-</row>
-</lyxtabular>
-
-\end_inset 
-
-
-\newline 
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-Since they are compiled as 
-\emph on 
-non-reentrant
-\emph default 
-
-\begin_inset LatexCommand \index{reentrant}
-
+x
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-, interrupt
-\begin_inset LatexCommand \index{interrupt}
+\layout Standard
 
+x
 \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
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
+x
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
--stack-auto
-\begin_inset LatexCommand \index{-\/-stack-auto}
-
-\end_inset 
+\layout Standard
 
 
-\emph default 
- option, after which the source program will have to be compiled with 
-\emph on 
--
-\begin_inset ERT
-status Collapsed
+\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">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
+-
 \end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
--int-long-reent
-\begin_inset LatexCommand \index{-\/-int-long-reent}
+\layout Standard
 
+byte arguments on stack
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
+\layout Standard
 
-\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}
-
+b
 \end_inset 
-
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \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 
+b
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \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">
+
+-
+\end_inset 
+</cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+-
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-Function 
+\layout Standard
+
+-
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15348,7 +17623,7 @@ Function
 
 \layout Standard
 
-Description
+-
 \end_inset 
 </cell>
 </row>
@@ -15358,88 +17633,44 @@ Description
 
 \layout Standard
 
+float format
+\begin_inset LatexCommand \index{Floating point support}
+
+\end_inset 
+
 
-\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">
+<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
-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 
+%f
 \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
-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">
@@ -15447,35 +17678,16 @@ _fsdiv.c
 
 \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
+%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
-_fsmul.c 
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15483,16 +17695,7 @@ _fsmul.c
 
 \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>
@@ -15502,88 +17705,39 @@ multiply floating point numbers
 
 \layout Standard
 
-
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_fs2uchar.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 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">
+<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">
@@ -15591,116 +17745,65 @@ _fs2uint.c
 
 \layout Standard
 
+-
+\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">
+<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
-_fs2int.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 signed int
+x
 \end_inset 
 </cell>
-</row>
-<row topline="true">
 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
 \begin_inset Text
 
 \layout Standard
 
+x
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\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
+\layout Standard
+
+-
 \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">
+<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
-_fs2long.c
+x
 \end_inset 
 </cell>
 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
@@ -15708,143 +17811,73 @@ _fs2long.c
 
 \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">
+<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
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
-\color none
-_uchar2fs.c
+\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 
-</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
+small / large
 \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
+1.52 / 2.59 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 char to floating point number
+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">
@@ -15852,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
+\layout Standard
 
-Compiler support routines (_gptrget, _mulint etc.)
-\layout Subsection
+Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
+ empty putchar()
+\end_inset 
 
-Stdclib functions (puts, printf, strcat etc.)
-\layout Subsubsection
+,
+\layout Standard
+
+small / large
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-<stdio.h>
 \layout Standard
 
+5.37 / 6.31 ms
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
-\begin_inset LatexCommand \index{<stdio.h>}
+\layout Standard
 
+5.37 / 6.31 ms
 \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
 
+8.71 / 40.65 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
 
+0.40 / 0.40 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()}
-
+0.40 / 0.40 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="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
+\end_inset 
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
-\end_inset 
+float speed
+\begin_inset Foot
+collapsed true
 
-DUSE_FLOATS=1
-\begin_inset LatexCommand \index{USE\_FLOATS}
+\layout Standard
 
+Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
+ empty putchar()
 \end_inset 
 
+,
+\layout Standard
 
-\emph default 
- on the command line.
- Use
-\emph on 
- -
-\begin_inset ERT
-status Collapsed
+small / large
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
 \layout Standard
 
-\backslash 
-/
+-
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
 
--model-large
-\begin_inset LatexCommand \index{-\/-model-large}
+\layout Standard
 
+7.49 / 22.47 ms
 \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().
+-
+\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
 
+1.04 / 1.04 ms
 \end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="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 
-
-\family default 
-and
-\family typewriter 
- printf_fast_f()
-\begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
+</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>
@@ -16177,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.)
@@ -16218,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
@@ -17726,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 (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips */
+__sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
+ XPAGE */
 \layout Verse
 
 
 \family typewriter 
-__sfr __at (0xaa) _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 a.k.a.
+ EMI0CN */
 \layout Standard
 
 For more exotic implementations further customizations may be needed.
@@ -17860,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}
 
@@ -17868,7 +19860,7 @@ The HC08 port passes the regression test suite (see section
 
 ).
 \layout Section
-\pagebreak_top 
+
 The PIC14 port
 \layout Standard
 
@@ -17930,7 +19922,7 @@ For devices that have multiple code pages it is more efficient to use the
  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
+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
 
@@ -18256,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 
@@ -18284,7 +20276,7 @@ collapsed true
 
 
 \layout Section
-\pagebreak_top 
+
 The PIC16
 \begin_inset LatexCommand \index{PIC16}
 
@@ -22670,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
@@ -22682,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 
@@ -22764,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
@@ -22837,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 
@@ -23612,7 +25628,7 @@ Toggle list mode
 \newline 
 
 \layout Chapter
-\pagebreak_top 
+
 TIPS
 \layout Standard
 
@@ -24007,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">
@@ -24661,7 +26682,12 @@ online at
 
 \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">
@@ -24686,7 +26712,6 @@ sdcc/sim/ucsim/doc
 \emph default 
 \bar default 
 \noun default 
-\color default
 /index.html 
 \emph on 
 \SpecialChar ~
@@ -24777,7 +26802,6 @@ cdbfileformat.pd
 \emph default 
 \bar default 
 \noun default 
-\color default
 f
 \emph on 
  \SpecialChar ~
@@ -26353,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
@@ -26593,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
 
@@ -27681,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
@@ -31831,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 
@@ -31839,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