pdftitle={SDCC Compiler User Guide},
pdfauthor={SDCC development team},
pdfsubject={installation, user manual},
- pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
+ pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
pdfpagemode=UseOutlines,
colorlinks=true,
linkcolor=blue] {hyperref}
\size normal
-SDCC 2.6.2
+SDCC 2.6.4
\size footnotesize
\newline
\end_inset
-\emph on
+\emph on
Note: this functionality is not in conformance with standard!
-
\layout List
\added_space_bottom bigskip \labelwidthstring 00.00.0000
\layout Itemize
-\series bold
+\series bold
pedantic_parse_number
-\series default
+\series default
\begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
-\end_inset
+\end_inset
(+ | -) - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are
parsed properly and the macro LO_B(3) gets expanded.
Default is off.
Below is an example on how to use this pragma.
-\emph on
+\emph on
Note: this functionality is not in conformance with standard!
-
\layout Verse
-\family typewriter
+\family typewriter
#pragma pedantic_parse_number +
\begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
-\end_inset
+\end_inset
+
+\newline
\newline
-\newline
#define LO_B(x) ((x) & 0xff)
-\newline
-\newline
+\newline
+
+\newline
unsigned char foo(void)
-\newline
-\InsetSpace ~
-\InsetSpace ~
-\InsetSpace ~
+\newline
+{
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
unsigned char c=0xfe-LO_B(3);
-\newline
-\newline
-\InsetSpace ~
-\InsetSpace ~
-\InsetSpace ~
+\newline
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
return c;
-\newline
+\newline
}
-\newline
+\newline
\layout Itemize
\layout Itemize
-\series bold
+\series bold
sdcc_hash
-\series default
+\series default
\begin_inset LatexCommand \index{\#pragma sdcc\_hash}
-\end_inset
+\end_inset
(+ | -) - Allow "naked" hash in macro definition, for example:
\newline
-\family typewriter
+
+\family typewriter
#define DIR_LO(x) #(x & 0xff)
-\family default
+\family default
+
\newline
Default is off.
Below is an example on how to use this pragma.
\layout Verse
-\family typewriter
+\family typewriter
#pragma preproc_asm +
-\newline
+\newline
#pragma sdcc_hash +
\begin_inset LatexCommand \index{\#pragma sdcc\_hash}
-\end_inset
+\end_inset
+
+\newline
-\newline
-\newline
+\newline
#define ROMCALL(x)
-\backslash
-\newline
-\InsetSpace ~
-\InsetSpace ~
-\InsetSpace ~
+\backslash
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
mov R6_B3, #(x & 0xff)
-\backslash
-\newline
-\InsetSpace ~
-\InsetSpace ~
-\InsetSpace ~
+\backslash
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
mov R7_B3, #((x >> 8) & 0xff)
-\backslash
-\newline
-\InsetSpace ~
-\InsetSpace ~
-\InsetSpace ~
+\backslash
+
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
lcall __romcall
-\newline
-\newline
+\newline
+
+\newline
...
-\newline
+\newline
_asm
-\newline
+\newline
ROMCALL(72)
-\newline
+\newline
_endasm;
-\newline
+\newline
...
-\newline
+\newline
\layout Standard
used.
The compiler treats all functions of a single C file as being in the same
code page unless it is non static.
- The compiler treats all local variables of a single C file as being in
- the same RAM bank unless it is an extern.
\newline
\newline
To get the best follow these guide lines:
\layout Enumerate
-make local functions static, as non static functions require code page selection
- overhead.
-\layout Enumerate
-
-Make local variables static as extern variables require RAM bank selection
+Make local functions static, as non static functions require code page selection
overhead.
\layout Enumerate
for the 16F877 use 4 separate files and i.e.
for the 16F874 use 2 separate files.
This way the linker can put the code for each file into different code
- pages and the compiler can allocate reusable variables more efficiently
- and there's less page selection overhead.
+ pages and there's less page selection overhead.
+\layout Enumerate
+
And as for any 8 bit micro (especially for PIC 14 as they have a very simple
- instruction set) use 'unsigned char' whereever possible instead of 'int'.
+ instruction set), use 'unsigned char' whereever possible instead of 'int'.
\layout Subsection
Creating a device include file
Interrupt code
\layout Standard
-For the interrupt function, use the keyword 'interrupt'
+For the interrupt function, use the keyword '__interrupt'
\begin_inset LatexCommand \index{PIC14!interrupt}
\end_inset
\family typewriter
-void Intr(void) interrupt 0
+void Intr(void) __interrupt 0
\newline
{
\newline
\end_inset
disable (slightly faulty) optimization on pCode
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-stack-loc
+\begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
+
+\end_inset
+
+ sets the lowest address of the argument passing stack (defaults to a suitably
+ large shared databank to reduce BANKSEL overhead)
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-stack-size
+\begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
+
+\end_inset
+
+ sets the size if the argument passing stack (default: 16, minimum: 4)
\layout Subsection
The library
/
\end_inset
--stack-model=[model] Used in conjuction with the command above.
+-pstack-model=[model] Used in conjuction with the command above.
Defines the stack model to be used, valid stack models are :
\begin_deeper
\layout List
whenever possible, especially loop control variables (induction).
\layout Itemize
-Since the compiler does not always do implicit integral promotion, the programme
-r should do an explicit cast when integral promotion is required.
-\layout Itemize
-
-Reducing the size of division, multiplication & modulus operations can reduce
- code size substantially.
- Take the following code for example.
-\begin_deeper
-\layout Verse
-
-
-\family typewriter
-foobar(unsigned int p1, unsigned char ch)
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-unsigned char ch1 = p1 % ch ;
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-....
-\newline
-}
-\layout Standard
-
-For the modulus operation the variable ch will be promoted to unsigned int
- first then the modulus operation will be performed (this will lead to a
- call to support routine _moduint()), and the result will be casted to a
- char.
- If the code is changed to
-\layout Verse
-
-
-\family typewriter
-foobar(unsigned int p1, unsigned char ch)
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-unsigned char ch1 = (unsigned char)p1 % ch ;
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-....
-\newline
-}
-\layout Standard
-
-It would substantially reduce the code generated (future versions of the
- compiler will be smart enough to detect such optimization opportunities).
-\end_deeper
-\layout Itemize
-
Have a look at the assembly listing to get a
\begin_inset Quotes sld
\end_inset
\layout Standard
+
+\series bold
Name
\end_inset
</cell>
\layout Standard
+
+\series bold
Purpose
\end_inset
</cell>
\layout Standard
+
+\series bold
Directory
\end_inset
</cell>
\begin_inset Tabular
<lyxtabular version="3" rows="10" columns="2">
<features>
-<column alignment="left" valignment="top" leftline="true" width="0">
-<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
-<row topline="true" bottomline="true">
+<column alignment="block" valignment="top" leftline="true" width="40col%">
+<column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
+<row topline="true" bottomline="true" endhead="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
+
+\series bold
Subject / Title
\end_inset
</cell>
\layout Standard
-Where to get / filename
+
+\series bold
+Filename / Where to get
\end_inset
</cell>
</row>
\layout Standard
You're reading it right now
+\emph on
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
sdcc/Changelog
+\emph on
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\end_inset
- Assemblers and ASLINK
+ Assemblers and
+\newline
+ASLINK
\begin_inset LatexCommand \index{aslink}
\end_inset
\layout Standard
-sdcc/as/doc/asxhtm.html
+sdcc/as/doc/asxhtm.html
+\emph on
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-sdcc/doc/test_suite_spec.pdf
+sdcc/doc/test_suite_spec.pdf
+\emph on
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-sdcc/doc/*
+sdcc/doc/*
+\emph on
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-sdcc/debugger/README
+sdcc/debugger/README
+\emph on
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at
+\emph default
+:
+\newline
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\bar default
\noun default
\color default
-/index.html
+/index.html
+\emph on
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
-sdcc/src/pic16/NOTES
+sdcc/src/pic16/NOTES
+\emph on
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\newline
+
+\emph default
+
+\begin_inset LatexCommand \url{http://svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\noun default
\color default
f
+\emph on
+ \SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+
+\hfill
+online at:
+\emph default
+
+\newline
+
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\layout Standard
+
+\series bold
Name
\end_inset
</cell>
\layout Standard
+
+\series bold
Purpose
\end_inset
</cell>
\layout Standard
+
+\series bold
Where to get
\end_inset
</cell>
<lyxtabular version="3" rows="7" columns="3">
<features>
<column alignment="left" valignment="top" leftline="true" width="0pt">
-<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" width="0">
<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\layout Standard
+
+\series bold
Name
\end_inset
</cell>
\layout Standard
+
+\series bold
Subject / Title
\end_inset
</cell>
\layout Standard
+
+\series bold
Where to get
\end_inset
</cell>
\layout Standard
+\series bold
\size footnotesize
Vendor
\end_inset
\layout Standard
+\series bold
\size footnotesize
Subject / Title
\end_inset
\layout Standard
+\series bold
\size footnotesize
Where to get
\end_inset