+\begin_layout Standard
+PRODL:WREG
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+24 bits
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+PRODH:PRODL:WREG
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+32 bits
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+FSR0L:PRODH:PRODL:WREG
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+>32 bits
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+on stack, FSR0 points to the beginning
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Interrupts
+\end_layout
+
+\begin_layout Standard
+An interrupt
+\begin_inset LatexCommand index
+name "PIC16!interrupt"
+
+\end_inset
+
+ service routine (ISR) is declared using the
+\emph on
+interrupt
+\emph default
+ keyword.
+\end_layout
+
+\begin_layout LyX-Code
+void isr(void) interrupt
+\emph on
+n
+\end_layout
+
+\begin_layout LyX-Code
+{
+\end_layout
+
+\begin_layout LyX-Code
+...
+\end_layout
+
+\begin_layout LyX-Code
+}
+\end_layout
+
+\begin_layout Standard
+
+\emph on
+n
+\emph default
+ is the interrupt number, which for PIC18F devices can be:
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="4" columns="3">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\emph on
+n
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Interrupt Vector
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Interrupt Vector Address
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+RESET vector
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0x000000
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+HIGH priority interrupts
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0x000008
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+2
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+LOW priority interrupts
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0x000018
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+When generating assembly code for ISR the code generator places a
+\noun on
+goto
+\noun default
+instruction at the
+\emph on
+Interrupt Vector Address
+\emph default
+ which points at the generated ISR.
+ This single GOTO instruction is part of an automatically generated
+\emph on
+interrupt entry point
+\emph default
+ function.
+ The actuall ISR code is placed as normally would in the code space.
+ Upon interrupt request, the GOTO instruction is executed which jumps to
+ the ISR code.
+ When declaring interrupt functions as _naked this GOTO instruction is
+\series bold
+not
+\series default
+ generated.
+ The whole interrupt functions is therefore placed at the Interrupt Vector
+ Address of the specific interrupt.
+ This is not a problem for the LOW priority interrupts, but it is a problem
+ for the RESET and the HIGH priority interrupts because code may be written
+ at the next interrupt's vector address and cause indeterminate program
+ behaviour if that interrupt is raised.
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+This is not a problem when
+\end_layout
+
+\begin_layout Enumerate
+this is a HIGH interrupt ISR and LOW interrupts are
+\emph on
+disabled
+\emph default
+ or not used.
+\end_layout
+
+\begin_layout Enumerate
+when the ISR is small enough not to reach the next interrupt's vector address.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\emph on
+n
+\emph default
+ may be omitted.
+ This way a function is generated similar to an ISR, but it is not assigned
+ to any interrupt.
+\end_layout
+
+\begin_layout Standard
+When entering an interrupt, currently the PIC16
+\begin_inset LatexCommand index
+name "PIC16"
+
+\end_inset
+
+ port automatically saves the following registers:
+\end_layout
+
+\begin_layout Itemize
+WREG
+\end_layout
+
+\begin_layout Itemize
+STATUS
+\end_layout
+
+\begin_layout Itemize
+BSR
+\end_layout
+
+\begin_layout Itemize
+PROD (PRODL and PRODH)
+\end_layout
+
+\begin_layout Itemize
+FSR0 (FSR0L and FSR0H)
+\end_layout
+
+\begin_layout Standard
+These registers are restored upon return from the interrupt routine.
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+NOTE that when the _naked attribute is specified for an interrupt routine,
+ then NO registers are stored or restored.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Generic Pointers
+\end_layout
+
+\begin_layout Standard
+Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
+ There are 3 types of generic pointers currently implemented data, code
+ and eeprom pointers.
+ They are differentiated by the value of the 7th and 6th bits of the upper
+ byte:
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="5" columns="5">
+<features>
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" width="0">
+<column alignment="left" valignment="top" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+pointer type
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+7th bit
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+6th bit
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+rest of the pointer
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+description
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+data
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+\shape slanted
+\emph on
+uuuuuu uuuuxxxx xxxxxxxx
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+a 12-bit data pointer in data RAM memory
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+code
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+\shape slanted
+\emph on
+uxxxxx xxxxxxxx xxxxxxxx
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+a 21-bit code pointer in FLASH memory
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+eeprom
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+\shape slanted
+\emph on
+uuuuuu uuuuuuxx xxxxxxxx
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+a 10-bit eeprom pointer in EEPROM memory
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+(unimplemented)
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+\shape slanted
+\emph on
+xxxxxx xxxxxxxx xxxxxxxx
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+unimplemented pointer type
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+Generic pointer are read and written with a set of library functions which
+ read/write 1, 2, 3, 4 bytes.
+\end_layout
+
+\begin_layout Subsection
+PIC16 C Libraries
+\end_layout
+
+\begin_layout Subsubsection
+Standard I/O Streams
+\end_layout
+
+\begin_layout Standard
+In the
+\emph on
+stdio.h
+\emph default
+ the type FILE is defined as:
+\end_layout
+
+\begin_layout LyX-Code
+typedef char * FILE;
+\end_layout
+
+\begin_layout Standard
+This type is the stream type implemented I/O in the PIC18F devices.
+ Also the standard input and output streams are declared in stdio.h:
+\end_layout
+
+\begin_layout LyX-Code
+extern FILE * stdin;
+\end_layout
+
+\begin_layout LyX-Code
+extern FILE * stdout;
+\end_layout
+
+\begin_layout Standard
+The FILE type is actually a generic pointer which defines one more type
+ of generic pointers, the
+\emph on
+stream
+\emph default
+ pointer.
+ This new type has the format:
+\end_layout
+
+\begin_layout Standard
+\noindent
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="2" columns="7">
+<features>
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="center" valignment="top" width="0">
+<column alignment="left" valignment="top" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+pointer type
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+<7:6>
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+<5>
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+<4>
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+<3:0>
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+rest of the pointer
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+descrption
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+stream
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+00
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+nnnn
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+\shape slanted
+\emph on
+uuuuuuuu uuuuuuuu
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+upper byte high nubble is 0x2n, the rest are zeroes
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+Currently implemented there are 3 types of streams defined:
+\end_layout
+
+\begin_layout Standard
+\noindent
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="4" columns="4">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+stream type
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+value
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+module
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+description
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+STREAM_USART
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+0x200000UL
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+USART
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Writes/Reads characters via the USART peripheral
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+STREAM_MSSP
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+0x210000UL
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+MSSP
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Writes/Reads characters via the MSSP peripheral
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+STREAM_USER
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family typewriter
+0x2f0000UL
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+(none)
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Writes/Reads characters via used defined functions
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+The stream identifiers are declared as macros in the stdio.h header.
+\end_layout
+
+\begin_layout Standard
+\noindent
+In the libc library there exist the functions that are used to write to
+ each of the above streams.
+ These are
+\end_layout
+
+\begin_layout Description
+_
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+_stream_usart_putchar writes a character at the USART stream
+\end_layout
+
+\begin_layout Description
+_
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+_stream_mssp_putchar writes a character at the MSSP stream
+\end_layout
+
+\begin_layout Description
+putchar dummy function.
+ This writes a character to a user specified manner.
+\end_layout
+
+\begin_layout Standard
+In order to increase performance
+\emph on
+putchar
+\emph default
+ is declared in stdio.h as having its parameter in WREG (it has the wparam
+ keyword).
+ In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
+ in a user-friendly way.
+
+\emph on
+arg
+\emph default
+ is the name of the variable that holds the character to print.
+ An example follows:
+\end_layout
+
+\begin_layout LyX-Code
+#include <pic18fregs.h>
+\newline
+#include <stdio.h>
+\newline
+
+\newline
+PUTCHAR( c )
+\end_layout
+
+\begin_layout LyX-Code
+{
+\end_layout
+
+\begin_layout LyX-Code
+ PORTA = c; /* dump character c to PORTA */
+\end_layout
+
+\begin_layout LyX-Code
+}
+\newline
+
+\newline
+void main(void)
+\end_layout
+
+\begin_layout LyX-Code
+{
+\end_layout
+
+\begin_layout LyX-Code
+ stdout = STREAM_USER; /* this is not necessary, since stdout points
+\end_layout
+
+\begin_layout LyX-Code
+ * by default to STREAM_USER */
+\end_layout
+
+\begin_layout LyX-Code
+ printf (
+\begin_inset Quotes sld
+\end_inset
+
+This is a printf test
+\backslash
+n
+\begin_inset Quotes srd
+\end_inset
+
+);
+\end_layout
+
+\begin_layout LyX-Code
+}
+\end_layout
+
+\begin_layout LyX-Code
+
+\end_layout
+
+\begin_layout Subsubsection
+Printing functions
+\end_layout
+
+\begin_layout Standard
+PIC16 contains an implementation of the printf-family of functions.
+ There exist the following functions:
+\end_layout
+
+\begin_layout LyX-Code
+extern unsigned int sprintf(char *buf, char *fmt, ...);
+\end_layout
+
+\begin_layout LyX-Code
+extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
+\end_layout
+
+\begin_layout LyX-Code
+
+\end_layout
+
+\begin_layout LyX-Code
+extern unsigned int printf(char *fmt, ...);
+\end_layout
+
+\begin_layout LyX-Code
+extern unsigned int vprintf(char *fmt, va_lista ap);
+\end_layout
+
+\begin_layout LyX-Code
+
+\end_layout
+
+\begin_layout LyX-Code
+extern unsigned int fprintf(FILE *fp, char *fmt, ...);
+\end_layout
+
+\begin_layout LyX-Code
+extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
+\end_layout
+
+\begin_layout Standard
+For sprintf and vsprintf
+\emph on
+buf
+\emph default
+ should normally be a data pointer where the resulting string will be placed.
+ No range checking is done so the user should allocate the necessary buffer.
+ For fprintf and vfprintf
+\emph on
+fp
+\emph default
+ should be a stream pointer (i.e.
+ stdout, STREAM_MSSP, etc...).
+\end_layout
+
+\begin_layout Subsubsection
+Signals
+\end_layout
+
+\begin_layout Standard
+The PIC18F family of microcontrollers supports a number of interrupt sources.
+ A list of these interrupts is shown in the following table:
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="11" columns="4">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+signal name
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+description
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+signal name
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+description
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_RB
+\end_layout
+
+\end_inset
+</cell>
+<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+PORTB change interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_EE
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+EEPROM/FLASH write complete interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_INT0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+INT0 external interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_BCOL
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Bus collision interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_INT1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+INT1 external interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_LVD
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Low voltage detect interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_INT2
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+INT2 external interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_PSP
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Parallel slave port interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_CCP1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+CCP1 module interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_AD
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+AD convertion complete interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_CCP2
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+CCP2 module interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_RC
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+USART receive interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_TMR0
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+TMR0 overflow interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_TX
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+USART transmit interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_TMR1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+TMR1 overflow interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_MSSP
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SSP receive/transmit interrupt
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_TMR2
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+TMR2 matches PR2 interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SIG_TMR3
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+TMR3 overflow interrupt
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\noindent
+The prototypes for these names are defined in the header file
+\emph on
+signal.h
+\emph default
+ .
+\end_layout
+
+\begin_layout Standard
+\noindent
+In order to simplify signal handling, a number of macros is provided:
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
+ high priority interrupts.
+
+\emph on
+name
+\emph default
+ is the function name to use.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
+ low priority interrupt.
+
+\emph on
+name
+\emph default
+ is the function name to use.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+DEF_HANDLER(sig,handler) define a handler for signal
+\emph on
+sig.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+END_DEF end the declaration of the dispatch table.
+\end_layout
+
+\begin_layout Standard
+Additionally there are two more macros to simplify the declaration of the
+ signal handler:
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series medium
+SIGHANDLER(handler)
+\series default
+ this declares the function prototype for the
+\emph on
+handler
+\emph default
+ function.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
+\end_layout
+
+\begin_layout Standard
+An example of using the macros above is shown below:
+\end_layout
+
+\begin_layout LyX-Code
+#include <pic18fregs.h>
+\end_layout
+
+\begin_layout LyX-Code
+#include <signal.h>
+\newline
+
+\newline
+DEF_INTHIGH(high_int)
+\end_layout
+
+\begin_layout LyX-Code
+DEF_HANDLER(SIG_TMR0, _tmr0_handler)
+\end_layout
+
+\begin_layout LyX-Code
+DEF_HANDLER(SIG_BCOL, _bcol_handler)
+\end_layout
+
+\begin_layout LyX-Code
+END_DEF
+\newline
+
+\newline
+SIGHANDLER(_tmr0_handler)
+\end_layout
+
+\begin_layout LyX-Code
+{
+\end_layout
+
+\begin_layout LyX-Code
+ /* action to be taken when timer 0 overflows */
+\end_layout
+
+\begin_layout LyX-Code
+}
+\newline
+
+\newline
+SIGHANDLERNAKED(_bcol_handler)
+\end_layout
+
+\begin_layout LyX-Code
+{
+\end_layout
+
+\begin_layout LyX-Code
+ _asm
+\end_layout
+
+\begin_layout LyX-Code
+ /* action to be taken when bus collision occurs */
+\end_layout
+
+\begin_layout LyX-Code
+ retfie
+\end_layout
+
+\begin_layout LyX-Code
+ _endasm;
+\end_layout
+
+\begin_layout LyX-Code
+}
+\end_layout
+
+\begin_layout Standard
+
+\series bold
+NOTES:
+\series default
+ Special care should be taken when using the above scheme:
+\end_layout
+
+\begin_layout Itemize
+do not place a colon (;) at the end of the DEF_* and END_DEF macros.
+\end_layout
+
+\begin_layout Itemize
+when declaring SIGHANDLERNAKED handler never forget to use
+\emph on
+retfie
+\emph default
+ for proper returning.
+\end_layout
+
+\begin_layout Subsection
+PIC16 Port -- Tips
+\end_layout
+
+\begin_layout Standard
+Here you can find some general tips for compiling programs with SDCC/pic16.
+\end_layout
+
+\begin_layout Subsubsection
+Stack size
+\end_layout
+
+\begin_layout Standard
+The default stack
+\begin_inset LatexCommand index
+name "PIC16!stack"
+
+\end_inset
+
+ size (that is 64 bytes) probably is enough for many programs.
+ One must take care that when there are many levels of function nesting,
+ or there is excessive usage of stack, its size should be extended.
+ An example of such a case is the printf/sprintf family of functions.
+ If you encounter problems like not being able to print integers, then you
+ need to set the stack size around the maximum (256 for small stack model).
+ The following diagram shows what happens when calling printf to print an
+ integer:
+\end_layout
+
+\begin_layout LyX-Code
+printf () --> ltoa () --> ultoa () --> divschar ()
+\end_layout
+
+\begin_layout Standard
+It is should be understood that stack is easily consumed when calling complicate
+d functions.
+ Using command line arguments like -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-fommit-frame-pointer might reduce stack usage by not creating unnecessery
+ stack frames.
+ Other ways to reduce stack usage may exist.
+\end_layout
+
+\begin_layout Subsection
+Known Bugs
+\end_layout
+
+\begin_layout Subsubsection
+Extended Instruction Set
+\end_layout
+
+\begin_layout Standard
+The PIC16 port emits code which is incompatible with the extended instruction
+ set available with many newer devices.
+ Make sure to always explicitly disable it, usually using
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
+\end_layout
+
+\begin_layout Standard
+\noindent
+Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
+ instead of _XINST_OFF_4L.
+\end_layout
+
+\begin_layout Subsubsection
+Regression Tests
+\end_layout
+
+\begin_layout Standard
+The PIC16 port currently passes most but not all of the tests in SDCC's
+ regression test
+\begin_inset LatexCommand index
+name "Regression test (PIC16)"
+
+\end_inset
+
+ suite (see section
+\begin_inset LatexCommand ref
+reference "sec:Quality-control"
+
+\end_inset
+
+), thus no automatic regression tests are currently performed for the PIC16
+ target.
+\end_layout
+
+\begin_layout Chapter
+Debugging
+\end_layout
+
+\begin_layout Standard
+There are several approaches to debugging your code.
+ This chapter is meant to show your options and to give detail on some of
+ them:
+\newline
+
+\newline
+When writing your code:
+\end_layout
+
+\begin_layout Itemize
+write your code with debugging in mind (avoid duplicating code, put conceptually
+ similar variables into structs, use structured code, have strategic points
+ within your code where all variables are consistent, ...)
+\end_layout
+
+\begin_layout Itemize
+run a syntax-checking tool like splint
+\begin_inset LatexCommand index
+name "splint (syntax checking tool)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "lint (syntax checking tool)"
+
+\end_inset
+
+ (see -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-more-pedantic
+\begin_inset LatexCommand ref
+reference "lyx:more-pedantic-SPLINT"
+
+\end_inset
+
+) over the code.
+\end_layout
+
+\begin_layout Itemize
+for the high level code use a C-compiler (like f.e.
+ GCC) to compile run and debug the code on your host.
+ See (see -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-more-pedantic
+\begin_inset LatexCommand ref
+reference "lyx:more-pedantic-SPLINT"
+
+\end_inset
+
+) on how to handle syntax extensions like __xdata, __at(), ...
+
+\end_layout
+
+\begin_layout Itemize
+use another C-compiler to compile code for your target.
+ Always an option but not recommended:) And not very likely to help you.
+ If you seriously consider walking this path you should at least occasionally
+ check portability of your code.
+ Most commercial compiler vendors will offer an evaluation version so you
+ can test compile your code or snippets of your code.
+\end_layout
+
+\begin_layout Standard
+Debugging on a simulator:
+\end_layout
+
+\begin_layout Itemize
+there is a separate section about SDCDB (section
+\begin_inset LatexCommand ref
+reference "cha:Debugging-with-SDCDB"
+
+\end_inset
+
+) below.
+\end_layout
+
+\begin_layout Itemize
+or (8051 specific) use a freeware/commercial simulator which interfaces
+ to the AOMF
+\begin_inset LatexCommand index
+name "AOMF, AOMF51"
+
+\end_inset
+
+ file (see
+\begin_inset LatexCommand ref
+reference "OMF file"
+
+\end_inset
+
+) optionally generated by SDCC.
+\end_layout
+
+\begin_layout Standard
+Debugging On-target:
+\end_layout
+
+\begin_layout Itemize
+use a MCU port pin to serially output debug data to the RS232 port of your
+ host.
+ You'll probably want some level shifting device typically involving a MAX232
+ or similar IC.
+ If the hardware serial port of the MCU is not available search for 'Software
+ UART' in your favourite search machine.
+\end_layout
+
+\begin_layout Itemize
+use an on-target monitor.
+ In this context a monitor is a small program which usually accepts commands
+ via a serial line and allows to set program counter, to single step through
+ a program and read/write memory locations.
+ For the 8051 good examples of monitors are paulmon and cmon51 (see section
+
+\begin_inset LatexCommand ref
+reference "sec:Related-open-source-tools"
+
+\end_inset
+
+).
+\end_layout
+
+\begin_layout Itemize
+toggle MCU port pins at strategic points within your code and use an oscilloscop
+e.
+ A
+\emph on
+digital oscilloscope
+\emph default
+
+\begin_inset LatexCommand index
+name "Oscilloscope"
+
+\end_inset
+
+ with deep trace memory is really helpful especially if you have to debug
+ a realtime application.
+ If you need to monitor more pins than your oscilloscope provides you can
+ sometimes get away with a small R-2R network.
+ On a single channel oscilloscope you could f.e.
+ monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
+k
+\begin_inset Formula $\Omega$
+\end_inset
+
+ resistor and the other one by a 5\InsetSpace ~
+k
+\begin_inset Formula $\Omega$
+\end_inset
+
+ resistor to the oscilloscope probe (check output drive capability of the
+ pins you want to monitor).
+ If you need to monitor many more pins a
+\emph on
+logic analyzer
+\emph default
+ will be handy.
+\end_layout
+
+\begin_layout Itemize
+use an ICE (
+\emph on
+i
+\emph default
+n
+\emph on
+c
+\emph default
+ircuit
+\emph on
+e
+\emph default
+mulator
+\begin_inset LatexCommand index
+name "ICE (in circuit emulator)"
+
+\end_inset
+
+).
+ Usually very expensive.
+ And very nice to have too.
+ And usually locks you (for years...) to the devices the ICE can emulate.
+
+\end_layout
+
+\begin_layout Itemize
+use a remote debugger.
+ In most 8-bit systems the symbol information is not available on the target,
+ and a complete debugger is too bulky for the target system.
+ Therefore usually a debugger on the host system connects to an on-target
+ debugging stub which accepts only primitive commands.
+
+\newline
+Terms to enter into your favourite search engine could be 'remote debugging',
+ 'gdb stub' or 'inferior debugger'.
+ (is there one?)
+\end_layout
+
+\begin_layout Itemize
+use an on target hardware debugger.
+ Some of the more modern MCUs include hardware support for setting break
+ points and monitoring/changing variables by using dedicated hardware pins.
+ This facility doesn't require additional code to run on the target and
+
+\emph on
+usually
+\emph default
+ doesn't affect runtime behaviour until a breakpoint is hit.
+ For the mcs51 most hardware debuggers use the AOMF
+\begin_inset LatexCommand index
+name "AOMF, AOMF51"
+
+\end_inset
+
+ file (see
+\begin_inset LatexCommand ref
+reference "OMF file"
+
+\end_inset
+
+) as input file.
+
+\end_layout
+
+\begin_layout Standard
+Last not least:
+\end_layout
+
+\begin_layout Itemize
+if you are not familiar with any of the following terms you're likely to
+ run into problems rather sooner than later:
+\emph on
+volatile
+\emph default
+,
+\emph on
+atomic
+\emph default
+,
+\emph on
+memory map
+\emph default
+,
+\emph on
+overlay
+\emph default
+.
+ As an embedded programmer you
+\emph on
+have
+\emph default
+ to know them so why not look them up
+\emph on
+before
+\emph default
+ you have problems?)
+\end_layout
+
+\begin_layout Itemize
+tell someone else about your problem (actually this is a surprisingly effective
+ means to hunt down the bug even if the listener is not familiar with your
+ environment).
+ As 'failure to communicate' is probably one of the job-induced deformations
+ of an embedded programmer this is highly encouraged.
+\end_layout
+
+\begin_layout Section
+Debugging with SDCDB
+\begin_inset LatexCommand label
+name "cha:Debugging-with-SDCDB"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "SDCDB (debugger)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+SDCC is distributed with a source level debugger
+\begin_inset LatexCommand index
+name "Debugger"
+
+\end_inset
+
+.
+ The debugger uses a command line interface, the command repertoire of the
+ debugger has been kept as close to gdb
+\begin_inset LatexCommand index
+name "gdb"
+
+\end_inset
+
+ (the GNU debugger) as possible.
+ The configuration and build process is part of the standard compiler installati
+on, which also builds and installs the debugger in the target directory
+ specified during configuration.
+ The debugger allows you debug BOTH at the C source and at the ASM source
+ level.
+\end_layout
+
+\begin_layout Subsection
+Compiling for Debugging
+\end_layout
+
+\begin_layout Standard
+The -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-debug
+\begin_inset LatexCommand index
+name "-\\/-debug"
+
+\end_inset
+
+ option must be specified for all files for which debug information is to
+ be generated.
+ The compiler generates a .adb file for each of these files.
+ The linker creates the .cdb
+\begin_inset LatexCommand index
+name "<file>.cdb"
+
+\end_inset
+
+ file from the .adb
+\begin_inset LatexCommand index
+name "<file>.adb"
+
+\end_inset
+
+ files and the address information.
+ This .cdb is used by the debugger.
+\end_layout
+
+\begin_layout Subsection
+How the Debugger Works
+\end_layout
+
+\begin_layout Standard
+When the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-debug option is specified the compiler generates extra symbol information
+ some of which are put into the assembler source and some are put into the
+ .adb file.
+ Then the linker creates the .cdb file from the individual .adb files with
+ the address information for the symbols.
+ The debugger reads the symbolic information generated by the compiler &
+ the address information generated by the linker.
+ It uses the SIMULATOR (Daniel's S51) to execute the program, the program
+ execution is controlled by the debugger.
+ When a command is issued for the debugger, it translates it into appropriate
+ commands for the simulator.
+ (Currently SDCDM only connects to the simulator but
+\emph on
+newcdb
+\emph default
+ at
+\begin_inset LatexCommand url
+target "http://ec2drv.sf.net/"
+
+\end_inset
+
+ is an effort to connect directly to the hardware.)
+\end_layout
+
+\begin_layout Subsection
+Starting the Debugger SDCDB
+\end_layout
+
+\begin_layout Standard
+The debugger can be started using the following command line.
+ (Assume the file you are debugging has the file name foo).
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcdb foo
+\newline
+
+\family default
+\series default
+
+\newline
+The debugger will look for the following files.
+\end_layout
+
+\begin_layout Itemize
+foo.c - the source file.
+\end_layout
+
+\begin_layout Itemize
+foo.cdb - the debugger symbol information file.
+\end_layout
+
+\begin_layout Itemize
+foo.ihx - the Intel hex format
+\begin_inset LatexCommand index
+name "Intel hex format"
+
+\end_inset
+
+ object file.
+\end_layout
+
+\begin_layout Subsection
+SDCDB Command Line Options
+\end_layout
+
+\begin_layout Itemize
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-directory=<source file directory> this option can used to specify the directory
+ search list.
+ The debugger will look into the directory list specified for source, cdb
+ & ihx files.
+ The items in the directory list must be separated by ':', e.g.
+ if the source files can be in the directories /home/src1 and /home/src2,
+ the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-directory option should be -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-directory=/home/src1:/home/src2.
+ Note there can be no spaces in the option.
+
+\end_layout
+
+\begin_layout Itemize
+-cd <directory> - change to the <directory>.
+\end_layout
+
+\begin_layout Itemize
+-fullname - used by GUI front ends.
+\end_layout
+
+\begin_layout Itemize
+-cpu <cpu-type> - this argument is passed to the simulator please see the
+ simulator docs for details.
+\end_layout
+
+\begin_layout Itemize
+-X <Clock frequency > this options is passed to the simulator please see
+ the simulator docs for details.
+\end_layout
+
+\begin_layout Itemize
+-s <serial port file> passed to simulator see the simulator docs for details.
+\end_layout
+
+\begin_layout Itemize
+-S <serial in,out> passed to simulator see the simulator docs for details.
+\end_layout
+
+\begin_layout Itemize
+-k <port number> passed to simulator see the simulator docs for details.
+\end_layout
+
+\begin_layout Subsection
+SDCDB Debugger Commands
+\end_layout
+
+\begin_layout Standard
+As mentioned earlier the command interface for the debugger has been deliberatel
+y kept as close the GNU debugger gdb, as possible.
+ This will help the integration with existing graphical user interfaces
+ (like ddd, xxgdb or xemacs) existing for the GNU debugger.
+ If you use a graphical user interface for the debugger you can skip this
+ section.
+\end_layout
+
+\begin_layout Subsubsection*
+break [line | file:line | function | file:function]
+\end_layout
+
+\begin_layout Standard
+Set breakpoint at specified line or function:
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcdb>break 100
+\newline
+sdcdb>break foo.c:100
+\newline
+sdcdb>break funcfoo
+\newline
+sdcdb>break foo.c:funcfoo
+\end_layout
+
+\begin_layout Subsubsection*
+clear [line | file:line | function | file:function ]
+\end_layout
+
+\begin_layout Standard
+Clear breakpoint at specified line or function:
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcdb>clear 100
+\newline
+sdcdb>clear foo.c:100
+\newline
+sdcdb>clear funcfoo
+\newline
+sdcdb>clear foo.c:funcfoo
+\end_layout
+
+\begin_layout Subsubsection*
+continue
+\end_layout
+
+\begin_layout Standard
+Continue program being debugged, after breakpoint.
+\end_layout
+
+\begin_layout Subsubsection*
+finish
+\end_layout
+
+\begin_layout Standard
+Execute till the end of the current function.
+\end_layout
+
+\begin_layout Subsubsection*
+delete [n]
+\end_layout
+
+\begin_layout Standard
+Delete breakpoint number 'n'.
+ If used without any option clear ALL user defined break points.
+\end_layout
+
+\begin_layout Subsubsection*
+info [break | stack | frame | registers ]
+\end_layout
+
+\begin_layout Itemize
+info break - list all breakpoints
+\end_layout
+
+\begin_layout Itemize
+info stack - show the function call stack.
+\end_layout
+
+\begin_layout Itemize
+info frame - show information about the current execution frame.
+\end_layout
+
+\begin_layout Itemize
+info registers - show content of all registers.
+\end_layout
+
+\begin_layout Subsubsection*
+step
+\end_layout
+
+\begin_layout Standard
+Step program until it reaches a different source line.
+ Note: pressing <return> repeats the last command.
+\end_layout
+
+\begin_layout Subsubsection*
+next
+\end_layout
+
+\begin_layout Standard
+Step program, proceeding through subroutine calls.
+\end_layout
+
+\begin_layout Subsubsection*
+run
+\end_layout
+
+\begin_layout Standard
+Start debugged program.
+\end_layout
+
+\begin_layout Subsubsection*
+ptype variable
+\end_layout
+
+\begin_layout Standard
+Print type information of the variable.
+\end_layout
+
+\begin_layout Subsubsection*
+print variable
+\end_layout
+
+\begin_layout Standard
+print value of variable.
+\end_layout
+
+\begin_layout Subsubsection*
+file filename
+\end_layout
+
+\begin_layout Standard
+load the given file name.
+ Note this is an alternate method of loading file for debugging.
+\end_layout
+
+\begin_layout Subsubsection*
+frame
+\end_layout
+
+\begin_layout Standard
+print information about current frame.
+\end_layout
+
+\begin_layout Subsubsection*
+set srcmode
+\end_layout
+
+\begin_layout Standard
+Toggle between C source & assembly source.
+\end_layout
+
+\begin_layout Subsubsection*
+! simulator command
+\end_layout
+
+\begin_layout Standard
+Send the string following '!' to the simulator, the simulator response is
+ displayed.
+ Note the debugger does not interpret the command being sent to the simulator,
+ so if a command like 'go' is sent the debugger can loose its execution
+ context and may display incorrect values.
+\end_layout
+
+\begin_layout Subsubsection*
+quit
+\end_layout
+
+\begin_layout Standard
+"Watch me now.
+ Iam going Down.
+ My name is Bobby Brown"
+\end_layout
+
+\begin_layout Subsection
+Interfacing SDCDB with DDD
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+The screenshot was converted from png to eps with:
+\begin_inset Quotes sld
+\end_inset
+
+bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
+\begin_inset Quotes srd
+\end_inset
+
+ which produces a pretty compact eps file which is free from compression
+ artifacts.
+\end_layout
+
+\begin_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_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The
+\emph on
+p
+\emph default
+ortable
+\emph on
+n
+\emph default
+etwork
+\emph on
+g
+\emph default
+raphics File
+\size footnotesize
+
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png"
+
+\end_inset
+
+
+\size default
+ shows a screenshot of a debugging session with DDD
+\begin_inset LatexCommand index
+name "DDD (debugger)"
+
+\end_inset
+
+ (Unix only) on a simulated 8032.
+ The debugging session might not run as smoothly as the screenshot suggests.
+ The debugger allows setting of breakpoints, displaying and changing variables,
+ single stepping through C and assembler code.
+
+\newline
+The source was compiled with
+\family sans
+\series bold
+
+\newline
+
+\newline
+sdcc -
+\family default
+\series default
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\family sans
+\series bold
+-debug ddd_example.c
+\family default
+\series default
+
+\family sans
+\series bold
+
+\newline
+
+\family default
+\series default
+
+\newline
+and DDD was invoked with
+\family sans
+\series bold
+
+\newline
+
+\newline
+ddd -debugger "sdcdb -cpu 8032 ddd_example"
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+Check that the double quotes or an apostrophe within the command line survive
+ the LyX tool chain.
+ Previously the apostrophes got slanted in the PDF output so a cut and paste
+ did not work.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Interfacing SDCDB with XEmacs
+\begin_inset LatexCommand index
+name "XEmacs"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Emacs"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Two files (in emacs lisp) are provided for the interfacing with XEmacs,
+ sdcdb.el and sdcdbsrc.el.
+ These two files can be found in the $(prefix)/bin directory after the installat
+ion is complete.
+ These files need to be loaded into XEmacs for the interface to work.
+ This can be done at XEmacs startup time by inserting the following into
+ your '.xemacs' file (which can be found in your HOME directory):
+\newline
+
+\newline
+
+\family typewriter
+(load-file sdcdbsrc.el)
+\family default
+
+\newline
+
+\newline
+.xemacs is a lisp file so the () around the command is REQUIRED.
+ The files can also be loaded dynamically while XEmacs is running, set the
+ environment variable 'EMACSLOADPATH' to the installation bin directory
+ (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
+ To start the interface enter the following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+ESC-x sdcdbsrc
+\family default
+\series default
+
+\newline
+
+\newline
+You will prompted to enter the file name to be debugged.
+
+\newline
+
+\newline
+The command line options that are passed to the simulator directly are
+ bound to default values in the file sdcdbsrc.el.
+ The variables are listed below, these values maybe changed as required.
+\end_layout
+
+\begin_layout Itemize
+sdcdbsrc-cpu-type '51
+\end_layout
+
+\begin_layout Itemize
+sdcdbsrc-frequency '11059200
+\end_layout
+
+\begin_layout Itemize
+sdcdbsrc-serial nil
+\end_layout
+
+\begin_layout Standard
+The following is a list of key mapping for the debugger interface.
+\end_layout
+
+\begin_layout Standard
+\InsetSpace ~
+
+\family typewriter
+
+\newline
+;;\InsetSpace ~
+Current Listing ::
+\newline
+;;key\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+binding\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+Comment
+\newline
+;;---\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+-------\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+-------
+\newline
+;;
+\newline
+;;\InsetSpace ~
+n\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-next-fro
+m-src\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB next command
+\newline
+;;\InsetSpace ~
+b\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-back-from-src\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB back command
+\newline
+;;\InsetSpace ~
+c\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-cont-f
+rom-src\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB continue command
+\newline
+;;\InsetSpace ~
+s\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-step-from-src\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB step command
+\newline
+;;\InsetSpace ~
+?\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-w
+hatis-c-sexp\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB ptypecommand for data at
+\newline
+;;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+buffer point
+\newline
+;;\InsetSpace ~
+x\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdbsrc-delete\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCD
+B Delete all breakpoints if no arg
+\newline
+;;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+given or delete arg (C-u arg x)
+\newline
+;;\InsetSpace ~
+m\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdbsrc
+-frame\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB Display current frame if no arg,
+\newline
+;;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+given or display frame arg
+
+\newline
+;;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+buffer point
+\newline
+;;\InsetSpace ~
+!\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdbsrc-goto-sdcdb\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+Goto the SDCDB output buffer
+\newline
+;;\InsetSpace ~
+p\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-prin
+t-c-sexp\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB print command for data at
+\newline
+;;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+buffer point
+\newline
+;;\InsetSpace ~
+g\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdbsrc-goto-sdcdb\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+Got
+o the SDCDB output buffer
+\newline
+;;\InsetSpace ~
+t\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdbsrc-mode\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+Toggles Sdcdbsrc mode (turns it
+ off)
+\newline
+;;
+\newline
+;;\InsetSpace ~
+C-c\InsetSpace ~
+C-f\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-finish-from-src\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SDCDB finish command
+\newline
+;;
+\newline
+;;\InsetSpace ~
+C-x\InsetSpace ~
+SPC\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdb-brea
+k\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+Set break for line with point
+\newline
+;;\InsetSpace ~
+ESC\InsetSpace ~
+t\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdcdbsrc-mode\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+Toggle Sdcdbsrc mode
+\newline
+;;\InsetSpace ~
+ESC\InsetSpace ~
+m\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sdc
+dbsrc-srcmode\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+Toggle list mode
+\newline
+;;
+\newline
+
+\family default
+
+\newpage
+
+\end_layout
+
+\begin_layout Chapter
+TIPS
+\end_layout
+
+\begin_layout Standard
+Here are a few guidelines that will help the compiler generate more efficient
+ code, some of the tips are specific to this compiler others are generally
+ good programming practice.
+\end_layout
+
+\begin_layout Itemize
+Use the smallest data type to represent your data-value.
+ If it is known in advance that the value is going to be less than 256 then
+ use an 'unsigned char' instead of a 'short' or 'int'.
+ Please note, that ANSI C requires both signed and unsigned chars to be
+ promoted to 'signed int'
+\begin_inset LatexCommand index
+name "promotion to signed int"
+
+\end_inset
+
+
+\begin_inset Marginal
+status collapsed
+
+\begin_layout Standard
+
+\series bold
+\InsetSpace ~
+!
+\end_layout
+
+\end_inset
+
+ before doing any operation.
+ This promotion
+\begin_inset LatexCommand index
+name "type promotion"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "type promotion"
+
+\end_inset
+
+ can be omitted, if the result is the same.
+ The effect of the promotion rules together with the sign-extension is often
+ surprising:
+\end_layout
+
+\begin_deeper
+\begin_layout Verse
+
+\family typewriter
+unsigned char uc = 0xfe;
+\newline
+if (uc * uc < 0) /* this is true! */
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+....
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+uc * uc
+\family default
+ is evaluated as
+\family typewriter
+(int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
+\family default
+.
+
+\newline
+Another one:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+(unsigned char) -12 / (signed char) -3 = ...
+\end_layout
+
+\begin_layout Standard
+No, the result is not 4:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+(int) (unsigned char) -12 / (int) (signed char) -3 =
+\newline
+(int) (unsigned char)
+ 0xf4 / (int) (signed char) 0xfd =
+\newline
+(int) 0x00f4 / (int) 0xfffd =
+\newline
+(int) 0x00f4
+ / (int) 0xfffd =
+\newline
+(int) 244 / (int) -3 =
+\newline
+(int) -81 = (int) 0xffaf;
+\end_layout
+
+\begin_layout Standard
+Don't complain, that gcc gives you a different result.
+ gcc uses 32 bit ints, while SDCC uses 16 bit ints.
+ Therefore the results are different.
+\newline
+From
+\begin_inset Quotes sld
+\end_inset
+
+comp.lang.c FAQ
+\begin_inset Quotes srd
+\end_inset
+
+:
+\end_layout
+
+\begin_layout Quote
+
+\emph on
+If well-defined overflow characteristics are important and negative values
+ are not, or if you want to steer clear of sign-extension problems when
+ manipulating bits or bytes, use one of the corresponding unsigned types.
+ (Beware when mixing signed and unsigned values in expressions, though.)
+\newline
+Although
+ character types (especially unsigned char) can be used as "tiny" integers,
+ doing so is sometimes more trouble than it's worth, due to unpredictable
+ sign extension and increased code size.
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+Use unsigned when it is known in advance that the value is not going to
+ be negative.
+ This helps especially if you are doing division or multiplication, bit-shifting
+ or are using an array index.
+\end_layout
+
+\begin_layout Itemize
+NEVER jump into a LOOP.
+\end_layout
+
+\begin_layout Itemize
+Declare the variables to be local
+\begin_inset LatexCommand index
+name "local variables"
+
+\end_inset
+
+ whenever possible, especially loop control variables (induction).
+\end_layout
+
+\begin_layout Itemize
+Have a look at the assembly listing to get a
+\begin_inset Quotes sld
+\end_inset
+
+feeling
+\begin_inset Quotes srd
+\end_inset
+
+ for the code generation.
+\end_layout
+
+\begin_layout Section
+Porting code from or to other compilers
+\begin_inset LatexCommand label
+name "sec:Porting-code-to-other-compilers"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+check whether endianness of the compilers differs and adapt where needed.
+\end_layout
+
+\begin_layout Itemize
+check the device specific header files
+\begin_inset LatexCommand index
+name "Header files"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Include files"
+
+\end_inset
+
+ for compiler specific syntax.
+ Eventually include the file <compiler.h
+\begin_inset LatexCommand index
+name "compiler.h (include file)"
+
+\end_inset
+
+>
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup"
+
+\end_inset
+
+ to allow using common header files.
+ (see f.e.
+ cc2510fx.h
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup"
+
+\end_inset
+
+).
+\end_layout
+
+\begin_layout Itemize
+check whether the startup code contains the correct initialization (watchdog,
+ peripherals).
+\end_layout
+
+\begin_layout Itemize
+check whether the sizes of short, int, long match.
+\end_layout
+
+\begin_layout Itemize
+check if some 16 or 32 bit hardware registers require a specific addressing
+ order (least significant or most significant byte first) and adapt if needed
+ (
+\emph on
+first
+\emph default
+ and
+\emph on
+last
+\emph default
+ relate to time and not to lower/upper memory location here, so this is
+
+\emph on
+not
+\emph default
+ the same as endianness).
+\end_layout
+
+\begin_layout Itemize
+check whether the keyword
+\emph on
+volatile
+\emph default
+ is used where needed.
+ The compilers might differ in their optimization characteristics (as different
+ versions of the same compiler might also use more clever optimizations
+ this is good idea anyway).
+ See section
+\begin_inset LatexCommand ref
+reference "sub:Common-interrupt-pitfall-volatile"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Itemize
+check that the compilers are not told to suppress warnings.
+\end_layout
+
+\begin_layout Itemize
+check and convert compiler specific extensions (interrupts, memory areas,
+ pragmas etc.).
+\end_layout
+
+\begin_layout Itemize
+check for differences in type promotion.
+ Especially check for math operations on
+\family typewriter
+char
+\family default
+ or
+\family typewriter
+unsigned char
+\family default
+ variables.
+ For the sake of C99 compatibility SDCC will probably promote these to
+\family typewriter
+int
+\family default
+ more often than other compilers.
+ Eventually insert explicit casts to
+\family typewriter
+(char)
+\family default
+ or
+\family typewriter
+(unsigned char)
+\family default
+.
+ Also check that the ~\InsetSpace ~
+operator
+\begin_inset LatexCommand index
+name "\\~\\/ Operator"
+
+\end_inset
+
+ is not used on
+\family typewriter
+bit
+\begin_inset LatexCommand index
+name "bit"
+
+\end_inset
+
+
+\family default
+ variables, use the !\InsetSpace ~
+operator instead.
+ See sections
+\begin_inset LatexCommand ref
+reference "type promotion"
+
+\end_inset
+
+ and
+\begin_inset LatexCommand ref
+reference "sec:Compatibility-with-previous"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Itemize
+check the assembly code generated for interrupt routines (f.e.
+ for calls to possibly non-reentrant library functions).
+\end_layout
+
+\begin_layout Itemize
+check whether timing loops result in proper timing (or preferably consider
+ a rewrite of the code with timer based delays instead).
+\end_layout
+
+\begin_layout Itemize
+check for differences in printf parameters (some compilers push (va_arg
+\begin_inset LatexCommand index
+name "vararg, va\\_arg"
+
+\end_inset
+
+) char variables as
+\family typewriter
+int
+\family default
+ others push them as
+\family typewriter
+char
+\family default
+.
+ See section
+\begin_inset LatexCommand ref
+reference "sec:Compatibility-with-previous"
+
+\end_inset
+
+).
+\end_layout
+
+\begin_layout Itemize
+check the resulting memory map
+\begin_inset LatexCommand index
+name "Memory map"
+
+\end_inset
+
+.
+ Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
+ly idata, pdata, xdata).
+ Eventually check if unexpected library functions are included.
+\end_layout
+
+\begin_layout Section
+Tools
+\begin_inset LatexCommand index
+name "Tools"
+
+\end_inset
+
+ included in the distribution
+\end_layout
+
+\begin_layout Standard
+\align left
+\begin_inset Tabular
+<lyxtabular version="3" rows="12" columns="3">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0pt">
+<column alignment="left" valignment="top" leftline="true" width="0pt">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Name
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Purpose
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Directory
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+uCsim
+\begin_inset LatexCommand index
+name "uCsim"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Simulator for various architectures
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/sim/ucsim
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+keil2sdcc.pl
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+header file
+\begin_inset LatexCommand index
+name "Header files"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Include files"
+
+\end_inset
+
+ conversion
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/support/scripts
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+mh2h.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+header file conversion
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/support/scripts
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+as-gbz80
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Assembler
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+as-z80
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Assembler
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+asx8051
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Assembler
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCDB
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Simulator
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+aslink
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Linker
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+link-z80
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Linker
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+link-gbz80
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Linker
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+packihx
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Intel Hex packer
+\begin_inset LatexCommand index
+name "packihx (tool)"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/bin
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\newline
+
+\end_layout
+
+\begin_layout Section
+Documentation
+\begin_inset LatexCommand index
+name "Documentation"
+
+\end_inset
+
+ included in the distribution
+\end_layout
+
+\begin_layout Standard
+\align left
+\begin_inset Tabular
+<lyxtabular version="3" rows="10" columns="2">
+<features>
+<column alignment="block" valignment="top" leftline="true" width="40col%">
+<column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
+<row topline="true" bottomline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Subject / Title
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Filename / Where to get
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCC Compiler User Guide
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+You're reading it right now
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Changelog of SDCC
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/Changelog
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+ASXXXX
+\begin_inset LatexCommand index
+name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Assembler documentation"
+
+\end_inset
+
+ Assemblers and
+\newline
+ASLINK
+\begin_inset LatexCommand index
+name "aslink"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Linker documentation"
+
+\end_inset
+
+ Relocating Linker
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/as/doc/asxhtm.html
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCC regression test
+\begin_inset LatexCommand index
+name "Regression test"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/doc/test_suite_spec.pdf
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Various notes
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/doc/*
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Notes on debugging with SDCDB
+\begin_inset LatexCommand index
+name "SDCDB (debugger)"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/debugger/README
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at
+\emph default
+:
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+uCsim
+\begin_inset LatexCommand index
+name "uCsim"
+
+\end_inset
+
+ Software simulator for microcontrollers
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+sdcc/sim/ucsim/doc
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+/index.html
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Temporary notes on the pic16
+\begin_inset LatexCommand index
+name "PIC16"
+
+\end_inset
+
+ port
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/src/pic16/NOTES
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\newline
+
+\emph default
+
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+SDCC internal documentation (debugging file format)
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+sdcc/doc/
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+cdbfileformat.pd
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+f
+\emph on
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand url
+target "http://sdcc.sourceforge.net/doc/cdbfileformat.pdf"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\newline
+
+\end_layout
+
+\begin_layout Section
+Related open source tools
+\begin_inset LatexCommand label
+name "sec:Related-open-source-tools"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Related tools"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\align left
+\begin_inset Tabular
+<lyxtabular version="3" rows="16" columns="3">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0pt">
+<column alignment="block" valignment="top" leftline="true" width="30line%">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Name
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Purpose
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Where to get
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text