+\end_layout
+
+\begin_layout Standard
+That is it.
+ Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
+ the executables from sdcc
+\backslash
+bin_vc to sdcc
+\backslash
+bin, and you can compile using SDCC.
+\end_layout
+
+\begin_layout Subsection
+Building SDCC Using Borland
+\end_layout
+
+\begin_layout Enumerate
+From the sdcc directory, run the command "make -f Makefile.bcc".
+ This should regenerate all the .exe files in the bin directory except for
+ SDCDB and ucSim.
+\end_layout
+
+\begin_layout Enumerate
+If you modify any source files and need to rebuild, be aware that the dependenci
+es may not be correctly calculated.
+ The safest option is to delete all .obj files and run the build again.
+ From a Cygwin BASH prompt, this can easily be done with the command (be
+ sure you are in the sdcc directory):
+\newline
+
+\newline
+
+\family sans
+\series bold
+find .
+
+\backslash
+( -name '*.obj' -o -name '*.lib' -o -name '*.rul'
+\backslash
+) -print -exec rm {}
+\backslash
+;
+\family default
+\series default
+
+\newline
+
+\newline
+or on Windows NT/2000/XP from the command prompt with the command:
+\newline
+
+\family sans
+\series bold
+
+\newline
+del /s *.obj *.lib *.rul
+\family default
+\series default
+ from the sdcc directory.
+\end_layout
+
+\begin_layout Subsection
+Windows Install Using a ZIP Package
+\end_layout
+
+\begin_layout Enumerate
+Download the binary zip package from
+\begin_inset LatexCommand url
+target "http://sdcc.sf.net/snap.php"
+
+\end_inset
+
+ and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
+ This should unpack to a group of sub-directories.
+ An example directory structure after unpacking the mingw32 package is:
+ c:
+\backslash
+sdcc
+\backslash
+bin for the executables, c:
+\backslash
+sdcc
+\backslash
+include and c:
+\backslash
+sdcc
+\backslash
+lib for the include and libraries.
+\end_layout
+
+\begin_layout Enumerate
+Adjust your environment variable PATH to include the location of the bin
+ directory or start sdcc using the full path.
+\end_layout
+
+\begin_layout Subsection
+Windows Install Using the Setup Program
+\begin_inset LatexCommand label
+name "sub:Windows-Install"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Download the setup program
+\emph on
+sdcc-x.y.z-setup.exe
+\emph default
+ for an official release from
+\newline
+
+\begin_inset LatexCommand url
+target "http://sf.net/project/showfiles.php?group_id=599"
+
+\end_inset
+
+ or a setup program for one of the snapshots
+\emph on
+sdcc-yyyymmdd-xxxx-setup.exe
+\emph default
+ from
+\begin_inset LatexCommand url
+target "http://sdcc.sf.net/snap.php"
+
+\end_inset
+
+ and execute it.
+ A windows typical installer will guide you through the installation process.
+\end_layout
+
+\begin_layout Subsection
+VPATH
+\begin_inset LatexCommand index
+name "VPATH"
+
+\end_inset
+
+ feature
+\end_layout
+
+\begin_layout Standard
+SDCC supports the VPATH feature provided by configure and make.
+ It allows to separate the source and build trees.
+ Here's an example:
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+cd ~\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+# cd $HOME
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+tar -xzf sdcc.src.tar.gz\InsetSpace ~
+# extract source to directory sdcc
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+mkdir sdcc.build\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+# put output in sdcc.build
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+cd sdcc.build
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+../sdcc/configure\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+# configure is doing all the magic!
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+make
+\end_layout
+
+\begin_layout Standard
+\noindent
+That's it!
+\series bold
+configure
+\series default
+ will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
+ It automagically computes the variables srcdir, top_srcdir and top_buildir
+ for each directory.
+ After running
+\series bold
+make
+\series default
+ the generated files will be in ~/sdcc.build, while the source files stay
+ in ~/sdcc.
+\newline
+This is not only usefull for building different binaries, e.g.
+ when cross compiling.
+ It also gives you a much better overview in the source tree when all the
+ generated files are not scattered between the source files.
+ And the best thing is: if you want to change a file you can leave the original
+ file untouched in the source directory.
+ Simply copy it to the build directory, edit it, enter `make clean', `rm
+ Makefile.dep' and `make'.
+
+\series bold
+make
+\series default
+ will do the rest for you!
+\end_layout
+
+\begin_layout Section
+Building the Documentation
+\end_layout
+
+\begin_layout Standard
+Add -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-enable-doc to the configure arguments to build the documentation together
+ with all the other stuff.
+ You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
+ dvips and makeindex) to get the job done.
+ Another possibility is to change to the doc directory and to type
+\family sans
+\series bold
+
+\begin_inset Quotes srd
+\end_inset
+
+make
+\begin_inset Quotes srd
+\end_inset
+
+
+\family default
+\series default
+ there.
+ You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
+x).
+ Using LyX
+\begin_inset LatexCommand url
+target "http://www.lyx.org"
+
+\end_inset
+
+ as editor is straightforward.
+ Prebuilt documentation in html and pdf format is available from
+\begin_inset LatexCommand url
+target "http://sdcc.sf.net/snap.php"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Section
+Reading the Documentation
+\begin_inset LatexCommand index
+name "Documentation"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Currently reading the document in pdf format is recommended, as for unknown
+ reason the hyperlinks are working there whereas in the html version they
+ are not
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+If you should know why please drop us a note
+\end_layout
+
+\end_inset
+
+.
+
+\newline
+You'll find the pdf version
+\begin_inset LatexCommand index
+name "PDF version of this document"
+
+\end_inset
+
+ at
+\begin_inset LatexCommand url
+target "http://sdcc.sf.net/doc/sdccman.pdf"
+
+\end_inset
+
+.
+
+\newline
+A html version
+\begin_inset LatexCommand index
+name "HTML version of this document"
+
+\end_inset
+
+ should be online at
+\begin_inset LatexCommand url
+target "http://sdcc.sf.net/doc/sdccman.html/index.html"
+
+\end_inset
+
+.
+\newline
+This documentation is in some aspects different from a commercial documentation:
+
+\end_layout
+
+\begin_layout Itemize
+It tries to document SDCC for several processor architectures in one document
+ (commercially these probably would be separate documents/products).
+ This document
+\begin_inset LatexCommand index
+name "Status of documentation"
+
+\end_inset
+
+ currently matches SDCC for mcs51 and DS390 best and does give too few informati
+on about f.e.
+ Z80, PIC14, PIC16 and HC08.
+\end_layout
+
+\begin_layout Itemize
+There are many references pointing away from this documentation.
+ Don't let this distract you.
+ If there f.e.
+ was a reference like
+\begin_inset LatexCommand url
+target "http://www.opencores.org"
+
+\end_inset
+
+ together with a statement
+\begin_inset Quotes sld
+\end_inset
+
+some processors which are targetted by SDCC can be implemented in a
+\emph on
+f
+\emph default
+ield
+\emph on
+p
+\emph default
+rogrammable
+\emph on
+g
+\emph default
+ate
+\emph on
+a
+\emph default
+rray
+\begin_inset LatexCommand index
+name "FPGA (field programmable gate array)"
+
+\end_inset
+
+
+\begin_inset Quotes srd
+\end_inset
+
+ or
+\begin_inset LatexCommand url
+target "http://sf.net/projects/fpgac"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "FpgaC ((subset of) C to FPGA compiler)"
+
+\end_inset
+
+
+\begin_inset Quotes sld
+\end_inset
+
+have you ever heard of an open source compiler that compiles a subset of
+ C for an FPGA?
+\begin_inset Quotes srd
+\end_inset
+
+ we expect you to have a quick look there and come back.
+ If you read this you are on the right track.
+\end_layout
+
+\begin_layout Itemize
+Some sections attribute more space to problems, restrictions and warnings
+ than to the solution.
+\end_layout
+
+\begin_layout Itemize
+The installation section and the section about the debugger is intimidating.
+\end_layout
+
+\begin_layout Itemize
+There are still lots of typos and there are more different writing styles
+ than pictures.
+\end_layout
+
+\begin_layout Section
+Testing the SDCC Compiler
+\begin_inset LatexCommand label
+name "sec:Testing-the-SDCC"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The first thing you should do after installing your SDCC compiler is to
+ see if it runs.
+ Type
+\family sans
+\series bold
+"sdcc -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-version"
+\begin_inset LatexCommand index
+name "version"
+
+\end_inset
+
+
+\family default
+\series default
+ at the prompt, and the program should run and output its version like:
+
+\newline
+
+\family typewriter
+SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
+ (UNIX)
+\end_layout
+
+\begin_layout Standard
+If it doesn't run, or gives a message about not finding sdcc program, then
+ you need to check over your installation.
+ Make sure that the sdcc bin directory is in your executable search path
+ defined by the PATH environment setting (
+\series medium
+see
+\series default
+ section
+\begin_inset LatexCommand ref
+reference "sub:Install-Trouble-shooting"
+
+\end_inset
+
+\InsetSpace ~
+
+\series medium
+Install trouble-shooting for suggestions
+\series default
+).
+ Make sure that the sdcc program is in the bin folder, if not perhaps something
+ did not install correctly.
+\newline
+
+\newline
+
+\series medium
+SDCC
+\series default
+ is commonly installed as described in section
+\begin_inset Quotes sld
+\end_inset
+
+Install and search paths
+\begin_inset Quotes srd
+\end_inset
+
+.
+\newline
+
+\newline
+
+\series medium
+Make sure the compiler works on a very simple example.
+ Type in the following test.c program using your favorite
+\series default
+ ASCII
+\series medium
+editor:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+char test;
+\newline
+
+\newline
+void main(void) {
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+test=0;
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+
+\series medium
+Compile this using the following command:
+\series default
+
+\family sans
+\series bold
+"sdcc -c test.c".
+
+\family default
+\series default
+
+\series medium
+If all goes well, the compiler will generate a test.asm and test.rel file.
+ Congratulations, you've just compiled your first program with SDCC.
+ We used the -c option to tell SDCC not to link the generated code, just
+ to keep things simple for this step.
+\series default
+
+\newline
+
+\newline
+
+\series medium
+The next step is to try it with the linker.
+ Type in
+\series default
+
+\family sans
+\series bold
+"sdcc test.c
+\family default
+\series default
+"
+\series medium
+.
+ If all goes well the compiler will link with the libraries and produce
+ a test.ihx output file.
+ If this step fails
+\series default
+
+\series medium
+(no test.ihx, and the linker generates warnings), then the problem is most
+ likely that
+\series default
+ SDCC
+\series medium
+cannot find the
+\series default
+ /
+\series medium
+usr/local/share/sdcc/lib directory
+\series default
+
+\series medium
+(see
+\series default
+ section
+\begin_inset LatexCommand ref
+reference "sub:Install-Trouble-shooting"
+
+\end_inset
+
+\InsetSpace ~
+
+\series medium
+Install trouble-shooting for suggestions).
+\series default
+
+\newline
+
+\newline
+
+\series medium
+The final test is to ensure
+\series default
+ SDCC
+\series medium
+can use the
+\series default
+ standard
+\series medium
+header files and libraries.
+ Edit test.c and change it to the following:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+#include <string.h>
+\newline
+
+\newline
+char str1[10];
+\newline
+
+\newline
+void main(void) {
+\newline
+\InsetSpace ~
+\InsetSpace ~
+strcpy(str1, "testing");
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+
+\series medium
+Compile this by typing
+\series default
+
+\family sans
+\series bold
+"sdcc test.c"
+\family default
+\series medium
+.
+ This should generate a test.ihx output file, and it should give no warnings
+ such as not finding the string.h file.
+ If it cannot find the string.h file, then the problem is that
+\series default
+ SDCC
+\series medium
+cannot find the /usr/local/share/sdcc/include directory
+\series default
+
+\series medium
+(see the
+\series default
+ section
+\begin_inset LatexCommand ref
+reference "sub:Install-Trouble-shooting"
+
+\end_inset
+
+\InsetSpace ~
+
+\series medium
+Install trouble-shooting section for suggestions).
+
+\series default
+ Use option
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-print-search-dirs
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-print-search-dirs"
+
+\end_inset
+
+ to find exactly where SDCC is looking for the include and lib files.
+\end_layout
+
+\begin_layout Section
+Install Trouble-shooting
+\begin_inset LatexCommand label
+name "sub:Install-Trouble-shooting"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Install trouble-shooting"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+If SDCC does not build correctly
+\end_layout
+
+\begin_layout Standard
+A thing to try is starting from scratch by unpacking the .tgz source package
+ again in an empty directory.
+ Configure it like:
+\newline
+
+\newline
+
+\family sans
+\series bold
+./configure 2>&1 | tee configure.log
+\family default
+\series default
+
+\newline
+
+\newline
+and build it like:
+\newline
+
+\newline
+
+\family sans
+\series bold
+make 2>&1 | tee make.log
+\family default
+\series default
+
+\newline
+
+\newline
+If anything goes wrong, you can review the log files to locate the problem.
+ Or a relevant part of this can be attached to an email that could be helpful
+ when requesting help from the mailing list.
+\end_layout
+
+\begin_layout Subsection
+What the
+\begin_inset Quotes sld
+\end_inset
+
+./configure
+\begin_inset Quotes srd
+\end_inset
+
+ does
+\end_layout
+
+\begin_layout Standard
+The
+\begin_inset Quotes sld
+\end_inset
+
+./configure
+\begin_inset Quotes srd
+\end_inset
+
+ command is a script that analyzes your system and performs some configuration
+ to ensure the source package compiles on your system.
+ It will take a few minutes to run, and will compile a few tests to determine
+ what compiler features are installed.
+\end_layout
+
+\begin_layout Subsection
+What the
+\begin_inset Quotes sld
+\end_inset
+
+make
+\begin_inset Quotes srd
+\end_inset
+
+ does
+\end_layout
+
+\begin_layout Standard
+This runs the GNU make tool, which automatically compiles all the source
+ packages into the final installed binary executables.
+\end_layout
+
+\begin_layout Subsection
+What the
+\begin_inset Quotes sld
+\end_inset
+
+make install
+\begin_inset Quotes erd
+\end_inset
+
+ command does.
+\end_layout
+
+\begin_layout Standard
+This will install the compiler, other executables libraries and include
+ files into the appropriate directories.
+ See sections
+\begin_inset LatexCommand ref
+reference "sub:Install-paths"
+
+\end_inset
+
+,\InsetSpace ~
+
+\begin_inset LatexCommand ref
+reference "sub:Search-Paths"
+
+\end_inset
+
+\InsetSpace ~
+about install and search paths.
+\newline
+On most systems you will need super-user privilege
+s to do this.
+\end_layout
+
+\begin_layout Section
+Components of SDCC
+\end_layout
+
+\begin_layout Standard
+SDCC is not just a compiler, but a collection of tools by various developers.
+ These include linkers, assemblers, simulators and other components.
+ Here is a summary of some of the components.
+ Note that the included simulator and assembler have separate documentation
+ which you can find in the source package in their respective directories.
+ As SDCC grows to include support for other processors, other packages from
+ various developers are included and may have their own sets of documentation.
+\newline
+
+\newline
+You
+ might want to look at the files which are installed in <installdir>.
+ At the time of this writing, we find the following programs for gcc-builds:
+\newline
+
+
+\newline
+In <installdir>/bin:
+\end_layout
+
+\begin_layout Itemize
+sdcc - The compiler.
+\end_layout
+
+\begin_layout Itemize
+sdcpp - The C preprocessor.
+\end_layout
+
+\begin_layout Itemize
+asx8051 - The assembler for 8051 type processors.
+\end_layout
+
+\begin_layout Itemize
+as-z80
+\series bold
+,
+\series default
+ as-gbz80 - The Z80 and GameBoy Z80 assemblers.
+\end_layout
+
+\begin_layout Itemize
+aslink -The linker for 8051 type processors.
+\end_layout
+
+\begin_layout Itemize
+link-z80
+\series bold
+,
+\series default
+ link-gbz80 - The Z80 and GameBoy Z80 linkers.
+\end_layout
+
+\begin_layout Itemize
+s51 - The ucSim 8051 simulator.
+\end_layout
+
+\begin_layout Itemize
+sdcdb - The source debugger.
+\end_layout
+
+\begin_layout Itemize
+packihx - A tool to pack (compress) Intel hex files.
+\end_layout
+
+\begin_layout Standard
+In <installdir>/share/sdcc/include
+\end_layout
+
+\begin_layout Itemize
+the include files
+\end_layout
+
+\begin_layout Standard
+In <installdir>/share/sdcc/lib
+\end_layout
+
+\begin_layout Itemize
+the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
+ relocatables.
+\end_layout
+
+\begin_layout Standard
+In <installdir>/share/sdcc/doc
+\end_layout
+
+\begin_layout Itemize
+the documentation
+\end_layout
+
+\begin_layout Standard
+As development for other processors proceeds, this list will expand to include
+ executables to support processors like AVR, PIC, etc.
+\end_layout
+
+\begin_layout Subsection
+sdcc - The Compiler
+\end_layout
+
+\begin_layout Standard
+This is the actual compiler, it in turn uses the c-preprocessor and invokes
+ the assembler and linkage editor.
+\end_layout
+
+\begin_layout Subsection
+sdcpp - The C-Preprocessor
+\end_layout
+
+\begin_layout Standard
+The preprocessor
+\begin_inset LatexCommand index
+name "sdcpp (preprocessor)"
+
+\end_inset
+
+ is a modified version of the GNU cpp
+\begin_inset LatexCommand index
+name "cpp|see{sdcpp}"
+
+\end_inset
+
+ preprocessor
+\begin_inset LatexCommand url
+target "http://gcc.gnu.org/"
+
+\end_inset
+
+.
+ The C preprocessor is used to pull in #include sources, process #ifdef
+ statements, #defines and so on.
+\end_layout
+
+\begin_layout Subsection
+as
+\emph on
+xxxx
+\emph default
+, aslink, link-
+\emph on
+xxx
+\emph default
+ - The Assemblers and Linkage Editors
+\end_layout
+
+\begin_layout Standard
+This is retargettable assembler & linkage editor, it was developed by Alan
+ Baldwin.
+ John Hartman created the version for 8051, and I (Sandeep) have made some
+ enhancements and bug fixes for it to work properly with SDCC.
+\end_layout
+
+\begin_layout Subsection
+s51 - The Simulator
+\end_layout
+
+\begin_layout Standard
+S51
+\begin_inset LatexCommand index
+name "s51"
+
+\end_inset
+
+ is a free open source simulator developed by Daniel Drotos.
+ The simulator is built as part of the build process.
+ For more information visit Daniel's web site at:
+\begin_inset LatexCommand url
+target "http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51"
+
+\end_inset
+
+.
+ It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
+ XA51 family.
+\end_layout
+
+\begin_layout Subsection
+sdcdb - Source Level Debugger
+\end_layout
+
+\begin_layout Standard
+SDCDB
+\begin_inset LatexCommand index
+name "SDCDB (debugger)"
+
+\end_inset
+
+ is the companion source level debugger.
+ More about SDCDB in section
+\begin_inset LatexCommand ref
+reference "cha:Debugging-with-SDCDB"
+
+\end_inset
+
+.
+ The current version of the debugger uses Daniel's Simulator S51
+\begin_inset LatexCommand index
+name "s51"
+
+\end_inset
+
+, but can be easily changed to use other simulators.
+\end_layout
+
+\begin_layout Chapter
+Using SDCC
+\end_layout
+
+\begin_layout Section
+Compiling
+\end_layout
+
+\begin_layout Subsection
+Single Source File Projects
+\end_layout
+
+\begin_layout Standard
+For single source file 8051 projects the process is very simple.
+ Compile your programs with the following command
+\family sans
+\series bold
+"sdcc sourcefile.c".
+
+\family default
+\series default
+ This will compile, assemble and link your source file.
+ Output files are as follows:
+\end_layout
+
+\begin_layout Itemize
+sourcefile.asm
+\begin_inset LatexCommand index
+name "<file>.asm"
+
+\end_inset
+
+ - Assembler source
+\begin_inset LatexCommand index
+name "Assembler source"
+
+\end_inset
+
+ file created by the compiler
+\end_layout
+
+\begin_layout Itemize
+sourcefile.lst
+\begin_inset LatexCommand index
+name "<file>.lst"
+
+\end_inset
+
+ - Assembler listing
+\begin_inset LatexCommand index
+name "Assembler listing"
+
+\end_inset
+
+ file created by the Assembler
+\end_layout
+
+\begin_layout Itemize
+sourcefile.rst
+\begin_inset LatexCommand index
+name "<file>.rst"
+
+\end_inset
+
+ - Assembler listing
+\begin_inset LatexCommand index
+name "Assembler listing"
+
+\end_inset
+
+ file updated with linkedit information, created by linkage editor
+\end_layout
+
+\begin_layout Itemize
+sourcefile.sym
+\begin_inset LatexCommand index
+name "<file>.sym"
+
+\end_inset
+
+ - symbol listing
+\begin_inset LatexCommand index
+name "Symbol listing"
+
+\end_inset
+
+ for the sourcefile, created by the assembler
+\end_layout
+
+\begin_layout Itemize
+sourcefile.rel
+\begin_inset LatexCommand index
+name "<file>.rel"
+
+\end_inset
+
+ or sourcefile.o
+\begin_inset LatexCommand index
+name "<file>.o"
+
+\end_inset
+
+ - Object file
+\begin_inset LatexCommand index
+name "Object file"
+
+\end_inset
+
+ created by the assembler, input to Linkage editor
+\end_layout
+
+\begin_layout Itemize
+sourcefile.map
+\begin_inset LatexCommand index
+name "<file>.map"
+
+\end_inset
+
+ - The memory map
+\begin_inset LatexCommand index
+name "Memory map"
+
+\end_inset
+
+ for the load module, created by the Linker
+\end_layout
+
+\begin_layout Itemize
+sourcefile.mem
+\begin_inset LatexCommand index
+name "<file>.mem"
+
+\end_inset
+
+ - A file with a summary of the memory usage
+\end_layout
+
+\begin_layout Itemize
+sourcefile.ihx
+\begin_inset LatexCommand index
+name "<file>.ihx"
+
+\end_inset
+
+ - The load module in Intel hex format
+\begin_inset LatexCommand index
+name "Intel hex format"
+
+\end_inset
+
+ (you can select the Motorola S19 format
+\begin_inset LatexCommand index
+name "Motorola S19 format"
+
+\end_inset
+
+ with -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-out-fmt-s19
+\begin_inset LatexCommand index
+name "-\\/-out-fmt-s19"
+
+\end_inset
+
+.
+ If you need another format you might want to use
+\family sans
+\shape italic
+objdump
+\family default
+\shape default
+
+\begin_inset LatexCommand index
+name "objdump (tool)"
+
+\end_inset
+
+ or
+\family sans
+\shape italic
+srecord
+\family default
+\shape default
+
+\begin_inset LatexCommand index
+name "srecord (bin, hex, ... tool)"
+
+\end_inset
+
+
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+hyperlinks needed
+\end_layout
+
+\end_inset
+
+ - see also section
+\begin_inset LatexCommand vref
+reference "sub:Postprocessing-the-Intel"
+
+\end_inset
+
+).
+ Both formats are documented in the documentation of srecord
+\begin_inset LatexCommand index
+name "srecord (bin, hex, ... tool)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+sourcefile.adb
+\begin_inset LatexCommand index
+name "<file>.adb"
+
+\end_inset
+
+ - An intermediate file containing debug information needed to create the
+ .cdb file (with -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-debug
+\begin_inset LatexCommand index
+name "-\\/-debug"
+
+\end_inset
+
+)
+\end_layout
+
+\begin_layout Itemize
+sourcefile.cdb
+\begin_inset LatexCommand index
+name "<file>.cdb"
+
+\end_inset
+
+ - An optional file (with -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-debug) containing debug information.
+ The format is documented in cdbfileformat.pdf
+\end_layout
+
+\begin_layout Itemize
+sourcefile.
+ - (no extension)
+\begin_inset LatexCommand index
+name "<file> (no extension)"
+
+\end_inset
+
+ An optional AOMF or AOMF51
+\begin_inset LatexCommand index
+name "AOMF, AOMF51"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "OMF file"
+
+\end_inset
+
+file containing debug information (generated with option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-debug).
+ The (Intel)
+\emph on
+a
+\emph default
+bsolute
+\emph on
+o
+\emph default
+bject
+\emph on
+m
+\emph default
+odule
+\emph on
+f
+\emph default
+ormat is a subformat of the OMF51 format and is commonly used by third party
+ tools (debuggers
+\begin_inset LatexCommand index
+name "Debugger"
+
+\end_inset
+
+, simulators, emulators).
+\end_layout
+
+\begin_layout Itemize
+sourcefile.dump*
+\begin_inset LatexCommand index
+name "<file>.dump*"
+
+\end_inset
+
+ - Dump file to debug the compiler it self (generated with option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumpall) (see section
+\begin_inset LatexCommand ref
+reference "sub:Intermediate-Dump-Options"
+
+\end_inset
+
+\InsetSpace ~
+ and section
+\begin_inset LatexCommand ref
+reference "sub:The-anatomy-of"
+
+\end_inset
+
+\InsetSpace ~
+
+\begin_inset Quotes sld
+\end_inset
+
+Anatomy of the compiler
+\begin_inset Quotes srd
+\end_inset
+
+).
+\end_layout
+
+\begin_layout Subsection
+Postprocessing the Intel Hex
+\begin_inset LatexCommand index
+name "Intel hex format"
+
+\end_inset
+
+ file
+\begin_inset LatexCommand label
+name "sub:Postprocessing-the-Intel"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+In most cases this won't be needed but the Intel Hex file
+\begin_inset LatexCommand index
+name "<file>.ihx"
+
+\end_inset
+
+ which is generated by SDCC might include lines of varying length and the
+ addresses within the file are not guaranteed to be strictly ascending.
+ If your toolchain or a bootloader does not like this you can use the tool
+
+\family typewriter
+packihx
+\family default
+
+\begin_inset LatexCommand index
+name "packihx (tool)"
+
+\end_inset
+
+ which is part of the SDCC distribution:
+\newline
+
+\newline
+
+\family sans
+\series bold
+packihx sourcefile.ihx >sourcefile.hex
+\family default
+\series default
+
+\newline
+
+\newline
+The separately available
+\emph on
+srecord
+\emph default
+
+\begin_inset LatexCommand index
+name "srecord (bin, hex, ... tool)"
+
+\end_inset
+
+ package additionally allows to set undefined locations to a predefined
+ value, to insert checksums
+\begin_inset LatexCommand index
+name "checksum"
+
+\end_inset
+
+ of various flavours (crc, add, xor) and to perform other manipulations
+ (convert, split, crop, offset, ...).
+
+\newline
+
+\newline
+
+\family sans
+\series bold
+srec_cat\InsetSpace ~
+\InsetSpace ~
+sourcefile.ihx -intel\InsetSpace ~
+\InsetSpace ~
+-o sourcefile.hex -intel
+\newline
+
+\newline
+
+\family default
+\series default
+An example for a more complex command line
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+the command backfills
+\begin_inset LatexCommand index
+name "backfill unused memory"
+
+\end_inset
+
+ unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
+ block is zero.
+ If the program counter on an mcs51 runs wild the backfill pattern 0x12
+ will be interpreted as an
+\family typewriter
+lcall
+\family default
+ to address
+\family typewriter
+0x1212
+\family default
+ (where an emergency routine could sit).
+\end_layout
+
+\end_inset
+
+ could look like:
+\newline
+
+\newline
+
+\family sans
+\series bold
+\size footnotesize
+srec_cat\InsetSpace ~
+sourcefile.ihx -intel\InsetSpace ~
+\InsetSpace ~
+-fill 0x12 0x0000 0xfffe\InsetSpace ~
+-little-endian-checksum-nega
+tive 0xfffe 0x02 0x02\InsetSpace ~
+\InsetSpace ~
+-o sourcefile.hex -intel
+\size default
+
+\newline
+
+\newline
+
+\family default
+\series default
+The srecord package is available at
+\begin_inset LatexCommand url
+target "http://sf.net/projects/srecord"
+
+\end_inset
+
+ .
+\end_layout
+
+\begin_layout Subsection
+Projects with Multiple Source Files
+\end_layout
+
+\begin_layout Standard
+SDCC can compile only ONE file at a time.
+ Let us for example assume that you have a project containing the following
+ files:
+\newline
+
+\newline
+foo1.c (contains some functions)
+\newline
+foo2.c (contains some more functions)
+\newline
+foomai
+n.c (contains more functions and the function main)
+\newline
+
+\size footnotesize
+
+\newline
+
+\size default
+The first two files will need to be compiled separately with the commands:
+\size footnotesize
+
+\size default
+
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcc\InsetSpace ~
+-c\InsetSpace ~
+foo1.c
+\family default
+\series default
+\size footnotesize
+
+\newline
+
+\family sans
+\series bold
+\size default
+sdcc\InsetSpace ~
+-c\InsetSpace ~
+foo2.c
+\family default
+\series default
+
+\newline
+
+\newline
+Then compile the source file containing the
+\emph on
+main()
+\emph default
+ function and link
+\begin_inset LatexCommand index
+name "Linker"
+
+\end_inset
+
+ the files together with the following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcc\InsetSpace ~
+foomain.c\InsetSpace ~
+foo1.rel\InsetSpace ~
+foo2.rel
+\family default
+\series default
+
+\begin_inset LatexCommand index
+name "<file>.rel"
+
+\end_inset
+
+
+\newline
+
+\newline
+Alternatively,
+\emph on
+foomain.c
+\emph default
+ can be separately compiled as well:
+\family sans
+\series bold
+
+\newline
+
+\newline
+sdcc\InsetSpace ~
+-c\InsetSpace ~
+foomain.c
+\newline
+sdcc foomain.rel foo1.rel foo2.rel
+\newline
+
+\newline
+
+\family default
+\series default
+The file containing the
+\emph on
+main()
+\emph default
+ function
+\noun on
+must
+\noun default
+ be the
+\noun on
+first
+\noun default
+ file specified in the command line, since the linkage editor processes
+ file in the order they are presented to it.
+ The linker is invoked from SDCC using a script file with extension .lnk
+\begin_inset LatexCommand index
+name "<file>.lnk"
+
+\end_inset
+
+.
+ You can view this file to troubleshoot linking problems such as those arising
+ from missing libraries.
+\end_layout
+
+\begin_layout Subsection
+Projects with Additional Libraries
+\begin_inset LatexCommand index
+name "Libraries"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Some reusable routines may be compiled into a library, see the documentation
+ for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
+ for how to create a
+\emph on
+.lib
+\begin_inset LatexCommand index
+name "<file>.lib"
+
+\end_inset
+
+
+\emph default
+ library file.
+ Libraries created in this manner can be included in the command line.
+ Make sure you include the -L <library-path> option to tell the linker where
+ to look for these files if they are not in the current directory.
+ Here is an example, assuming you have the source file
+\emph on
+foomain.c
+\emph default
+ and a library
+\emph on
+foolib.lib
+\emph default
+ in the directory
+\emph on
+mylib
+\emph default
+ (if that is not the same as your current project):
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcc foomain.c foolib.lib -L mylib
+\newline
+
+\newline
+
+\family default
+\series default
+Note here that
+\emph on
+mylib
+\emph default
+ must be an absolute path name.
+\newline
+
+\newline
+The most efficient way to use libraries is
+ to keep separate modules in separate source files.
+ The lib file now should name all the modules.rel
+\begin_inset LatexCommand index
+name "<file>.rel"
+
+\end_inset
+
+ files.
+ For an example see the standard library file
+\emph on
+libsdcc.lib
+\emph default
+ in the directory <installdir>/share/lib/small.
+\end_layout
+
+\begin_layout Subsection
+Using sdcclib to Create and Manage Libraries
+\begin_inset LatexCommand index
+name "sdcclib"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Alternatively, instead of having a .rel file for each entry on the library
+ file as described in the preceding section, sdcclib can be used to embed
+ all the modules belonging to such library in the library file itself.
+ This results in a larger library file, but it greatly reduces the number
+ of disk files accessed by the linker.
+ Additionally, the packed library file contains an index of all include
+ modules and symbols that significantly speeds up the linking process.
+ To display a list of options supported by sdcclib type:
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib -?
+\begin_inset LatexCommand index
+name "sdcclib"
+
+\end_inset
+
+
+\newline
+
+\newline
+
+\family default
+\series default
+To create a new library file, start by compiling all the required modules.
+ For example:
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcc -c _divsint.c
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcc -c _divuint.c
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcc -c _modsint.c
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcc -c _moduint.c
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcc -c _mulint.c
+\newline
+
+\end_layout
+
+\begin_layout Standard
+This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
+ and _mulint.rel.
+ The next step is to add the .rel files to the library file:
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib libint.lib _divsint.rel
+\family default
+
+\begin_inset LatexCommand index
+name "sdcclib"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib libint.lib _divuint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib libint.lib _modsint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib libint.lib _moduint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib libint.lib _mulint.rel
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Or, if you preffer:
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+If the file already exists in the library, it will be replaced.
+ If a list of .rel files is available, you can tell sdcclib to add those
+ files to a library.
+ For example, if the file 'myliblist.txt' contains
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_divsint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_divuint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_modsint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_moduint.rel
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+_mulint.rel
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Use
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib -l libint.lib myliblist.txt
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Additionally, you can instruct sdcclib to compiles the files before adding
+ them to the library.
+ This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
+ For example:
+\family sans
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+set SDCCLIB_CC=sdcc -c
+\end_layout
+
+\begin_layout Standard
+
+\family sans
+\series bold
+sdcclib -l libint.lib myliblist.txt
+\family default
+\series default
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+To see what modules and symbols are included in the library, options -s
+ and -m are available.
+ For example:
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcclib -s libint.lib
+\family default
+
+\begin_inset LatexCommand index
+name "sdcclib"
+
+\end_inset
+
+
+\newline
+
+\family typewriter
+\series default
+_divsint.rel:
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divsint_a_1_1
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divsint_PARM_2
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divsint
+\newline
+_divuint.rel:
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divuint_a_1_1
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divuint_PARM_2
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divuint_reste_1_1
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divuint_count_1_1
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__divuint
+\newline
+_modsint.rel:
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__modsint_a_1_1
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__modsint_PARM_2
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__modsint
+\newline
+_moduint.rel:
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__moduint_a_1_1
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__moduint_PARM_2
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__moduint_count_1_1
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__moduint
+\newline
+_mulint.rel:
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__mulint_PARM_2
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+__mulint
+\family default
+\series bold
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+If the source files are compiled using -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-debug
+\begin_inset LatexCommand index
+name "-\\/-debug"
+
+\end_inset
+
+, the corresponding debug information file .adb will be include in the library
+ file as well.
+ The library files created with sdcclib are plain text files, so they can
+ be viewed with a text editor.
+ It is not recommended to modify a library file created with sdcclib using
+ a text editor, as there are file indexes numbers located across the file
+ used by the linker to quickly locate the required module to link.
+ Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
+ it can be safely deleted, since all the information required for linking
+ is embedded in the library file itself.
+ Library files created using sdcclib are used as described in the preceding
+ sections.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Command Line Options
+\begin_inset LatexCommand index
+name "Command Line Options"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "sec:Command-Line-Options"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Processor Selection Options
+\begin_inset LatexCommand index
+name "Options processor selection"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Processor selection options"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mmcs51
+\begin_inset LatexCommand index
+name "-mmcs51"
+
+\end_inset
+
+
+\series default
+ Generate code for the Intel MCS51
+\begin_inset LatexCommand index
+name "MCS51"
+
+\end_inset
+
+ family of processors.
+ This is the default processor target.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mds390
+\begin_inset LatexCommand index
+name "-mds390"
+
+\end_inset
+
+
+\series default
+ Generate code for the Dallas DS80C390
+\begin_inset LatexCommand index
+name "DS80C390"
+
+\end_inset
+
+ processor.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mds400
+\begin_inset LatexCommand index
+name "-mds400"
+
+\end_inset
+
+
+\series default
+ Generate code for the Dallas DS80C400
+\begin_inset LatexCommand index
+name "DS80C400"
+
+\end_inset
+
+ processor.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mhc08
+\begin_inset LatexCommand index
+name "-mhc08"
+
+\end_inset
+
+
+\series default
+ Generate code for the Freescale/Motorola HC08
+\begin_inset LatexCommand index
+name "HC08"
+
+\end_inset
+
+ family of processors.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mz80
+\begin_inset LatexCommand index
+name "-mz80"
+
+\end_inset
+
+
+\series default
+ Generate code for the Zilog Z80
+\begin_inset LatexCommand index
+name "Z80"
+
+\end_inset
+
+ family of processors.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mgbz80
+\begin_inset LatexCommand index
+name "-mgbz80"
+
+\end_inset
+
+
+\series default
+ Generate code for the GameBoy Z80
+\begin_inset LatexCommand index
+name "gbz80 (GameBoy Z80)"
+
+\end_inset
+
+ processor (Not actively maintained).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mavr
+\begin_inset LatexCommand index
+name "-mavr"
+
+\end_inset
+
+
+\series default
+ Generate code for the Atmel AVR
+\begin_inset LatexCommand index
+name "AVR"
+
+\end_inset
+
+ processor (Not maintained, not complete).
+ AVR users should probably have a look at winavr
+\begin_inset LatexCommand url
+target "http://sourceforge.net/projects/winavr"
+
+\end_inset
+
+ or
+\begin_inset LatexCommand url
+target "http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index"
+
+\end_inset
+
+, which is based on AVR-port of the gcc compiler.
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+I think it is fair to direct users there for now.
+ Open source is also about avoiding unnecessary work .
+ But I didn't find the 'official' link.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mpic14
+\begin_inset LatexCommand index
+name "-mpic14"
+
+\end_inset
+
+
+\series default
+ Generate code for the Microchip PIC 14
+\begin_inset LatexCommand index
+name "PIC14"
+
+\end_inset
+
+-bit processors (p16f84 and variants.
+ In development, not complete).
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+p16f627 p16f628 p16f84 p16f873 p16f877?
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mpic16
+\begin_inset LatexCommand index
+name "-mpic16"
+
+\end_inset
+
+
+\series default
+ Generate code for the Microchip PIC 16
+\begin_inset LatexCommand index
+name "PIC16"
+
+\end_inset
+
+-bit processors (p18f452 and variants.
+ In development, not complete).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mtlcs900h
+\series default
+ Generate code for the Toshiba TLCS-900H
+\begin_inset LatexCommand index
+name "TLCS-900H"
+
+\end_inset
+
+ processor (Not maintained, not complete).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-mxa51
+\begin_inset LatexCommand index
+name "-mxa51"
+
+\end_inset
+
+
+\series default
+ Generate code for the Phillips XA51
+\begin_inset LatexCommand index
+name "XA51"
+
+\end_inset
+
+ processor (Not maintained, not complete).
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Preprocessor Options
+\begin_inset LatexCommand index
+name "Options preprocessor"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Preprocessor options"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "sdcpp (preprocessor)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-I<path>
+\begin_inset LatexCommand index
+name "-I<path>"
+
+\end_inset
+
+
+\series default
+ The additional location where the preprocessor will look for <..h> or
+\begin_inset Quotes eld
+\end_inset
+
+..h
+\begin_inset Quotes erd
+\end_inset
+
+ files.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-D<macro[=value]>
+\begin_inset LatexCommand index
+name "-D<macro[=value]>"
+
+\end_inset
+
+
+\series default
+ Command line definition of macros.
+ Passed to the preprocessor.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-M
+\begin_inset LatexCommand index
+name "-M"
+
+\end_inset
+
+
+\series default
+ Tell the preprocessor to output a rule suitable for make describing the
+ dependencies of each object file.
+ For each source file, the preprocessor outputs one make-rule whose target
+ is the object file name for that source file and whose dependencies are
+ all the files `#include'd in it.
+ This rule may be a single line or may be continued with `
+\backslash
+'-newline if it is long.
+ The list of rules is printed on standard output instead of the preprocessed
+ C program.
+ `-M' implies `-E
+\begin_inset LatexCommand index
+name "-E"
+
+\end_inset
+
+'.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-C
+\begin_inset LatexCommand index
+name "-C"
+
+\end_inset
+
+
+\series default
+ Tell the preprocessor not to discard comments.
+ Used with the `-E' option.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-MM
+\begin_inset LatexCommand index
+name "-MM"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+Like `-M' but the output mentions only the user header files included with
+ `#include
+\begin_inset Quotes eld
+\end_inset
+
+file"'.
+ System header files included with `#include <file>' are omitted.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-Aquestion(answer)
+\begin_inset LatexCommand index
+name "-Aquestion(answer)"
+
+\end_inset
+
+
+\series default
+ Assert the answer answer for question, in case it is tested with a preprocessor
+ conditional such as `#if #question(answer)'.
+ `-A-' disables the standard assertions that normally describe the target
+ machine.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-Umacro
+\begin_inset LatexCommand index
+name "-Umacro"
+
+\end_inset
+
+
+\series default
+ Undefine macro macro.
+ `-U' options are evaluated after all `-D' options, but before any `-include'
+ and `-imacros' options.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-dM
+\begin_inset LatexCommand index
+name "-dM"
+
+\end_inset
+
+
+\series default
+ Tell the preprocessor to output only a list of the macro definitions that
+ are in effect at the end of preprocessing.
+ Used with the `-E' option.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-dD
+\begin_inset LatexCommand index
+name "-dD"
+
+\end_inset
+
+
+\series default
+ Tell the preprocessor to pass all macro definitions into the output, in
+ their proper sequence in the rest of the output.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-dN
+\begin_inset LatexCommand index
+name "-dN"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+Like `-dD' except that the macro arguments and contents are omitted.
+ Only `#define name' is included in the output.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-pedantic-parse-number
+\begin_inset LatexCommand index
+name "pedantic"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "-pedantic-parse-number"
+
+\end_inset
+
+
+\size large
+\bar under
+
+\begin_inset LatexCommand label
+name "lyx:-pedantic-parse-number"
+
+\end_inset
+
+
+\series default
+\bar default
+
+\size default
+Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
+ and the macro LO_B(3) gets expanded.
+ See also #pragma pedantic_parse_number
+\begin_inset LatexCommand vpageref
+reference "ite:pedantic_parse_number"
+
+\end_inset
+
+ in section
+\begin_inset LatexCommand ref
+reference "sec:Pragmas"
+
+\end_inset
+
+
+\emph on
+Note: this functionality is not in conformance with C99 standard!
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-Wp\InsetSpace ~
+preprocessorOption[,preprocessorOption]
+\series default
+
+\begin_inset LatexCommand index
+name "-Wp preprocessorOption[,preprocessorOption]"
+
+\end_inset
+
+...
+ Pass the preprocessorOption to the preprocessor
+\family typewriter
+sdcpp
+\family default
+
+\begin_inset LatexCommand index
+name "sdcpp (preprocessor)"
+
+\end_inset
+
+.
+ SDCC uses an adapted version of the preprocessor
+\emph on
+cpp
+\emph default
+ of the GNU Compiler Collection
+\begin_inset LatexCommand index
+name "gcc (GNU Compiler Collection)"
+
+\end_inset
+
+ (
+\emph on
+gcc
+\emph default
+
+\begin_inset LatexCommand url
+target "http://gcc.gnu.org/"
+
+\end_inset
+
+), if you need more dedicated options please refer to the GCC\InsetSpace ~
+4.1.1\InsetSpace ~
+CPP\InsetSpace ~
+Manual
+ at
+\begin_inset LatexCommand htmlurl
+target "http://www.gnu.org/software/gcc/onlinedocs/"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Linker Options
+\begin_inset LatexCommand index
+name "Options linker"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Linker options"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-L\InsetSpace ~
+-
+\series default
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series bold
+-lib-path
+\begin_inset LatexCommand index
+name "-\\/-lib-path <path>"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "-L -\\/-lib-path"
+
+\end_inset
+
+
+\series default
+\InsetSpace ~
+<absolute path to additional libraries> This option is passed to the linkage
+ editor's additional libraries
+\begin_inset LatexCommand index
+name "Libraries"
+
+\end_inset
+
+ search path.
+ The path name must be absolute.
+ Additional library files may be specified in the command line.
+ See section Compiling programs for more details.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xram-loc
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-xram-loc <Value>"
+
+\end_inset
+
+\InsetSpace ~
+<Value> The start location of the external ram
+\begin_inset LatexCommand index
+name "xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+, default value is 0.
+ The value entered can be in Hexadecimal or Decimal format, e.g.: -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xram-loc 0x8000 or -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xram-loc 32768.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-code-loc
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-code-loc <Value>"
+
+\end_inset
+
+\InsetSpace ~
+<Value> The start location of the code
+\begin_inset LatexCommand index
+name "code"
+
+\end_inset
+
+ segment, default value 0.
+ Note when this option is used the interrupt vector table
+\begin_inset LatexCommand index
+name "interrupt vector table"
+
+\end_inset
+
+ is also relocated to the given address.
+ The value entered can be in Hexadecimal or Decimal format, e.g.: -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-code-loc 0x8000 or -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-code-loc 32768.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-loc
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-stack-loc <Value>"
+
+\end_inset
+
+\InsetSpace ~
+<Value> By default the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ is placed after the data segment.
+ Using this option the stack can be placed anywhere in the internal memory
+ space of the 8051.
+ The value entered can be in Hexadecimal or Decimal format, e.g.
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-loc 0x20 or -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-loc 32.
+ Since the sp register is incremented before a push or call, the initial
+ sp will be set to one byte prior the provided value.
+ The provided value should not overlap any other memory areas such as used
+ register banks or the data segment and with enough space for the current
+ application.
+ The
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-pack-iram
+\series default
+\InsetSpace ~
+
+\begin_inset LatexCommand index
+name "-\\/-pack-iram"
+
+\end_inset
+
+ option (which is now a default setting) will override this setting, so
+ you should also specify the
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-pack-iram
+\series default
+\InsetSpace ~
+
+\begin_inset LatexCommand index
+name "-\\/-no-pack-iram"
+
+\end_inset
+
+ option if you need to manually place the stack.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xstack-loc
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-xstack-loc <Value>"
+
+\end_inset
+
+\InsetSpace ~
+<Value> By default the external stack
+\begin_inset LatexCommand index
+name "xstack"
+
+\end_inset
+
+ is placed after the pdata
+\begin_inset LatexCommand index
+name "pdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ segment.
+ Using this option the xstack can be placed anywhere in the external memory
+ space of the 8051.
+ The value entered can be in Hexadecimal or Decimal format, e.g.
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xstack-loc 0x8000 or -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-loc 32768.
+ The provided value should not overlap any other memory areas such as the
+ pdata or xdata segment and with enough space for the current application.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-data-loc
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-data-loc <Value>"
+
+\end_inset
+
+\InsetSpace ~
+<Value> The start location of the internal ram data
+\begin_inset LatexCommand index
+name "data (mcs51, ds390 storage class)"
+
+\end_inset
+
+ segment.
+ The value entered can be in Hexadecimal or Decimal format, eg.
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-data-loc 0x20 or -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-data-loc 32.
+ (By default, the start location of the internal ram data segment is set
+ as low as possible in memory, taking into account the used register banks
+ and the bit segment at address 0x20.
+ For example if register banks 0 and 1 are used without bit variables, the
+ data segment will be set, if -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-data-loc is not used, to location 0x10.)
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-idata-loc
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-idata-loc <Value>"
+
+\end_inset
+
+\InsetSpace ~
+<Value> The start location of the indirectly addressable internal ram
+\begin_inset LatexCommand index
+name "idata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ of the 8051, default value is 0x80.
+ The value entered can be in Hexadecimal or Decimal format, eg.
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-idata-loc 0x88 or -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-idata-loc 136.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-bit-loc
+\series default
+\InsetSpace ~
+<Value> The start location of the bit
+\begin_inset LatexCommand index
+name "bit"
+
+\end_inset
+
+ addressable internal ram of the 8051.
+ This is
+\emph on
+not
+\emph default
+ implemented yet.
+ Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
+-bBSEG=<Value>.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-out-fmt-ihx
+\begin_inset LatexCommand index
+name "-\\/-out-fmt-ihx"
+
+\end_inset
+
+
+\series default
+The linker output (final object code) is in Intel Hex format.
+\begin_inset LatexCommand index
+name "Intel hex format"
+
+\end_inset
+
+ This is the default option.
+ The format itself is documented in the documentation of srecord
+\begin_inset LatexCommand index
+name "srecord (bin, hex, ... tool)"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-out-fmt-s19
+\begin_inset LatexCommand index
+name "-\\/-out-fmt-s19"
+
+\end_inset
+
+
+\series default
+The linker output (final object code) is in Motorola S19 format
+\begin_inset LatexCommand index
+name "Motorola S19 format"
+
+\end_inset
+
+.
+ The format itself is documented in the documentation of srecord.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-out-fmt-elf
+\begin_inset LatexCommand index
+name "-\\/-out-fmt-s19"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "HC08!Options!-\\/-out-fmt-elf"
+
+\end_inset
+
+
+\series default
+The linker output (final object code) is in ELF format
+\begin_inset LatexCommand index
+name "ELF format"
+
+\end_inset
+
+.
+ (Currently only supported for the HC08
+\begin_inset LatexCommand index
+name "HC08"
+
+\end_inset
+
+ processors)
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-Wl\InsetSpace ~
+linkOption[,linkOption]
+\series default
+
+\begin_inset LatexCommand index
+name "-Wl linkOption[,linkOption]"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "lyx:-Wl option"
+
+\end_inset
+
+...
+ Pass the linkOption to the linker.
+ If a bootloader is used an option like
+\begin_inset Quotes sld
+\end_inset
+
+-Wl\InsetSpace ~
+-bCSEG=0x1000
+\begin_inset Quotes srd
+\end_inset
+
+ would be typical to set the start of the code segment.
+ Either use the double quotes around this option or use no space (e.g.
+ -Wl-bCSEG=0x1000).
+ See also #pragma constseg and #pragma codeseg in section
+\begin_inset LatexCommand ref
+reference "sec:Pragmas"
+
+\end_inset
+
+ .
+ File sdcc/as/doc/asxhtm.html has more on linker options.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+MCS51 Options
+\begin_inset LatexCommand index
+name "Options MCS51"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "MCS51 options"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-model-small
+\begin_inset LatexCommand index
+name "-\\/-model-small"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+Generate code for Small Model programs, see section Memory Models for more
+ details.
+ This is the default model.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-model-medium
+\begin_inset LatexCommand index
+name "-\\/-model-medium"
+
+\end_inset
+
+
+\series default
+ Generate code for Medium model programs, see section Memory Models for
+ more details.
+ If this option is used all source files in the project have to be compiled
+ with this option.
+ It must also be used when invoking the linker.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-model-large
+\begin_inset LatexCommand index
+name "-\\/-model-large"
+
+\end_inset
+
+
+\series default
+ Generate code for Large model programs, see section Memory Models for more
+ details.
+ If this option is used all source files in the project have to be compiled
+ with this option.
+ It must also be used when invoking the linker.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xstack
+\begin_inset LatexCommand index
+name "-\\/-xstack"
+
+\end_inset
+
+
+\series default
+ Uses a pseudo stack in the pdata
+\begin_inset LatexCommand index
+name "pdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ area (usually the first 256 bytes in the external ram) for allocating variables
+ and passing parameters.
+ See section
+\begin_inset LatexCommand ref
+reference "sub:External-Stack"
+
+\end_inset
+
+\InsetSpace ~
+ External Stack for more details.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-iram-size
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "-\\/-iram-size <Value>"
+
+\end_inset
+
+ Causes the linker to check if the internal ram usage is within limits of
+ the given value.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xram-size
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "-\\/-xram-size <Value>"
+
+\end_inset
+
+ Causes the linker to check if the external ram usage is within limits of
+ the given value.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-code-size
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "-\\/-code-size <Value>"
+
+\end_inset
+
+ Causes the linker to check if the code memory usage is within limits of
+ the given value.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-size
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "-\\/-stack-size <Value>"
+
+\end_inset
+
+ Causes the linker to check if there is at minimum <Value> bytes for stack.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-pack-iram
+\series default
+\InsetSpace ~
+
+\begin_inset LatexCommand index
+name "-\\/-pack-iram"
+
+\end_inset
+
+ Causes the linker to use unused register banks for data variables and pack
+ data, idata and stack together.
+ This is the default now.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-pack-iram
+\series default
+\InsetSpace ~
+
+\begin_inset LatexCommand index
+name "-\\/-no-pack-iram"
+
+\end_inset
+
+ Causes the linker to use old style for allocating memory areas.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-acall-ajmp
+\series default
+\InsetSpace ~
+
+\begin_inset LatexCommand index
+name "-\\/-acall-ajmp"
+
+\end_inset
+
+ Replaces the three byte instructions lcall/ljmp with the two byte instructions
+ acall/ajmp.
+ Only use this option if your code is in the same 2k block of memory.
+ You may need to use this option for some 8051 derivatives which lack the
+ lcall/ljmp instructions..
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+DS390 / DS400 Options
+\begin_inset LatexCommand index
+name "Options DS390"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "DS390"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-model-flat24
+\series default
+
+\begin_inset LatexCommand index
+name "DS390!Options!-\\/-model-flat24"
+
+\end_inset
+
+
+\size large
+
+\size default
+Generate 24-bit flat mode code.
+ This is the one and only that the ds390 code generator supports right now
+ and is default when using
+\emph on
+-mds390
+\emph default
+.
+ See section Memory Models for more details.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-protect-sp-update
+\begin_inset LatexCommand index
+name "DS390!Options!-\\/-protect-sp-update"
+
+\end_inset
+
+
+\series default
+ disable interrupts during ESP:SP updates.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-10bit
+\series default
+
+\begin_inset LatexCommand index
+name "DS390!Options!-\\/-stack-10bit"
+
+\end_inset
+
+ Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
+ This is the one and only that the ds390 code generator supports right now
+ and is default when using
+\emph on
+-mds390
+\emph default
+.
+ In this mode, the stack is located in the lower 1K of the internal RAM,
+ which is mapped to 0x400000.
+ Note that the support is incomplete, since it still uses a single byte
+ as the stack pointer.
+ This means that only the lower 256 bytes of the potential 1K stack space
+ will actually be used.
+ However, this does allow you to reclaim the precious 256 bytes of low RAM
+ for use for the DATA and IDATA segments.
+ The compiler will not generate any code to put the processor into 10 bit
+ stack mode.
+ It is important to ensure that the processor is in this mode before calling
+ any re-entrant functions compiled with this option.
+ In principle, this should work with the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\begin_inset LatexCommand index
+name "-\\/-stack-auto"
+
+\end_inset
+
+
+\emph default
+ option, but that has not been tested.
+ It is incompatible with the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xstack
+\begin_inset LatexCommand index
+name "-\\/-xstack"
+
+\end_inset
+
+
+\emph default
+ option.
+ It also only makes sense if the processor is in 24 bit contiguous addressing
+ mode (see the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-model-flat24 option
+\emph default
+).
+\series bold
+
+\begin_inset Note Note
+status collapsed
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-8-bit - switches off the 10-bit mode
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-probe
+\begin_inset LatexCommand index
+name "DS390!Options!-\\/-stack-probe"
+
+\end_inset
+
+
+\series default
+ insert call to function __stack_probe at each function prologue.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-tini-libid
+\begin_inset LatexCommand index
+name "DS390!Options!-\\/-tini-libid"
+
+\end_inset
+
+
+\series default
+ <nnnn> LibraryID used in -mTININative.
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-use-accelerator
+\begin_inset LatexCommand index
+name "DS390!Options!-\\/-use-accelerator"
+
+\end_inset
+
+
+\series default
+ generate code for DS390 Arithmetic Accelerator.
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Z80 Options
+\begin_inset LatexCommand index
+name "Options Z80"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Z80"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-callee-saves-bc
+\series default
+
+\begin_inset LatexCommand index
+name "Z80!Options!-\\/-callee-saves-bc"
+
+\end_inset
+
+
+\size large
+
+\size default
+Force a called function to always save BC.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-std-crt0
+\series default
+
+\begin_inset LatexCommand index
+name "Z80!Options!-\\/-no-std-crt0"
+
+\end_inset
+
+ When linking, skip the standard crt0.o object file.
+ You must provide your own crt0.o for your system when linking.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-portmode=
+\series default
+<Value>
+\begin_inset LatexCommand index
+name "Z80!Options!-\\/-portmode=<Value>"
+
+\end_inset
+
+ Determinate PORT I/O mode (<Value> is z80 or z180).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-asm=
+\series default
+<Value>
+\begin_inset LatexCommand index
+name "Z80!Options!-\\/-asm=<Value>"
+
+\end_inset
+
+ Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-codeseg
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "Z80!Options!-\\/-codeseg <Value>"
+
+\end_inset
+
+ Use <Value> for the code segment name.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-constseg
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "Z80!Options!-\\/-constseg <Value>"
+
+\end_inset
+
+ Use <Value> for the const segment name.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+GBZ80 Options
+\begin_inset LatexCommand index
+name "Options GBZ80"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "GBZ80"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-callee-saves-bc
+\series default
+
+\begin_inset LatexCommand index
+name "GBZ80!Options!-\\/-callee-saves-bc"
+
+\end_inset
+
+
+\size large
+
+\size default
+Force a called function to always save BC.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-std-crt0
+\series default
+
+\begin_inset LatexCommand index
+name "Z80!Options!-\\/-no-std-crt0"
+
+\end_inset
+
+ When linking, skip the standard crt0.o object file.
+ You must provide your own crt0.o for your system when linking.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-bo
+\series default
+\InsetSpace ~
+<Num>
+\begin_inset LatexCommand index
+name "GBZ80!Options!-bo <Num>"
+
+\end_inset
+
+ Use code bank <Num>.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-ba
+\series default
+\InsetSpace ~
+<Num>
+\begin_inset LatexCommand index
+name "GBZ80!Options!-ba <Num>"
+
+\end_inset
+
+ Use data bank <Num>.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-codeseg
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "GBZ80!Options!-\\/-codeseg <Value>"
+
+\end_inset
+
+ Use <Value> for the code segment name.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-constseg
+\series default
+\InsetSpace ~
+<Value>
+\begin_inset LatexCommand index
+name "GBZ80!Options!-\\/-constseg <Value>"
+
+\end_inset
+
+ Use <Value> for the const segment name.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Optimization Options
+\begin_inset LatexCommand index
+name "Options optimization"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Optimization options"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-nogcse
+\begin_inset LatexCommand index
+name "-\\/-nogcse"
+
+\end_inset
+
+
+\series default
+ Will not do global subexpression elimination, this option may be used when
+ the compiler creates undesirably large stack/data spaces to store compiler
+ temporaries (
+\emph on
+s
+\emph default
+pill
+\emph on
+loc
+\emph default
+ations, sloc
+\begin_inset LatexCommand index
+name "sloc (spill location)"
+
+\end_inset
+
+).
+ A warning message will be generated when this happens and the compiler
+ will indicate the number of extra bytes it allocated.
+ It is recommended that this option NOT be used, #pragma\InsetSpace ~
+nogcse
+\begin_inset LatexCommand index
+name "\\#pragma nogcse"
+
+\end_inset
+
+ can be used to turn off global subexpression elimination
+\begin_inset LatexCommand index
+name "Subexpression elimination"
+
+\end_inset
+
+ for a given function only.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-noinvariant
+\begin_inset LatexCommand index
+name "-\\/-noinvariant"
+
+\end_inset
+
+
+\series default
+ Will not do loop invariant optimizations, this may be turned off for reasons
+ explained for the previous option.
+ For more details of loop optimizations performed see Loop Invariants in
+ section
+\begin_inset LatexCommand ref
+reference "sub:Loop-Optimizations"
+
+\end_inset
+
+.
+ It is recommended that this option NOT be used, #pragma\InsetSpace ~
+noinvariant
+\begin_inset LatexCommand index
+name "\\#pragma noinvariant"
+
+\end_inset
+
+ can be used to turn off invariant optimizations for a given function only.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-noinduction
+\begin_inset LatexCommand index
+name "-\\/-noinduction"
+
+\end_inset
+
+
+\series default
+ Will not do loop induction optimizations, see section strength reduction
+ for more details.
+ It is recommended that this option is NOT used, #pragma\InsetSpace ~
+noinduction
+\begin_inset LatexCommand index
+name "\\#pragma noinduction"
+
+\end_inset
+
+ can be used to turn off induction optimizations for a given function only.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-nojtbound
+\begin_inset LatexCommand index
+name "-\\/-nojtbound"
+
+\end_inset
+
+
+\size large
+
+\series default
+\size default
+ Will not generate boundary condition check when switch statements
+\begin_inset LatexCommand index
+name "switch statement"
+
+\end_inset
+
+ are implemented using jump-tables.
+ See section
+\begin_inset LatexCommand ref
+reference "sub:'switch'-Statements"
+
+\end_inset
+
+\InsetSpace ~
+Switch Statements for more details.
+ It is recommended that this option is NOT used, #pragma\InsetSpace ~
+nojtbound
+\begin_inset LatexCommand index
+name "\\#pragma nojtbound"
+
+\end_inset
+
+ can be used to turn off boundary checking for jump tables for a given function
+ only.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-noloopreverse
+\begin_inset LatexCommand index
+name "-\\/-noloopreverse"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+Will not do loop reversal
+\begin_inset LatexCommand index
+name "Loop reversing"
+
+\end_inset
+
+optimization.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-
+\series bold
+nolabelopt
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-nolabelopt "
+
+\end_inset
+
+Will not optimize labels (makes the dumpfiles more readable).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-xinit-opt
+\begin_inset LatexCommand index
+name "-\\/-no-xinit-opt"
+
+\end_inset
+
+
+\series default
+ Will not memcpy initialized data from code space into xdata space.
+ This saves a few bytes in code space if you don't have initialized data
+\begin_inset LatexCommand index
+name "Variable initialization"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-nooverlay
+\begin_inset LatexCommand index
+name "-\\/-nooverlay"
+
+\end_inset
+
+
+\series default
+ The compiler will not overlay parameters and local variables of any function,
+ see section Parameters and local variables for more details.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-peep
+\begin_inset LatexCommand index
+name "-\\/-no-peep"
+
+\end_inset
+
+
+\series default
+ Disable peep-hole optimization with built-in rules.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-peep-file
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-peep-file"
+
+\end_inset
+
+\InsetSpace ~
+<filename> This option can be used to use additional rules to be used by
+ the peep hole optimizer.
+ See section
+\begin_inset LatexCommand ref
+reference "sub:Peephole-Optimizer"
+
+\end_inset
+
+\InsetSpace ~
+Peep Hole optimizations for details on how to write these rules.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-peep-asm
+\begin_inset LatexCommand index
+name "-\\/-peep-asm"
+
+\end_inset
+
+
+\series default
+ Pass the inline assembler code through the peep hole optimizer.
+ This can cause unexpected changes to inline assembler code, please go through
+ the peephole optimizer
+\begin_inset LatexCommand index
+name "Peephole optimizer"
+
+\end_inset
+
+ rules defined in the source file tree '<target>/peeph.def' before using
+ this option.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-opt-code-speed
+\begin_inset LatexCommand index
+name "-\\/-opt-code-speed"
+
+\end_inset
+
+
+\series default
+ The compiler will optimize code generation towards fast code, possibly
+ at the expense of code size.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-opt-code-size
+\begin_inset LatexCommand index
+name "-\\/-opt-code-size"
+
+\end_inset
+
+
+\series default
+ The compiler will optimize code generation towards compact code, possibly
+ at the expense of code speed.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Other Options
+\begin_inset LatexCommand index
+name "Options other"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-c\InsetSpace ~
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-compile-only
+\begin_inset LatexCommand index
+name "-\\/-compile-only"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "-c -\\/-compile-only"
+
+\end_inset
+
+
+\series default
+ will compile and assemble the source, but will not call the linkage editor.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\series default
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series bold
+-c1mode
+\begin_inset LatexCommand index
+name "-\\/-c1mode"
+
+\end_inset
+
+
+\series default
+ reads the preprocessed source from standard input and compiles it.
+ The file name for the assembler output must be specified using the -o option.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-E
+\begin_inset LatexCommand index
+name "-E"
+
+\end_inset
+
+
+\series default
+ Run only the C preprocessor.
+ Preprocess all the C source files specified and output the results to standard
+ output.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-o\InsetSpace ~
+<path/file>
+\begin_inset LatexCommand index
+name "-o <path/file>"
+
+\end_inset
+
+
+\series default
+ The output path where everything will be placed or the file name used for
+ all generated output files.
+ If the parameter is a path, it must have a trailing slash (or backslash
+ for the Windows binaries) to be recognized as a path.
+ Note for Windows users: if the path contains spaces, it should be surrounded
+ by quotes.
+ The trailing backslash should be doubled in order to prevent escaping the
+ final quote, for example:
+\emph on
+-o
+\begin_inset Quotes sld
+\end_inset
+
+F:
+\backslash
+Projects
+\backslash
+test3
+\backslash
+output 1
+\backslash
+
+\backslash
+
+\begin_inset Quotes srd
+\end_inset
+
+
+\emph default
+ or put after the final quote, for example:
+\emph on
+-o
+\begin_inset Quotes sld
+\end_inset
+
+F:
+\backslash
+Projects
+\backslash
+test3
+\backslash
+output 1
+\begin_inset Quotes srd
+\end_inset
+
+
+\backslash
+
+\emph default
+.
+ The path using slashes for directory delimiters can be used too, for example:
+
+\emph on
+-o
+\begin_inset Quotes sld
+\end_inset
+
+F:/Projects/test3/output 1/
+\begin_inset Quotes srd
+\end_inset
+
+
+\emph default
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\begin_inset LatexCommand index
+name "-\\/-stack-auto"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+All functions in the source file will be compiled as
+\emph on
+reentrant
+\emph default
+
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+, i.e.
+ the parameters and local variables will be allocated on the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+.
+ See section
+\begin_inset LatexCommand ref
+reference "sec:Parameters-and-Local-Variables"
+
+\end_inset
+
+ Parameters and Local Variables for more details.
+ If this option is used all source files in the project should be compiled
+ with this option.
+ It automatically implies -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-int-long-reent and -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-float-reent.
+
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-callee-saves
+\begin_inset LatexCommand index
+name "-\\/-callee-saves"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "lyx:--callee-saves-function1[,function2][,function3]..."
+
+\end_inset
+
+function1[,function2][,function3]....
+
+\series default
+ The compiler by default uses a caller saves convention for register saving
+ across function calls, however this can cause unnecessary register pushing
+ and popping when calling small functions from larger functions.
+ This option can be used to switch the register saving convention for the
+ function names specified.
+ The compiler will not save registers when calling these functions, no extra
+ code will be generated at the entry and exit (function prologue
+\series bold
+
+\begin_inset LatexCommand index
+name "function prologue"
+
+\end_inset
+
+
+\series default
+ and epilogue
+\series bold
+
+\begin_inset LatexCommand index
+name "function epilogue"
+
+\end_inset
+
+
+\series default
+) for these functions to save and restore the registers used by these functions,
+ this can SUBSTANTIALLY reduce code and improve run time performance of
+ the generated code.
+ In the future the compiler (with inter procedural analysis) will be able
+ to determine the appropriate scheme to use for each function call.
+ DO NOT use this option for built-in functions such as _mulint..., if this
+ option is used for a library function the appropriate library function
+ needs to be recompiled with the same option.
+ If the project consists of multiple source files then all the source file
+ should be compiled with the same -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-callee-saves option string.
+ Also see #pragma\InsetSpace ~
+callee_saves
+\begin_inset LatexCommand index
+name "\\#pragma callee\\_saves"
+
+\end_inset
+
+
+\begin_inset LatexCommand vpageref
+reference "ite:callee_saves-function1[,function2[,function3...]]--"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-all-callee-saves
+\begin_inset LatexCommand index
+name "-\\/-all-callee-saves"
+
+\end_inset
+
+
+\series default
+ Function of -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-callee-saves will be applied to all functions by default.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-debug
+\begin_inset LatexCommand index
+name "-\\/-debug"
+
+\end_inset
+
+
+\series default
+When this option is used the compiler will generate debug information.
+ The debug information collected in a file with .cdb extension can be used
+ with the SDCDB.
+ For more information see documentation for SDCDB.
+ Another file with no extension contains debug information in AOMF or AOMF51
+\begin_inset LatexCommand index
+name "AOMF, AOMF51"
+
+\end_inset
+
+ format which is commonly used by third party tools.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-S
+\begin_inset LatexCommand index
+name "-S"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+Stop after the stage of compilation proper; do not assemble.
+ The output is an assembler code file for the input file specified.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-int-long-reent
+\begin_inset LatexCommand index
+name "-\\/-int-long-reent"
+
+\end_inset
+
+
+\series default
+ Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
+ Note by default these libraries are compiled as non-reentrant.
+ See section Installation for more details.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-cyclomatic
+\begin_inset LatexCommand index
+name "-\\/-cyclomatic"
+
+\end_inset
+
+
+\series default
+This option will cause the compiler to generate an information message for
+ each function in the source file.
+ The message contains some
+\emph on
+important
+\emph default
+ information about the function.
+ The number of edges and nodes the compiler detected in the control flow
+ graph of the function, and most importantly the
+\emph on
+cyclomatic complexity
+\begin_inset LatexCommand index
+name "Cyclomatic complexity"
+
+\end_inset
+
+
+\emph default
+ see section on Cyclomatic Complexity for more details.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-float-reent
+\begin_inset LatexCommand index
+name "-\\/-float-reent"
+
+\end_inset
+
+
+\series default
+ Floating point library is compiled as reentrant
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+.
+ See section Installation for more details.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-funsigned-char
+\begin_inset LatexCommand index
+name "-\\/-funsigned-char"
+
+\end_inset
+
+
+\series default
+ The default signedness for every type is
+\family typewriter
+signed
+\family default
+.
+ In some embedded environments the default signedness of
+\family typewriter
+char
+\family default
+ is
+\family typewriter
+unsigned
+\family default
+.
+ To set the signess for characters to unsigned, use the option -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-funsigned-char.
+ If this option is set and no signedness keyword (unsigned/signed) is given,
+ a char will be signed.
+ All other types are unaffected.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-main-return
+\begin_inset LatexCommand index
+name "-\\/-main-return"
+
+\end_inset
+
+
+\series default
+ This option can be used if the code generated is called by a monitor program
+ or if the main routine includes an endless loop.
+ This option results in slightly smaller code and saves two bytes of stack
+ space.
+ The return from the 'main'
+\begin_inset LatexCommand index
+name "main return"
+
+\end_inset
+
+ function will return to the function calling main.
+ The default setting is to lock up i.e.
+ generate a '
+\family typewriter
+sjmp .
+\family default
+'.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-nostdinc
+\begin_inset LatexCommand index
+name "-\\/-nostdinc"
+
+\end_inset
+
+
+\series default
+ This will prevent the compiler from passing on the default include path
+ to the preprocessor.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-nostdlib
+\begin_inset LatexCommand index
+name "-\\/-nostdlib"
+
+\end_inset
+
+
+\series default
+ This will prevent the compiler from passing on the default library
+\begin_inset LatexCommand index
+name "Libraries"
+
+\end_inset
+
+ path to the linker.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-verbose
+\begin_inset LatexCommand index
+name "-\\/-verbose"
+
+\end_inset
+
+
+\series default
+ Shows the various actions the compiler is performing.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-V
+\begin_inset LatexCommand index
+name "-V"
+
+\end_inset
+
+
+\series default
+ Shows the actual commands the compiler is executing.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-c-code-in-asm
+\begin_inset LatexCommand index
+name "-\\/-no-c-code-in-asm"
+
+\end_inset
+
+
+\series default
+ Hides your ugly and inefficient c-code from the asm file, so you can always
+ blame the compiler :)
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-fverbose-asm
+\begin_inset LatexCommand index
+name "-\\/-no-gen-comments"
+
+\end_inset
+
+
+\series default
+ Include code generator and peep-hole comments in the generated asm files.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-peep-comments
+\begin_inset LatexCommand index
+name "-\\/-no-peep-comments"
+
+\end_inset
+
+
+\series default
+ Don't include peep-hole comments in the generated asm files even if -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-fverbose-asm option is specified.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-i-code-in-asm
+\begin_inset LatexCommand index
+name "-\\/-i-code-in-asm"
+
+\end_inset
+
+
+\series default
+ Include i-codes in the asm file.
+ Sounds like noise but is most helpful for debugging the compiler itself.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-less-pedantic
+\begin_inset LatexCommand index
+name "pedantic"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "-\\/-less-pedantic"
+
+\end_inset
+
+
+\series default
+
+\begin_inset LatexCommand label
+name "lyx:--less-pedantic"
+
+\end_inset
+
+ Disable some of the more pedantic warnings
+\begin_inset LatexCommand index
+name "Warnings"
+
+\end_inset
+
+.
+ For more details, see the less_pedantic pragma
+\begin_inset LatexCommand vpageref
+reference "ite:less_pedantic"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-disable-warning\InsetSpace ~
+<nnnn>
+\begin_inset LatexCommand index
+name "-\\/-disable-warning"
+
+\end_inset
+
+
+\series default
+ Disable specific warning with number <nnnn>.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-Werror
+\begin_inset LatexCommand index
+name "-\\/-Werror"
+
+\end_inset
+
+
+\series default
+ Treat all warnings as errors.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-print-search-dirs
+\begin_inset LatexCommand index
+name "-\\/-print-search-dirs"
+
+\end_inset
+
+
+\series default
+ Display the directories in the compiler's search path
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-vc
+\begin_inset LatexCommand index
+name "-\\/-vc"
+
+\end_inset
+
+
+\series default
+ Display errors and warnings using MSVC style, so you can use SDCC with
+ the visual studio IDE
+\begin_inset LatexCommand index
+name "IDE"
+
+\end_inset
+
+.
+ With SDCC both offering a GCC-like (the default) and a MSVC-like
+\begin_inset LatexCommand index
+name "MSVC output style"
+
+\end_inset
+
+ output style, integration into most programming editors should be straightforwa
+rd.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-use-stdout
+\begin_inset LatexCommand index
+name "-\\/-use-stdout"
+
+\end_inset
+
+
+\series default
+ Send errors and warnings to stdout instead of stderr.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-Wa\InsetSpace ~
+asmOption[,asmOption]
+\series default
+
+\begin_inset LatexCommand index
+name "-Wa asmOption[,asmOption]"
+
+\end_inset
+
+...
+ Pass the asmOption to the assembler
+\begin_inset LatexCommand index
+name "Options assembler"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Assembler options"
+
+\end_inset
+
+.
+ See file sdcc/as/doc/asxhtm.html for assembler options.cd
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-sdcc89
+\begin_inset LatexCommand index
+name "-\\/-std-sdcc89"
+
+\end_inset
+
+
+\series default
+ Generally follow the C89 standard, but allow SDCC features that conflict
+ with the standard (default).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c89
+\begin_inset LatexCommand index
+name "-\\/-std-c89"
+
+\end_inset
+
+
+\series default
+ Follow the C89 standard and disable SDCC features that conflict with the
+ standard.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-sdcc99
+\begin_inset LatexCommand index
+name "-\\/-std-sdcc99"
+
+\end_inset
+
+
+\series default
+ Generally follow the C99 standard, but allow SDCC features that conflict
+ with the standard (incomplete support).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-std-c99
+\begin_inset LatexCommand index
+name "-\\/-std-sdcc99"
+
+\end_inset
+
+
+\series default
+ Follow the C99 standard and disable SDCC features that conflict with the
+ standard (incomplete support).
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-codeseg
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-codeseg <Value>"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "lyx:-codeseg"
+
+\end_inset
+
+\InsetSpace ~
+<Name> The name to be used for the code
+\begin_inset LatexCommand index
+name "code"
+
+\end_inset
+
+ segment, default CSEG.
+ This is useful if you need to tell the compiler to put the code in a special
+ segment so you can later on tell the linker to put this segment in a special
+ place in memory.
+ Can be used for instance when using bank switching to put the code in a
+ bank.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-constseg
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-constseg <Value>"
+
+\end_inset
+
+\InsetSpace ~
+<Name> The name to be used for the const
+\begin_inset LatexCommand index
+name "const"
+
+\end_inset
+
+ segment, default CONST.
+ This is useful if you need to tell the compiler to put the const data in
+ a special segment so you can later on tell the linker to put this segment
+ in a special place in memory.
+ Can be used for instance when using bank switching to put the const data
+ in a bank.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-fdollars-in-identifiers
+\begin_inset LatexCommand index
+name "-\\/-fdollars-in-identifiers"
+
+\end_inset
+
+
+\series default
+ Permit '$' as an identifier character.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-more-pedantic
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-more-pedantic"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "pedantic"
+
+\end_inset
+
+ Actually this is
+\series bold
+\emph on
+not
+\series default
+\emph default
+ a SDCC compiler option but if you want
+\emph on
+more
+\emph default
+ warnings you can use a separate tool dedicated to syntax checking like
+ splint
+\begin_inset LatexCommand label
+name "lyx:more-pedantic-SPLINT"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "lint (syntax checking tool)"
+
+\end_inset
+
+
+\begin_inset LatexCommand url
+target "http://www.splint.org"
+
+\end_inset
+
+.
+ To make your source files parseable by splint you will have to include
+
+\family sans
+lint.h
+\family default
+
+\begin_inset LatexCommand index
+name "splint (syntax checking tool)"
+
+\end_inset
+
+ in your source file and add brackets around extended keywords (like
+\family sans
+
+\begin_inset Quotes sld
+\end_inset
+
+__at\InsetSpace ~
+
+\series bold
+(
+\series default
+0xab
+\series bold
+)
+\series default
+
+\begin_inset Quotes srd
+\end_inset
+
+
+\family default
+ and
+\family sans
+
+\begin_inset Quotes sld
+\end_inset
+
+__interrupt\InsetSpace ~
+(2)
+\begin_inset Quotes srd
+\end_inset
+
+
+\family default
+).
+
+\newline
+Splint has an excellent on line manual at
+\begin_inset LatexCommand url
+target "http://www.splint.org/manual/"
+
+\end_inset
+
+ and it's capabilities go beyond pure syntax checking.
+ You'll need to tell splint the location of SDCC's include files so a typical
+ command line could look like this:
+\newline
+
+\family sans
+splint\InsetSpace ~
+-I\InsetSpace ~
+/usr/local/share/sdcc/include/mcs51/\InsetSpace ~
+\InsetSpace ~
+myprogram.c
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-short-is-8bits
+\series default
+
+\begin_inset LatexCommand index
+name "-\\/-short-is-8bits"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "lyx:--short-is-8bits"
+
+\end_inset
+
+ Treat short as 8-bit (for backward compatibility with older versions of
+ compiler - see section
+\begin_inset LatexCommand ref
+reference "sec:Compatibility-with-previous"
+
+\end_inset
+
+)
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Intermediate Dump Options
+\begin_inset LatexCommand label
+name "sub:Intermediate-Dump-Options"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Options intermediate dump"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Intermediate dump options"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The following options are provided for the purpose of retargetting and debugging
+ the compiler.
+ They provide a means to dump the intermediate code (iCode
+\begin_inset LatexCommand index
+name "iCode"
+
+\end_inset
+
+) generated by the compiler in human readable form at various stages of
+ the compilation process.
+ More on iCodes see chapter
+\begin_inset LatexCommand ref
+reference "sub:The-anatomy-of"
+
+\end_inset
+
+
+\begin_inset Quotes srd
+\end_inset
+
+The anatomy of the compiler
+\begin_inset Quotes srd
+\end_inset
+
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumpraw
+\begin_inset LatexCommand index
+name "-\\/-dumpraw"
+
+\end_inset
+
+
+\series default
+ This option will cause the compiler to dump the intermediate code into
+ a file of named
+\emph on
+<source filename>.dumpraw
+\emph default
+ just after the intermediate code has been generated for a function, i.e.
+ before any optimizations are done.
+ The basic blocks
+\begin_inset LatexCommand index
+name "Basic blocks"
+
+\end_inset
+
+ at this stage ordered in the depth first number, so they may not be in
+ sequence of execution.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumpgcse
+\begin_inset LatexCommand index
+name "-\\/-dumpgcse"
+
+\end_inset
+
+
+\series default
+ Will create a dump of iCodes, after global subexpression elimination
+\begin_inset LatexCommand index
+name "Global subexpression elimination"
+
+\end_inset
+
+, into a file named
+\emph on
+<source filename>.dumpgcse.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumpdeadcode
+\begin_inset LatexCommand index
+name "-\\/-dumpdeadcode"
+
+\end_inset
+
+
+\series default
+ Will create a dump of iCodes, after deadcode elimination
+\begin_inset LatexCommand index
+name "Dead-code elimination"
+
+\end_inset
+
+, into a file named
+\emph on
+<source filename>.dumpdeadcode.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumploop
+\begin_inset LatexCommand index
+name "-\\/-dumploop"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+Will create a dump of iCodes, after loop optimizations
+\begin_inset LatexCommand index
+name "Loop optimization"
+
+\end_inset
+
+, into a file named
+\emph on
+<source filename>.dumploop.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumprange
+\begin_inset LatexCommand index
+name "-\\/-dumprange"
+
+\end_inset
+
+
+\series default
+\size large
+
+\size default
+Will create a dump of iCodes, after live range analysis
+\begin_inset LatexCommand index
+name "Live range analysis"
+
+\end_inset
+
+, into a file named
+\emph on
+<source filename>.dumprange.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumlrange
+\begin_inset LatexCommand index
+name "-\\/-dumlrange"
+
+\end_inset
+
+
+\series default
+ Will dump the life ranges
+\begin_inset LatexCommand index
+name "Live range analysis"
+
+\end_inset
+
+ for all symbols.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumpregassign
+\begin_inset LatexCommand index
+name "-\\/-dumpregassign"
+
+\end_inset
+
+
+\series default
+Will create a dump of iCodes, after register assignment
+\begin_inset LatexCommand index
+name "Register assignment"
+
+\end_inset
+
+, into a file named
+\emph on
+<source filename>.dumprassgn.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumplrange
+\begin_inset LatexCommand index
+name "-\\/-dumplrange"
+
+\end_inset
+
+
+\series default
+ Will create a dump of the live ranges of iTemp's
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-dumpall
+\begin_inset LatexCommand index
+name "-\\/-dumpall"
+
+\end_inset
+
+
+\size large
+
+\series default
+\size default
+Will cause all the above mentioned dumps to be created.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Redirecting output on Windows Shells
+\end_layout
+
+\begin_layout Standard
+By default SDCC writes its error messages to
+\begin_inset Quotes sld
+\end_inset
+
+standard error
+\begin_inset Quotes srd
+\end_inset
+
+.
+ To force all messages to
+\begin_inset Quotes sld
+\end_inset
+
+standard output
+\begin_inset Quotes srd
+\end_inset
+
+ use
+\series bold
+-
+\series default
+\emph on
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series bold
+\emph default
+-
+\series default
+use-stdout
+\begin_inset LatexCommand index
+name "-\\/-use-stdout"
+
+\end_inset
+
+.
+ Additionally, if you happen to have visual studio installed in your windows
+ machine, you can use it to compile your sources using a custom build and
+ the SDCC -
+\emph on
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\emph default
+-vc
+\begin_inset LatexCommand index
+name "-\\/-vc"
+
+\end_inset
+
+ option.
+ Something like this should work:
+\newline
+
+\newline
+
+\series bold
+c:
+\backslash
+sdcc
+\backslash
+bin
+\backslash
+sdcc.exe -
+\series default
+\emph on
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series bold
+\emph default
+-vc -
+\series default
+\emph on
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series bold
+\emph default
+-model-large -c $(InputPath)
+\series default
+
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Environment variables
+\begin_inset LatexCommand index
+name "Environment variables"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+SDCC recognizes the following environment variables:
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+SDCC_LEAVE_SIGNALS
+\begin_inset LatexCommand index
+name "SDCC\\_LEAVE\\_SIGNALS"
+
+\end_inset
+
+
+\series default
+ SDCC installs a signal handler
+\begin_inset LatexCommand index
+name "signal handler"
+
+\end_inset
+
+ to be able to delete temporary files after an user break (^C) or an exception.
+ If this environment variable is set, SDCC won't install the signal handler
+ in order to be able to debug SDCC.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+TMP,\InsetSpace ~
+TEMP,\InsetSpace ~
+TMPDIR
+\begin_inset LatexCommand index
+name "TMP, TEMP, TMPDIR"
+
+\end_inset
+
+
+\series default
+ Path, where temporary files will be created.
+ The order of the variables is the search order.
+ In a standard *nix environment these variables are not set, and there's
+ no need to set them.
+ On Windows it's recommended to set one of them.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+SDCC_HOME
+\begin_inset LatexCommand index
+name "SDCC\\_HOME"
+
+\end_inset
+
+
+\series default
+ Path, see section
+\begin_inset LatexCommand ref
+reference "sub:Install-paths"
+
+\end_inset
+
+\InsetSpace ~
+
+\begin_inset Quotes sld
+\end_inset
+
+ Install Paths
+\begin_inset Quotes srd
+\end_inset
+
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+SDCC_INCLUDE
+\begin_inset LatexCommand index
+name "SDCC\\_INCLUDE"
+
+\end_inset
+
+
+\series default
+ Path, see section
+\begin_inset LatexCommand ref
+reference "sub:Search-Paths"
+
+\end_inset
+
+\InsetSpace ~
+
+\begin_inset Quotes sld
+\end_inset
+
+Search Paths
+\begin_inset Quotes srd
+\end_inset
+
+.
+\end_layout
+
+\begin_layout List
+\labelwidthstring 00.00.0000
+
+\series bold
+SDCC_LIB
+\begin_inset LatexCommand index
+name "SDCC\\_LIB"
+
+\end_inset
+
+
+\series default
+ Path, see section
+\begin_inset LatexCommand ref
+reference "sub:Search-Paths"
+
+\end_inset
+
+\InsetSpace ~
+
+\begin_inset Quotes sld
+\end_inset
+
+Search Paths
+\begin_inset Quotes srd
+\end_inset
+
+..
+\end_layout
+
+\begin_layout Standard
+There are some more environment variables recognized by SDCC, but these
+ are solely used for debugging purposes.
+ They can change or disappear very quickly, and will never be documented.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Storage Class Language Extensions
+\end_layout
+
+\begin_layout Subsection
+MCS51/DS390 Storage Class
+\begin_inset LatexCommand index
+name "Storage class"
+
+\end_inset
+
+ Language Extensions
+\end_layout
+
+\begin_layout Standard
+In addition to the ANSI storage classes SDCC allows the following MCS51
+ specific storage classes:
+\end_layout
+
+\begin_layout Subsubsection
+data
+\begin_inset LatexCommand index
+name "data (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_data (mcs51, ds390 storage class)"
+
+\end_inset
+
+ / near
+\begin_inset LatexCommand index
+name "near (storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_near (storage class)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+This is the
+\series bold
+default
+\series default
+ storage class for the Small Memory model (
+\emph on
+data
+\emph default
+ and
+\emph on
+near
+\emph default
+ or the more ANSI-C compliant forms
+\emph on
+__data
+\emph default
+ and
+\emph on
+__near
+\emph default
+ can be used synonymously).
+ Variables declared with this storage class will be allocated in the directly
+ addressable portion of the internal RAM of a 8051, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__data unsigned char test_data;
+\end_layout
+
+\begin_layout Standard
+Writing 0x01 to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+75*00 01\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+_test_data,#0x01
+\end_layout
+
+\begin_layout Subsubsection
+xdata
+\begin_inset LatexCommand index
+name "xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ / far
+\begin_inset LatexCommand index
+name "far (storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_far (storage class)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Variables declared with this storage class will be placed in the external
+ RAM.
+ This is the
+\series bold
+default
+\series default
+ storage class for the Large Memory model, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__xdata unsigned char test_xdata;
+\end_layout
+
+\begin_layout Standard
+Writing 0x01 to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+90s00r00\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+dptr,#_test_xdata
+\newline
+74\InsetSpace ~
+01\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+a,#0x01
+\newline
+F0\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movx\InsetSpace ~
+@dptr,a
+\end_layout
+
+\begin_layout Subsubsection
+idata
+\begin_inset LatexCommand index
+name "idata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_idata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Variables declared with this storage class will be allocated into the indirectly
+ addressable portion of the internal ram of a 8051, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__idata unsigned char test_idata;
+\end_layout
+
+\begin_layout Standard
+Writing 0x01 to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+78r00\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+r0,#_test_idata
+\newline
+76\InsetSpace ~
+01\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+@r0,#0x01
+\end_layout
+
+\begin_layout Standard
+Please note, the first 128 byte of idata physically access the same RAM
+ as the data memory.
+ The original 8051 had 128 byte idata memory, nowadays most devices have
+ 256 byte idata memory.
+ The stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ is located in idata memory.
+\end_layout
+
+\begin_layout Subsubsection
+pdata
+\begin_inset LatexCommand index
+name "pdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_pdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Paged xdata access is just as straightforward as using the other addressing
+ modes of a 8051.
+ It is typically located at the start of xdata and has a maximum size of
+ 256 bytes.
+ The following example writes 0x01 to the pdata variable.
+ Please note, pdata access physically accesses xdata memory.
+ The high byte of the address is determined by port P2
+\begin_inset LatexCommand index
+name "P2 (mcs51 sfr)"
+
+\end_inset
+
+(or in case of some 8051 variants by a separate Special Function Register,
+ see section
+\begin_inset LatexCommand ref
+reference "sub:MCS51-variants"
+
+\end_inset
+
+).
+ This is the
+\series bold
+default
+\series default
+ storage class for the Medium Memory model, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__pdata unsigned char test_pdata;
+\end_layout
+
+\begin_layout Standard
+Writing 0x01 to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+78r00\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r0,#_test_pdata
+\newline
+74 01\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov a,#0x01
+\newline
+F2\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movx @r0,a
+\end_layout
+
+\begin_layout Standard
+If the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xstack
+\begin_inset LatexCommand index
+name "-\\/-xstack"
+
+\end_inset
+
+ option is used the pdata memory area is followed by the xstack memory area
+ and the sum of their sizes is limited to 256 bytes.
+\end_layout
+
+\begin_layout Subsubsection
+code
+\begin_inset LatexCommand index
+name "code"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_code"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+'Variables' declared with this storage class will be placed in the code
+ memory:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__code unsigned char test_code;
+\end_layout
+
+\begin_layout Standard
+Read access to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+90s00r6F\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov dptr,#_test_code
+\newline
+E4\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+clr a
+\newline
+93\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movc a,@a+dptr
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+char
+\family default
+ indexed arrays of characters in code memory can be accessed efficiently:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__code char test_array[] = {'c','h','e','a','p'};
+\end_layout
+
+\begin_layout Standard
+Read access to this array using an 8-bit unsigned index generates the assembly
+ code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+E5*00\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov a,_index
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+90s00r41\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov dptr,#_test_array
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+93\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movc a,@a+dptr
+\end_layout
+
+\begin_layout Subsubsection
+bit
+\begin_inset LatexCommand index
+name "bit"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_bit"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+This is a data-type and a storage class specifier.
+ When a variable is declared as a bit, it is allocated into the bit addressable
+ memory of 8051, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__bit test_bit;
+\end_layout
+
+\begin_layout Standard
+Writing 1 to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+D2*00\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+setb\InsetSpace ~
+_test_bit
+\end_layout
+
+\begin_layout Standard
+The bit addressable memory consists of 128 bits which are located from 0x20
+ to 0x2f in data memory.
+
+\newline
+Apart from this 8051 specific storage class most architectures support
+ ANSI-C bitfields
+\begin_inset LatexCommand index
+name "bitfields"
+
+\end_inset
+
+
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+Not really meant as examples, but nevertheless showing what bitfields are
+ about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
+\end_layout
+
+\end_inset
+
+.
+ In accordance with ISO/IEC 9899 bits and bitfields without an explicit
+ signed modifier are implemented as unsigned.
+\end_layout
+
+\begin_layout Subsubsection
+sfr
+\begin_inset LatexCommand index
+name "sfr"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_sfr"
+
+\end_inset
+
+ / sfr16
+\begin_inset LatexCommand index
+name "sfr16"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_sfr16"
+
+\end_inset
+
+ / sfr32
+\begin_inset LatexCommand index
+name "sfr32"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_sfr32"
+
+\end_inset
+
+ / sbit
+\begin_inset LatexCommand index
+name "\\_\\_sbit"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "sbit"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Like the bit keyword,
+\emph on
+sfr / sfr16 / sfr32 / sbit
+\emph default
+ signify both a data-type and storage class, they are used to describe the
+
+\emph on
+s
+\emph default
+pecial
+\emph on
+f
+\emph default
+unction
+\emph on
+r
+\emph default
+egisters and
+\emph on
+s
+\emph default
+pecial
+\emph on
+bit
+\emph default
+ variables of a 8051, eg:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__sfr __at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_at"
+
+\end_inset
+
+ (0x80) P0;\InsetSpace ~
+ /* special function register P0 at location 0x80 */
+\newline
+
+\newline
+/* 16 bit
+ special function register combination for timer 0
+\newline
+\InsetSpace ~
+\InsetSpace ~
+ with the high byte at
+ location 0x8C and the low byte at location 0x8A */
+\newline
+__sfr16 __at (0x8C8A)
+ TMR0;
+\newline
+
+\newline
+__sbit __at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_at"
+
+\end_inset
+
+ (0xd7) CY;\InsetSpace ~
+ /* CY (Carry Flag
+\begin_inset LatexCommand index
+name "Flags"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Carry flag"
+
+\end_inset
+
+) */
+\end_layout
+
+\begin_layout Standard
+Special function registers which are located on an address dividable by
+ 8 are bit-addressable, an
+\emph on
+sbit
+\emph default
+ addresses a specific bit within these sfr.
+\newline
+16 Bit and 32 bit special function
+ register combinations which require a certain access order are better not
+ declared using
+\emph on
+sfr16
+\emph default
+ or
+\emph on
+sfr32.
+
+\emph default
+ Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
+ this is not guaranteed.
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Please note, if you use a header file which was written for another compiler
+ then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
+ likely be
+\emph on
+not
+\emph default
+ compatible.
+ Specifically the syntax
+\family typewriter
+\InsetSpace ~
+sfr P0 = 0x80;\InsetSpace ~
+
+\family default
+ is compiled
+\emph on
+without warning
+\emph default
+ by SDCC to an assignment of 0x80 to a variable called P0
+\family typewriter
+
+\begin_inset Marginal
+status collapsed
+
+\begin_layout Standard
+
+\series bold
+\InsetSpace ~
+!
+\end_layout
+
+\end_inset
+
+.
+
+\family default
+
+\series bold
+Nevertheless it is possible to write header files
+\begin_inset LatexCommand index
+name "Header files"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Include files"
+
+\end_inset
+
+ which can be shared among different compilers (see section
+\begin_inset LatexCommand ref
+reference "sec:Porting-code-to-other-compilers"
+
+\end_inset
+
+).
+
+\end_layout
+
+\begin_layout Subsubsection
+Pointers
+\begin_inset LatexCommand index
+name "Pointer"
+
+\end_inset
+
+ to MCS51/DS390 specific memory spaces
+\end_layout
+
+\begin_layout Standard
+SDCC allows (via language extensions) pointers to explicitly point to any
+ of the memory spaces
+\begin_inset LatexCommand index
+name "Memory model"
+
+\end_inset
+
+ of the 8051.
+ In addition to the explicit pointers, the compiler uses (by default) generic
+ pointers which can be used to point to any of the memory spaces.
+\newline
+
+\newline
+Pointer
+ declaration examples:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+/* pointer physically in internal ram pointing to object in external ram
+ */
+\newline
+__xdata unsigned char * __data p;
+\newline
+
+\newline
+/* pointer physically in external ram
+ pointing to object in internal ram */
+\newline
+__data unsigned char * __xdata p;
+\newline
+
+\newline
+/*
+ pointer physically in code rom pointing to data in xdata space */
+\newline
+__xdata
+ unsigned char * __code p;
+\newline
+
+\newline
+/* pointer physically in code space pointing to
+ data in code space */
+\newline
+__code unsigned char * __code p;
+\newline
+
+\newline
+/* generic pointer
+ physically located in xdata space */
+\newline
+unsigned char * __xdata p;
+\newline
+
+\newline
+/* generic
+ pointer physically located in default memory space */
+\newline
+unsigned char * p;
+\newline
+
+\newline
+/*
+ the following is a function pointer
+\begin_inset LatexCommand index
+name "function pointer"
+
+\end_inset
+
+ physically located in data space */
+\newline
+char (* __data fp)(void);
+\end_layout
+
+\begin_layout Standard
+Well you get the idea.
+
+\newline
+
+\newline
+All unqualified pointers are treated as 3-byte (4-byte for the ds390)
+\emph on
+generic
+\emph default
+ pointers.
+
+\size small
+
+\newline
+
+\newline
+
+\size default
+The highest order byte of the
+\emph on
+generic
+\emph default
+ pointers contains the data space information.
+ Assembler support routines are called whenever data is stored or retrieved
+ using
+\emph on
+generic
+\emph default
+ pointers.
+ These are useful for developing reusable library
+\begin_inset LatexCommand index
+name "Libraries"
+
+\end_inset
+
+ routines.
+ Explicitly specifying the pointer
+\begin_inset LatexCommand index
+name "pointer"
+
+\end_inset
+
+ type will generate the most efficient code.
+\end_layout
+
+\begin_layout Subsubsection
+Notes on MCS51 memory
+\begin_inset LatexCommand index
+name "MCS51 memory"
+
+\end_inset
+
+ layout
+\end_layout
+
+\begin_layout Standard
+The 8051 family of microcontrollers have a minimum of 128 bytes of internal
+ RAM memory which is structured as follows:
+\newline
+
+\newline
+- Bytes 00-1F - 32 bytes to hold
+ up to 4 banks of the registers R0 to R7,
+\newline
+- Bytes 20-2F - 16 bytes to hold
+ 128 bit
+\begin_inset LatexCommand index
+name "bit"
+
+\end_inset
+
+ variables and,
+\newline
+- Bytes 30-7F - 80 bytes for general purpose use.
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Additionally some members of the MCS51 family may have up to 128 bytes of
+ additional, indirectly addressable, internal RAM memory (
+\emph on
+idata
+\emph default
+
+\begin_inset LatexCommand index
+name "idata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_idata (mcs51, ds390 storage class)"
+
+\end_inset
+
+).
+ Furthermore, some chips may have some built in external memory (
+\emph on
+xdata
+\emph default
+
+\begin_inset LatexCommand index
+name "xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+) which should not be confused with the internal, directly addressable RAM
+ memory (
+\emph on
+data
+\emph default
+
+\begin_inset LatexCommand index
+name "data (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_data (mcs51, ds390 storage class)"
+
+\end_inset
+
+).
+ Sometimes this built in
+\emph on
+xdata
+\emph default
+ memory has to be activated before using it (you can probably find this
+ information on the datasheet of the microcontroller your are using, see
+ also section
+\begin_inset LatexCommand ref
+reference "sub:Startup-Code"
+
+\end_inset
+
+\InsetSpace ~
+Startup-Code).
+\end_layout
+
+\begin_layout Standard
+Normally SDCC will only use the first bank
+\begin_inset LatexCommand index
+name "register bank (mcs51, ds390)"
+
+\end_inset
+
+ of registers (register bank 0), but it is possible to specify that other
+ banks of registers (keyword
+\emph on
+using
+\emph default
+
+\emph on
+
+\begin_inset LatexCommand index
+name "using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\emph default
+) should be used for example in interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_interrupt"
+
+\end_inset
+
+ routines.
+ By default, the compiler will place the stack after the last byte of allocated
+ memory for variables.
+ For example, if the first 2 banks of registers are used, and only four
+ bytes are used for
+\emph on
+data
+\emph default
+ variables, it will position the base of the internal stack at address 20
+ (0x14).
+ This implies that as the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ grows, it will use up the remaining register banks, and the 16 bytes used
+ by the 128 bit variables, and 80 bytes for general purpose use.
+ If any bit variables are used, the data variables will be placed in unused
+ register banks and after the byte holding the last bit variable.
+ For example, if register banks 0 and 1 are used, and there are 9 bit variables
+ (two bytes used),
+\emph on
+data
+\emph default
+ variables will be placed starting from address 0x10 to 0x20 and continue
+ at address 0x22.
+ You can also use -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-data-loc
+\begin_inset LatexCommand index
+name "-\\/-data-loc <Value>"
+
+\end_inset
+
+ to specify the start address of the
+\emph on
+data
+\emph default
+ and -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-iram-size
+\begin_inset LatexCommand index
+name "-\\/-iram-size <Value>"
+
+\end_inset
+
+ to specify the size of the total internal RAM (
+\emph on
+data
+\emph default
++
+\emph on
+idata
+\emph default
+).
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+By default the 8051 linker will place the stack after the last byte of (i)data
+ variables.
+ Option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-loc
+\begin_inset LatexCommand index
+name "-\\/-stack-loc <Value>"
+
+\end_inset
+
+ allows you to specify the start of the stack, i.e.
+ you could start it after any data in the general purpose area.
+ If your microcontroller has additional indirectly addressable internal
+ RAM (
+\emph on
+idata
+\emph default
+) you can place the stack on it.
+ You may also need to use -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xdata-loc
+\begin_inset LatexCommand index
+name "-\\/-xdata-loc<Value>"
+
+\end_inset
+
+ to set the start address of the external RAM (
+\emph on
+xdata
+\emph default
+) and -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xram-size
+\begin_inset LatexCommand index
+name "-\\/-xram-size <Value>"
+
+\end_inset
+
+ to specify its size.
+ Same goes for the code memory, using -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-code-loc
+\begin_inset LatexCommand index
+name "-\\/-code-loc <Value>"
+
+\end_inset
+
+ and -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-code-size
+\begin_inset LatexCommand index
+name "-\\/-code-size <Value>"
+
+\end_inset
+
+.
+ If in doubt, don't specify any options and see if the resulting memory
+ layout is appropriate, then you can adjust it.
+\end_layout
+
+\begin_layout Standard
+The linker generates two files with memory allocation information.
+ The first, with extension .map
+\begin_inset LatexCommand index
+name "<file>.map"
+
+\end_inset
+
+ shows all the variables and segments.
+ The second with extension .mem
+\begin_inset LatexCommand index
+name "<file>.mem"
+
+\end_inset
+
+ shows the final memory layout.
+ The linker will complain either if memory segments overlap, there is not
+ enough memory, or there is not enough space for stack.
+ If you get any linking warnings and/or errors related to stack or segments
+ allocation, take a look at either the .map or .mem files to find out what
+ the problem is.
+ The .mem file may even suggest a solution to the problem.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Z80/Z180 Storage Class
+\begin_inset LatexCommand index
+name "Z80!Storage class"
+
+\end_inset
+
+ Language Extensions
+\end_layout
+
+\begin_layout Subsubsection
+sfr
+\begin_inset LatexCommand index
+name "sfr"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_sfr"
+
+\end_inset
+
+ (in/out to 8-bit addresses)
+\end_layout
+
+\begin_layout Standard
+The Z80
+\begin_inset LatexCommand index
+name "Z80"
+
+\end_inset
+
+ family has separate address spaces for memory and
+\emph on
+i
+\emph default
+nput/
+\emph on
+o
+\emph default
+utput memory.
+ I/O memory
+\begin_inset LatexCommand index
+name "I/O memory (Z80, Z180)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Z80!I/O memory"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Z180!I/O memory"
+
+\end_inset
+
+ is accessed with special instructions, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+sfr at 0x78 IoPort;\InsetSpace ~
+\InsetSpace ~
+/* define a var in I/O space at 78h called IoPort */
+
+\end_layout
+
+\begin_layout Standard
+Writing 0x01 to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+3E 01\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ld a,#0x01
+\newline
+D3 78\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+out (_IoPort),a
+\end_layout
+
+\begin_layout Subsubsection
+banked sfr
+\begin_inset LatexCommand index
+name "sfr"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_sfr"
+
+\end_inset
+
+ (in/out to 16-bit addresses)
+\end_layout
+
+\begin_layout Standard
+The keyword
+\emph on
+banked
+\emph default
+ is used to support 16 bit addresses in I/O memory e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+sfr banked at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_at"
+
+\end_inset
+
+ 0x123 IoPort;
+\end_layout
+
+\begin_layout Standard
+Writing 0x01 to this variable generates the assembly code:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+01 23 01\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ld bc,#_IoPort
+\newline
+3E 01\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ld a,#0x01
+\newline
+ED 79\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+out (c),a
+\end_layout
+
+\begin_layout Subsubsection
+sfr
+\begin_inset LatexCommand index
+name "sfr"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_sfr"
+
+\end_inset
+
+ (in0/out0 to 8 bit addresses on Z180
+\begin_inset LatexCommand index
+name "Z180"
+
+\end_inset
+
+/HD64180
+\begin_inset LatexCommand index
+name "HD64180 (see Z180)"
+
+\end_inset
+
+)
+\end_layout
+
+\begin_layout Standard
+The compiler option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-portmode
+\begin_inset LatexCommand index
+name "Z180!Options!-\\/-portmode"
+
+\end_inset
+
+=180 (80) and a compiler #pragma\InsetSpace ~
+portmode
+\begin_inset LatexCommand index
+name "Z180!Pragmas!\\#pragma portmode"
+
+\end_inset
+
+ z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
+ns
+\family typewriter
+in0/out0
+\family default
+ instead of
+\family typewriter
+in/out
+\family default
+.
+ If you include the file z180.h this will be set automatically.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+HC08 Storage Class
+\begin_inset LatexCommand index
+name "HC08!Storage class"
+
+\end_inset
+
+ Language Extensions
+\end_layout
+
+\begin_layout Subsubsection
+data
+\begin_inset LatexCommand index
+name "data (hc08 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_data (hc08 storage class)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The data storage class declares a variable that resides in the first 256
+ bytes of memory (the direct page).
+ The HC08
+\begin_inset LatexCommand index
+name "HC08"
+
+\end_inset
+
+ is most efficient at accessing variables (especially pointers) stored here.
+\end_layout
+
+\begin_layout Subsubsection
+xdata
+\begin_inset LatexCommand index
+name "xdata (hc08 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_xdata (hc08 storage class)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The xdata storage class declares a variable that can reside anywhere in
+ memory.
+ This is the default if no storage class is specified.
+
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Other SDCC language extensions
+\begin_inset LatexCommand index
+name "Other SDCC language extensions"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Binary constants
+\end_layout
+
+\begin_layout Standard
+SDCC supports the use of binary constants, such as 0b01100010.
+ This feature is only enabled when the compiler is invoked using --std-sdccxx.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Absolute Addressing
+\begin_inset LatexCommand index
+name "Absolute addressing"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Data items can be assigned an absolute address with the
+\emph on
+at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_at"
+
+\end_inset
+
+ <address>
+\emph default
+ keyword, in addition to a storage class, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+xdata
+\begin_inset LatexCommand index
+name "xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_at"
+
+\end_inset
+
+ 0x7ffe unsigned int chksum;
+\end_layout
+
+\begin_layout Standard
+or, better conforming to ISO/IEC 9899 C:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__xdata __at (0x7ffe) unsigned int chksum;
+\end_layout
+
+\begin_layout Standard
+In the above example the variable chksum will be located at 0x7ffe and 0x7fff
+ of the external ram.
+ The compiler does
+\emph on
+not
+\emph default
+ reserve any space for variables declared in this way
+\begin_inset Marginal
+status collapsed
+
+\begin_layout Standard
+
+\series bold
+\InsetSpace ~
+!
+\end_layout
+
+\end_inset
+
+ (they are implemented with an equate in the assembler).
+ Thus it is left to the programmer to make sure there are no overlaps with
+ other variables that are declared without the absolute address.
+ The assembler listing file (.lst
+\begin_inset LatexCommand index
+name "<file>.lst"
+
+\end_inset
+
+) and the linker output files (.rst
+\begin_inset LatexCommand index
+name "<file>.rst"
+
+\end_inset
+
+) and (.map
+\begin_inset LatexCommand index
+name "<file>.map"
+
+\end_inset
+
+) are good places to look for such overlaps.
+\end_layout
+
+\begin_layout Standard
+If however you provide an initializer
+\begin_inset LatexCommand index
+name "Variable initialization"
+
+\end_inset
+
+ actual memory allocation will take place and overlaps will be detected
+ by the linker.
+ E.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__code __at (0x7ff0) char Id[5] =
+\begin_inset Quotes sld
+\end_inset
+
+SDCC
+\begin_inset Quotes srd
+\end_inset
+
+;
+\end_layout
+
+\begin_layout Standard
+In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
+ in code memory.
+\end_layout
+
+\begin_layout Standard
+In case of memory mapped I/O devices the keyword
+\emph on
+volatile
+\emph default
+ has to be used to tell the compiler that accesses might not be removed:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+volatile
+\begin_inset LatexCommand index
+name "volatile"
+
+\end_inset
+
+ __xdata
+\begin_inset LatexCommand index
+name "xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ __at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+ (0x8000) unsigned char PORTA_8255;
+\end_layout
+
+\begin_layout Standard
+For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
+r) array
+\family typewriter
+\size footnotesize
+
+\begin_inset LatexCommand index
+name "Aligned array"
+
+\end_inset
+
+
+\family default
+\size default
+ starts at a block (256 byte) boundary
+\begin_inset LatexCommand index
+name "block boundary"
+
+\end_inset
+
+ (section
+\begin_inset LatexCommand ref
+reference "sub:A-Step-by Assembler Introduction"
+
+\end_inset
+
+ has an example).
+\newline
+Absolute addresses can be specified for variables in all
+ storage classes, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__bit
+\begin_inset LatexCommand index
+name "bit"
+
+\end_inset
+
+ __at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+ (0x02) bvar;
+\end_layout
+
+\begin_layout Standard
+The above example will allocate the variable at offset 0x02 in the bit-addressab
+le space.
+ There is no real advantage to assigning absolute addresses to variables
+ in this manner, unless you want strict control over all the variables allocated.
+ One possible use would be to write hardware portable code.
+ For example, if you have a routine that uses one or more of the microcontroller
+ I/O pins, and such pins are different for two different hardwares, you
+ can declare the I/O pins in your routine using:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+extern volatile
+\begin_inset LatexCommand index
+name "volatile"
+
+\end_inset
+
+ __bit MOSI;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* master out, slave in */
+\newline
+extern volatile __bit MISO;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* master
+ in, slave out */
+\newline
+extern volatile __bit MCLK;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* master clock */
+\newline
+
+\newline
+/* Input and
+ Output of a byte on a 3-wire serial bus.
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+If needed adapt polarity of clock,
+ polarity of data and bit order
+\newline
+\InsetSpace ~
+*/
+\newline
+unsigned char spi_io(unsigned char out_byte)
+
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+unsigned char i=8;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+do {
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+MOSI = out_byte & 0x80;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+out_byte <<= 1;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+MCLK =
+ 1;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* _asm nop _endasm; */\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* for slow peripherals */
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+if(MISO)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+out_byte +=
+ 1;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+MCLK = 0;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+} while(--i);
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+return out_byte;
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+Then, someplace in the code for the first hardware you would use
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__bit __at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_at"
+
+\end_inset
+
+ (0x80) MOSI;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* I/O port 0, bit 0 */
+\newline
+__bit __at (0x81) MISO;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* I/O port 0,
+ bit 1 */
+\newline
+__bit __at (0x82) MCLK;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* I/O port 0, bit 2 */
+\end_layout
+
+\begin_layout Standard
+Similarly, for the second hardware you would use
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__bit __at (0x83) MOSI;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* I/O port 0, bit 3 */
+\newline
+__bit __at (0x91) MISO;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/*
+ I/O port 1, bit 1 */
+\newline
+__bit
+\begin_inset LatexCommand index
+name "bit"
+
+\end_inset
+
+ __at (0x92) MCLK;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* I/O port 1, bit 2 */
+\end_layout
+
+\begin_layout Standard
+and you can use the same hardware dependent routine without changes, as
+ for example in a library.
+ This is somehow similar to sbit, but only one absolute address has to be
+ specified in the whole project.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Parameters
+\begin_inset LatexCommand index
+name "Parameters"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "function parameter"
+
+\end_inset
+
+ & Local Variables
+\begin_inset LatexCommand index
+name "local variables"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "sec:Parameters-and-Local-Variables"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Automatic (local) variables and parameters to functions can either be placed
+ on the stack or in data-space.
+ The default action of the compiler is to place these variables in the internal
+ RAM (for small model) or external RAM (for medium or large model).
+ This in fact makes them similar to
+\emph on
+static
+\begin_inset LatexCommand index
+name "static"
+
+\end_inset
+
+
+\emph default
+ so by default functions are non-reentrant
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+.
+
+\newline
+
+\newline
+They can be placed on the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ by using the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\begin_inset LatexCommand index
+name "-\\/-stack-auto"
+
+\end_inset
+
+
+\emph default
+ option, by using
+\emph on
+#pragma\InsetSpace ~
+stackauto
+\emph default
+
+\begin_inset LatexCommand index
+name "\\#pragma stackauto"
+
+\end_inset
+
+ or by using the
+\emph on
+reentrant
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+
+\emph default
+ keyword in the function declaration, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+unsigned char foo(char i) __reentrant
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+Since stack space on 8051 is limited, the
+\emph on
+reentrant
+\emph default
+ keyword or the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\emph default
+ option should be used sparingly.
+ Note that the reentrant keyword just means that the parameters & local
+ variables will be allocated to the stack, it
+\emph on
+does not
+\emph default
+ mean that the function is register bank
+\begin_inset LatexCommand index
+name "register bank (mcs51, ds390)"
+
+\end_inset
+
+ independent.
+\newline
+
+\newline
+Local variables
+\begin_inset LatexCommand index
+name "local variables"
+
+\end_inset
+
+ can be assigned storage classes and absolute
+\begin_inset LatexCommand index
+name "Absolute addressing"
+
+\end_inset
+
+ addresses, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+unsigned char foo()
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+__xdata unsigned char i;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+__bit bvar;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+__data __at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+ (0x31) unsigned char j;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+In the above example the variable
+\emph on
+i
+\emph default
+ will be allocated in the external ram,
+\emph on
+bvar
+\emph default
+ in bit addressable space and
+\emph on
+j
+\emph default
+ in internal ram.
+ When compiled with
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\emph default
+ or when a function is declared as
+\emph on
+reentrant
+\emph default
+ this should only be done for static variables.
+\end_layout
+
+\begin_layout Standard
+Parameters
+\begin_inset LatexCommand index
+name "function parameter"
+
+\end_inset
+
+ however are not allowed any storage class
+\begin_inset LatexCommand index
+name "Storage class"
+
+\end_inset
+
+, (storage classes for parameters will be ignored), their allocation is
+ governed by the memory model in use, and the reentrancy options.
+\end_layout
+
+\begin_layout Standard
+It is however allowed to use bit parameters in reentrant functions and also
+ non-static local bit variables are supported.
+ Efficient use is limited to 8 semi-bitregisters in bit space.
+ They are pushed and popped to stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ as a single byte just like the normal registers.
+\end_layout
+
+\begin_layout Section
+Overlaying
+\begin_inset LatexCommand label
+name "sub:Overlaying"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Overlaying"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+For non-reentrant
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+ functions SDCC will try to reduce internal ram space usage by overlaying
+ parameters and local variables of a function (if possible).
+ Parameters and local variables
+\begin_inset LatexCommand index
+name "local variables"
+
+\end_inset
+
+ of a function will be allocated to an overlayable segment if the function
+ has
+\emph on
+no other function calls and the function is non-reentrant and the memory
+ model
+\begin_inset LatexCommand index
+name "Memory model"
+
+\end_inset
+
+ is small.
+
+\emph default
+ If an explicit storage class
+\begin_inset LatexCommand index
+name "Storage class"
+
+\end_inset
+
+ is specified for a local variable, it will NOT be overlaid.
+\end_layout
+
+\begin_layout Standard
+Note that the compiler (not the linkage editor) makes the decision for overlayin
+g the data items.
+ Functions that are called from an interrupt service routine
+\begin_inset Marginal
+status collapsed
+
+\begin_layout Standard
+
+\series bold
+!
+\end_layout
+
+\end_inset
+
+ should be preceded by a #pragma\InsetSpace ~
+nooverlay
+\begin_inset LatexCommand index
+name "\\#pragma nooverlay"
+
+\end_inset
+
+ if they are not reentrant.
+\end_layout
+
+\begin_layout Standard
+Also note that the compiler does not do any processing of inline assembler
+ code, so the compiler might incorrectly assign local variables and parameters
+ of a function into the overlay segment if the inline assembler code calls
+ other c-functions that might use the overlay.
+ In that case the #pragma\InsetSpace ~
+nooverlay should be used.
+\end_layout
+
+\begin_layout Standard
+Parameters and local variables of functions that contain 16 or 32 bit multiplica
+tion
+\begin_inset LatexCommand index
+name "Multiplication"
+
+\end_inset
+
+ or division
+\begin_inset LatexCommand index
+name "Division"
+
+\end_inset
+
+ will NOT be overlaid since these are implemented using external functions,
+ e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+#pragma save
+\newline
+#pragma nooverlay
+\begin_inset LatexCommand index
+name "\\#pragma nooverlay"
+
+\end_inset
+
+
+\newline
+void set_error(unsigned char errcd)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+P3 = errcd;
+\newline
+}
+\newline
+#pragma restore
+\newline
+
+\newline
+void
+ some_isr () __interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ (2)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+set_error(10);
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+In the above example the parameter
+\emph on
+errcd
+\emph default
+ for the function
+\emph on
+set_error
+\emph default
+ would be assigned to the overlayable segment if the #pragma\InsetSpace ~
+nooverlay was
+ not present, this could cause unpredictable runtime behavior when called
+ from an interrupt service routine.
+ The #pragma\InsetSpace ~
+nooverlay ensures that the parameters and local variables for
+ the function are NOT overlaid.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Interrupt Service Routines
+\begin_inset LatexCommand label
+name "sub:Interrupt-Service-Routines"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+General Information
+\end_layout
+
+\begin_layout Standard
+SDCC allows
+\emph on
+i
+\emph default
+nterrupt
+\emph on
+s
+\emph default
+ervice
+\emph on
+r
+\emph default
+outines to be coded in C, with some extended keywords.
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+void timer_isr (void) __interrupt (1) __using (1)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+The optional number following the
+\emph on
+interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_interrupt"
+
+\end_inset
+
+
+\emph default
+ keyword is the interrupt number this routine will service.
+ When present, the compiler will insert a call to this routine in the interrupt
+ vector table
+\begin_inset LatexCommand index
+name "interrupt vector table"
+
+\end_inset
+
+ for the interrupt number specified.
+ If you have multiple source files in your project, interrupt service routines
+ can be present in any of them, but a prototype of the isr MUST be present
+ or included in the file that contains the function
+\emph on
+main
+\emph default
+.
+ The optional (8051 specific) keyword
+\emph on
+using
+\begin_inset LatexCommand index
+name "using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\emph default
+ can be used to tell the compiler to use the specified register bank when
+ generating code for this function.
+
+\newline
+Interrupt service routines open the door for some very interesting bugs:
+\end_layout
+
+\begin_layout Subsubsection
+\begin_inset LatexCommand label
+name "sub:Common-interrupt-pitfall-volatile"
+
+\end_inset
+
+Common interrupt pitfall: variable not declared
+\emph on
+volatile
+\end_layout
+
+\begin_layout Standard
+If an interrupt service routine changes variables which are accessed by
+ other functions these variables have to be declared
+\emph on
+volatile
+\emph default
+
+\begin_inset LatexCommand index
+name "volatile"
+
+\end_inset
+
+.
+ See
+\begin_inset LatexCommand url
+target "http://en.wikipedia.org/wiki/Volatile_variable"
+
+\end_inset
+
+ .
+\end_layout
+
+\begin_layout Subsubsection
+\begin_inset LatexCommand label
+name "sub:Common-interrupt-pitfall-non-atomic"
+
+\end_inset
+
+Common interrupt pitfall:
+\emph on
+non-atomic access
+\end_layout
+
+\begin_layout Standard
+If the access to these variables is not
+\emph on
+atomic
+\begin_inset LatexCommand index
+name "atomic"
+
+\end_inset
+
+
+\emph default
+ (i.e.
+ the processor needs more than one instruction for the access and could
+ be interrupted while accessing the variable) the interrupt must be disabled
+ during the access to avoid inconsistent data.
+
+\newline
+Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
+ and should be protected by disabling interrupts.
+ You're not automatically on the safe side if you use 8 bit variables though.
+ We need an example here: f.e.
+ on the 8051 the harmless looking
+\begin_inset Quotes srd
+\end_inset
+
+
+\family typewriter
+flags\InsetSpace ~
+|=\InsetSpace ~
+0x80;
+\family default
+
+\begin_inset Quotes sld
+\end_inset
+
+ is not atomic if
+\family typewriter
+flags
+\family default
+ resides in xdata.
+ Setting
+\begin_inset Quotes srd
+\end_inset
+
+
+\family typewriter
+flags\InsetSpace ~
+|=\InsetSpace ~
+0x40;
+\family default
+
+\begin_inset Quotes sld
+\end_inset
+
+ from within an interrupt routine might get lost if the interrupt occurs
+ at the wrong time.
+
+\begin_inset Quotes sld
+\end_inset
+
+
+\family typewriter
+counter\InsetSpace ~
++=\InsetSpace ~
+8;
+\family default
+
+\begin_inset Quotes srd
+\end_inset
+
+ is not atomic on the 8051 even if
+\family typewriter
+counter
+\family default
+ is located in data memory.
+\newline
+Bugs like these are hard to reproduce and can
+ cause a lot of trouble.
+
+\end_layout
+
+\begin_layout Subsubsection
+\begin_inset LatexCommand label
+name "sub:Common-interrupt-pitfall-stack-overflow"
+
+\end_inset
+
+Common interrupt pitfall:
+\emph on
+stack overflow
+\end_layout
+
+\begin_layout Standard
+The return address and the registers used in the interrupt service routine
+ are saved on the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ so there must be sufficient stack space.
+ If there isn't variables or registers (or even the return address itself)
+ will be corrupted.
+ This
+\emph on
+stack overflow
+\emph default
+
+\begin_inset LatexCommand index
+name "stack overflow"
+
+\end_inset
+
+ is most likely to happen if the interrupt occurs during the
+\begin_inset Quotes sld
+\end_inset
+
+deepest
+\begin_inset Quotes srd
+\end_inset
+
+ subroutine when the stack is already in use for f.e.
+ many return addresses.
+\end_layout
+
+\begin_layout Subsubsection
+\begin_inset LatexCommand label
+name "sub:Common-interrupt-pitfall-non-reentrant"
+
+\end_inset
+
+Common interrupt pitfall:
+\emph on
+use of non-reentrant functions
+\end_layout
+
+\begin_layout Standard
+A special note here, int (16 bit) and long (32 bit) integer division
+\begin_inset LatexCommand index
+name "Division"
+
+\end_inset
+
+, multiplication
+\begin_inset LatexCommand index
+name "Multiplication"
+
+\end_inset
+
+ & modulus
+\begin_inset LatexCommand index
+name "Modulus"
+
+\end_inset
+
+ and floating-point
+\begin_inset LatexCommand index
+name "Floating point support"
+
+\end_inset
+
+ operations are implemented using external support routines.
+ If an interrupt service routine needs to do any of these operations then
+ the support routines (as mentioned in a following section) will have to
+ be recompiled using the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\begin_inset LatexCommand index
+name "-\\/-stack-auto"
+
+\end_inset
+
+
+\emph default
+ option and the source file will need to be compiled using the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-int-long-reent
+\emph default
+
+\begin_inset LatexCommand index
+name "-\\/-int-long-reent"
+
+\end_inset
+
+ compiler option.
+
+\newline
+Note, the type promotion
+\begin_inset LatexCommand index
+name "type promotion"
+
+\end_inset
+
+ required by ANSI C can cause 16 bit routines to be used
+\begin_inset Marginal
+status collapsed
+
+\begin_layout Standard
+
+\series bold
+\InsetSpace ~
+!
+\end_layout
+
+\end_inset
+
+ without the programmer being aware of it.
+ See f.e.
+ the cast
+\family typewriter
+\series bold
+(unsigned char)(tail-1)
+\family default
+\series default
+
+\series bold
+within the if clause in section
+\begin_inset LatexCommand ref
+reference "sub:A-Step-by Assembler Introduction"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+Calling other functions from an interrupt service routine is not recommended,
+ avoid it if possible.
+ Note that when some function is called from an interrupt service routine
+ it should be preceded by a #pragma\InsetSpace ~
+nooverlay
+\begin_inset LatexCommand index
+name "\\#pragma nooverlay"
+
+\end_inset
+
+ if it is not reentrant.
+ Furthermore nonreentrant functions should not be called from the main program
+ while the interrupt service routine might be active.
+ They also must not be called from low priority interrupt service routines
+ while a high priority interrupt service routine might be active.
+ You could use semaphores or make the function
+\emph on
+critical
+\emph default
+ if all parameters are passed in registers.
+\newline
+ Also see section
+\begin_inset LatexCommand ref
+reference "sub:Overlaying"
+
+\end_inset
+
+\InsetSpace ~
+about Overlaying and section
+\begin_inset LatexCommand ref
+reference "sub:Functions-using-private-banks"
+
+\end_inset
+
+\InsetSpace ~
+about Functions using private register banks.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+MCS51/DS390 Interrupt Service Routines
+\end_layout
+
+\begin_layout Standard
+Interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ numbers and the corresponding address & descriptions for the Standard 8051/8052
+ are listed below.
+ SDCC will automatically adjust the
+\begin_inset LatexCommand index
+name "interrupt vector table"
+
+\end_inset
+
+ to the maximum interrupt number specified.
+\newline
+
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="9" columns="3">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0in">
+<column alignment="left" valignment="top" leftline="true" width="0in">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Interrupt #
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="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
+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
+External 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
+0x0003
+\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
+1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Timer 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
+0x000b
+\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
+2
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+External 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
+0x0013
+\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
+3
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Timer 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
+0x001b
+\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
+4
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Serial
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0x0023
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+5
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+Timer 2 (8052)
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0x002b
+\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
+...
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="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
+n
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="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
+0x0003 + 8*n
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+If the interrupt service routine is defined without
+\emph on
+using
+\begin_inset LatexCommand index
+name "using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\emph default
+ a register bank or with register bank 0 (
+\emph on
+using
+\emph default
+ 0), the compiler will save the registers used by itself on the stack upon
+ entry and restore them at exit, however if such an interrupt service routine
+ calls another function then the entire register bank will be saved on the
+ stack.
+ This scheme may be advantageous for small interrupt service routines which
+ have low register usage.
+\end_layout
+
+\begin_layout Standard
+If the interrupt service routine is defined to be using a specific register
+ bank then only
+\emph on
+a, b, dptr
+\emph default
+ & psw are saved and restored, if such an interrupt service routine calls
+ another function (using another register bank) then the entire register
+ bank of the called function will be saved on the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+.
+ This scheme is recommended for larger interrupt service routines.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+HC08
+\begin_inset LatexCommand index
+name "HC08"
+
+\end_inset
+
+ Interrupt Service Routines
+\end_layout
+
+\begin_layout Standard
+Since the number of interrupts
+\begin_inset LatexCommand index
+name "HC08!interrupt"
+
+\end_inset
+
+ available is chip specific and the interrupt vector table always ends at
+ the last byte of memory, the interrupt numbers corresponds to the interrupt
+ vectors in reverse order of address.
+ For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
+ 2 will use the interrupt vector at 0xfffa, and so on.
+ However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
+ this way; instead see section
+\begin_inset LatexCommand ref
+reference "sub:Startup-Code"
+
+\end_inset
+
+ for details on customizing startup.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Z80 Interrupt Service Routines
+\end_layout
+
+\begin_layout Standard
+The Z80
+\begin_inset LatexCommand index
+name "Z80"
+
+\end_inset
+
+ uses several different methods for determining the correct interrupt
+\begin_inset LatexCommand index
+name "Z80!interrupt"
+
+\end_inset
+
+ vector depending on the hardware implementation.
+ Therefore, SDCC ignores the optional interrupt number and does not attempt
+ to generate an interrupt vector table.
+\end_layout
+
+\begin_layout Standard
+By default, SDCC generates code for a maskable interrupt, which uses a RETI
+ instruction to return from the interrupt.
+ To write an interrupt handler for the non-maskable interrupt, which needs
+ a RETN instruction instead, add the
+\emph on
+critical
+\emph default
+ keyword:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+void nmi_isr (void) critical interrupt
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+However if you need to create a non-interruptable interrupt service routine
+ you would also require the
+\emph on
+critical
+\emph default
+ keyword.
+ To distinguish between this and an nmi_isr you must provide an interrupt
+ number.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Enabling and Disabling Interrupts
+\end_layout
+
+\begin_layout Subsection
+Critical Functions and Critical Statements
+\end_layout
+
+\begin_layout Standard
+A special keyword may be associated with a block or a function declaring
+ it as
+\emph on
+critical
+\emph default
+.
+ SDCC will generate code to disable all interrupts
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ upon entry to a critical function and restore the interrupt enable to the
+ previous state before returning.
+ Nesting critical functions will need one additional byte on the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ for each call.
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+int foo () __critical
+\begin_inset LatexCommand index
+name "critical"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_critical"
+
+\end_inset
+
+
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+The critical attribute maybe used with other attributes like
+\emph on
+reentrant.
+\emph default
+
+\newline
+The keyword
+\emph on
+critical
+\emph default
+ may also be used to disable interrupts more locally:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+__critical{ i++; }
+\end_layout
+
+\begin_layout Standard
+More than one statement could have been included in the block.
+\end_layout
+
+\begin_layout Subsection
+Enabling and Disabling Interrupts directly
+\end_layout
+
+\begin_layout Standard
+Interrupts
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ can also be disabled and enabled directly (8051):
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+EA = 0;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+or:\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+EA_SAVE = EA;
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+...\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 ~
+EA = 0;
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+EA = 1;\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 ~
+...
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\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 ~
+EA = EA_SAVE;
+\end_layout
+
+\begin_layout Standard
+On other architectures which have separate opcodes for enabling and disabling
+ interrupts you might want to make use of defines with inline assembly
+\begin_inset LatexCommand index
+name "Assembler routines"
+
+\end_inset
+
+ (HC08
+\begin_inset LatexCommand index
+name "HC08!interrupt"
+
+\end_inset
+
+):
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+#define CLI _asm
+\begin_inset LatexCommand index
+name "\\_asm"
+
+\end_inset
+
+\InsetSpace ~
+\InsetSpace ~
+cli\InsetSpace ~
+\InsetSpace ~
+_endasm
+\begin_inset LatexCommand index
+name "\\_endasm"
+
+\end_inset
+
+;
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+#define SEI _asm\InsetSpace ~
+\InsetSpace ~
+sei\InsetSpace ~
+\InsetSpace ~
+_endasm;
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+...
+\end_layout
+
+\begin_layout Standard
+Note: it is sometimes sufficient to disable only a specific interrupt source
+ like f.e.
+ a timer or serial interrupt by manipulating an
+\emph on
+interrupt mask
+\begin_inset LatexCommand index
+name "interrupt mask"
+
+\end_inset
+
+
+\emph default
+ register.
+
+\end_layout
+
+\begin_layout Standard
+Usually the time during which interrupts are disabled should be kept as
+ short as possible.
+ This minimizes both
+\emph on
+interrupt latency
+\emph default
+
+\begin_inset LatexCommand index
+name "interrupt latency"
+
+\end_inset
+
+ (the time between the occurrence of the interrupt and the execution of
+ the first code in the interrupt routine) and
+\emph on
+interrupt jitter
+\emph default
+
+\begin_inset LatexCommand index
+name "interrupt jitter"
+
+\end_inset
+
+ (the difference between the shortest and the longest interrupt latency).
+ These really are something different, f.e.
+ a serial interrupt has to be served before its buffer overruns so it cares
+ for the maximum interrupt latency, whereas it does not care about jitter.
+ On a loudspeaker driven via a digital to analog converter which is fed
+ by an interrupt a latency of a few milliseconds might be tolerable, whereas
+ a much smaller jitter will be very audible.
+\end_layout
+
+\begin_layout Standard
+You can reenable interrupts within an interrupt routine and on some architecture
+s you can make use of two (or more) levels of
+\emph on
+interrupt priorities
+\emph default
+
+\begin_inset LatexCommand index
+name "interrupt priority"
+
+\end_inset
+
+.
+ On some architectures which don't support interrupt priorities these can
+ be implemented by manipulating the interrupt mask and reenabling interrupts
+ within the interrupt routine.
+ Check there is sufficient space on the stack
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+ and don't add complexity unless you have to.
+
+\end_layout
+
+\begin_layout Subsection
+Semaphore
+\begin_inset LatexCommand index
+name "semaphore"
+
+\end_inset
+
+ locking (mcs51/ds390)
+\end_layout
+
+\begin_layout Standard
+Some architectures (mcs51/ds390) have an atomic
+\begin_inset LatexCommand index
+name "atomic"
+
+\end_inset
+
+ bit test and clear instruction.
+ These type of instructions are typically used in preemptive multitasking
+ systems, where a routine f.e.
+ claims the use of a data structure ('acquires a lock
+\begin_inset LatexCommand index
+name "lock"
+
+\end_inset
+
+ on it'), makes some modifications and then releases the lock when the data
+ structure is consistent again.
+ The instruction may also be used if interrupt and non-interrupt code have
+ to compete for a resource.
+ With the atomic bit test and clear instruction interrupts
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ don't have to be disabled for the locking operation.
+
+\end_layout
+
+\begin_layout Standard
+SDCC generates this instruction if the source follows this pattern:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+volatile
+\begin_inset LatexCommand index
+name "volatile"
+
+\end_inset
+
+ bit resource_is_free;
+\newline
+
+\newline
+if (resource_is_free)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+resource_is_free=0;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+...
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+resource_is_free=1;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+}
+\end_layout
+
+\begin_layout Standard
+Note, mcs51 and ds390 support only an atomic
+\begin_inset LatexCommand index
+name "atomic"
+
+\end_inset
+
+ bit test and
+\emph on
+clear
+\emph default
+ instruction (as opposed to atomic bit test and
+\emph on
+set).
+\end_layout
+
+\begin_layout Section
+Functions using private register banks
+\begin_inset LatexCommand label
+name "sub:Functions-using-private-banks"
+
+\end_inset
+
+ (mcs51/ds390)
+\end_layout
+
+\begin_layout Standard
+Some architectures have support for quickly changing register sets.
+ SDCC supports this feature with the
+\emph on
+using
+\begin_inset LatexCommand index
+name "using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_using (mcs51, ds390 register bank)"
+
+\end_inset
+
+
+\emph default
+ attribute (which tells the compiler to use a register bank
+\begin_inset LatexCommand index
+name "register bank (mcs51, ds390)"
+
+\end_inset
+
+ other than the default bank zero).
+ It should only be applied to
+\emph on
+interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+
+\emph default
+ functions (see footnote below).
+ This will in most circumstances make the generated ISR code more efficient
+ since it will not have to save registers on the stack.
+\end_layout
+
+\begin_layout Standard
+The
+\emph on
+using
+\emph default
+ attribute will have no effect on the generated code for a
+\emph on
+non-interrupt
+\emph default
+ function (but may occasionally be useful anyway
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+possible exception: if a function is called ONLY from 'interrupt' functions
+ using a particular bank, it can be declared with the same 'using' attribute
+ as the calling 'interrupt' functions.
+ For instance, if you have several ISRs using bank one, and all of them
+ call memcpy(), it might make sense to create a specialized version of memcpy()
+ 'using 1', since this would prevent the ISR from having to save bank zero
+ to the stack on entry and switch to bank zero before calling the function
+\end_layout
+
+\end_inset
+
+).
+\newline
+
+\emph on
+(pending: Note, nowadays the
+\emph default
+ using
+\emph on
+attribute has an effect on
+\emph default
+
+\emph on
+the generated code for a
+\emph default
+ non-interrupt
+\emph on
+function
+\emph default
+.
+\emph on
+)
+\end_layout
+
+\begin_layout Standard
+An
+\emph on
+interrupt
+\emph default
+ function using a non-zero bank will assume that it can trash that register
+ bank, and will not save it.
+ Since high-priority interrupts
+\begin_inset LatexCommand index
+name "interrupts"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "interrupt priority"
+
+\end_inset
+
+ can interrupt low-priority ones on the 8051 and friends, this means that
+ if a high-priority ISR
+\emph on
+using
+\emph default
+ a particular bank occurs while processing a low-priority ISR
+\emph on
+using
+\emph default
+ the same bank, terrible and bad things can happen.
+ To prevent this, no single register bank should be
+\emph on
+used
+\emph default
+ by both a high priority and a low priority ISR.
+ This is probably most easily done by having all high priority ISRs use
+ one bank and all low priority ISRs use another.
+ If you have an ISR which can change priority at runtime, you're on your
+ own: I suggest using the default bank zero and taking the small performance
+ hit.
+\end_layout
+
+\begin_layout Standard
+It is most efficient if your ISR calls no other functions.
+ If your ISR must call other functions, it is most efficient if those functions
+ use the same bank as the ISR (see note 1 below); the next best is if the
+ called functions use bank zero.
+ It is very inefficient to call a function using a different, non-zero bank
+ from an ISR.
+
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Startup Code
+\begin_inset LatexCommand label
+name "sub:Startup-Code"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Startup code"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+MCS51/DS390 Startup Code
+\end_layout
+
+\begin_layout Standard
+The compiler triggers the linker to link certain initialization modules
+ from the runtime library
+\begin_inset LatexCommand index
+name "Runtime library"
+
+\end_inset
+
+ called crt<something>.
+ Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
+ GSINIT5) is not linked unless the -
+\series bold
+
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+-xstack option is used.
+ These modules are highly entangled by the use of special segments/areas,
+ but a common layout is shown below:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(main.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area HOME (CODE)
+\newline
+__interrupt_vect:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ljmp __sdcc_gsinit_startup
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(crtstart.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT0 (CODE)
+\newline
+__sdcc_gsinit_startup::
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov sp,#__start__stack - 1
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(crtxstack.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT1 (CODE)
+\newline
+__sdcc_init_xstack::
+\newline
+; Need to initialize in GSINIT1 in
+ case the user's __sdcc_external_startup uses the xstack.
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov __XPAGE,#(__start__x
+stack >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov _spx,#__start__xstack
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(crtstart.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT2 (CODE)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+lcall __sdcc_external_startup
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov a,dpl
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+jz __sdcc_init_data
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ljmp
+ __sdcc_program_startup
+\newline
+__sdcc_init_data:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(crtxinit.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT3 (CODE)
+\newline
+__mcs51_genXINIT::
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r1,#l_XINIT
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov a,r1
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+orl a,#(l_XINIT
+ >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+jz 00003$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r2,#((l_XINIT+255) >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov dptr,#s_XINIT
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r0,#s_XISEG
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov
+ __XPAGE,#(s_XISEG >> 8)
+\newline
+00001$:\InsetSpace ~
+clr a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movc a,@a+dptr
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movx @r0,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc dptr
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc
+ r0
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+cjne r0,#0,00002$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc __XPAGE
+\newline
+00002$:\InsetSpace ~
+djnz r1,00001$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+djnz r2,00001$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov __XPAGE,#0
+xFF
+\newline
+00003$:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(crtclear.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT4 (CODE)
+\newline
+__mcs51_genRAMCLEAR::
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+clr a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r0,#(l_IRAM-1)
+\newline
+00004$:\InsetSpace ~
+mov
+ @r0,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+djnz r0,00004$
+\newline
+; _mcs51_genRAMCLEAR() end
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(crtxclear.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT4 (CODE)
+\newline
+__mcs51_genXRAMCLEAR::
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r0,#l_PSEG
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov a,r0
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+orl a,#(l_PSEG
+ >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+jz 00006$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r1,#s_PSEG
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov __XPAGE,#(s_PSEG >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+clr a
+\newline
+00005$:\InsetSpace ~
+movx
+ @r1,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc r1
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+djnz r0,00005$
+\newline
+00006$:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r0,#l_XSEG
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov a,r0
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+orl a,#(l_XSEG >>
+ 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+jz 00008$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov r1,#((l_XSEG + 255) >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov dptr,#s_XSEG
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+clr a
+\newline
+00007$:\InsetSpace ~
+movx
+ @dptr,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc dptr
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+djnz r0,00007$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+djnz r1,00007$
+\newline
+00008$:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(crtxstack.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT5 (CODE)
+\newline
+; Need to initialize in GSINIT5 because __mcs51_genXINIT
+ modifies __XPAGE
+\newline
+; and __mcs51_genRAMCLEAR modifies _spx.
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov __XPAGE,#(__start__x
+stack >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov _spx,#__start__xstack
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(application modules)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSINIT (CODE)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\series bold
+\size footnotesize
+(main.asm)
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area GSFINAL (CODE)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ljmp __sdcc_program_startup
+\newline
+;---------------------------------
+-----------------------
+\newline
+; Home
+\newline
+;--------------------------------------------------
+------
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area HOME (CODE)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area CSEG (CODE)
+\newline
+__sdcc_program_startup:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+lcall _main
+\newline
+;
+ return from main will lock up
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+sjmp .
+\end_layout
+
+\begin_layout Standard
+One of these modules (crtstart.asm) contains a call to the C routine
+\emph on
+_sdcc_external_startup()
+\begin_inset LatexCommand index
+name "\\_sdcc\\_external\\_startup()"
+
+\end_inset
+
+
+\emph default
+ at the start of the CODE area.
+ This routine is also in the runtime library
+\begin_inset LatexCommand index
+name "Runtime library"
+
+\end_inset
+
+ and returns 0 by default.
+ If this routine returns a non-zero value, the static & global variable
+ initialization will be skipped and the function main will be invoked.
+ Otherwise static & global variables will be initialized before the function
+ main is invoked.
+ You could add an
+\emph on
+_sdcc_external_startup()
+\emph default
+ routine to your program to override the default if you need to setup hardware
+ or perform some other critical operation prior to static & global variable
+ initialization
+\begin_inset LatexCommand index
+name "Variable initialization"
+
+\end_inset
+
+.
+ On some mcs51 variants xdata
+\begin_inset LatexCommand index
+name "xdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ memory has to be explicitly enabled before it can be accessed or if the
+ watchdog
+\begin_inset LatexCommand index
+name "watchdog"
+
+\end_inset
+
+ needs to be disabled, this is the place to do it.
+ The startup code clears all internal data memory, 256 bytes by default,
+ but from 0 to n-1 if
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-iram-size
+\begin_inset LatexCommand index
+name "-\\/-iram-size <Value>"
+
+\end_inset
+
+n
+\emph default
+ is used.
+ (recommended for Chipcon CC1010).
+\end_layout
+
+\begin_layout Standard
+See also the compiler options
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-no-xinit
+\emph default
+-
+\emph on
+opt
+\emph default
+
+\begin_inset LatexCommand index
+name "-\\/-no-xinit-opt"
+
+\end_inset
+
+,
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-main-return
+\emph default
+
+\begin_inset LatexCommand index
+name "-\\/-main-return"
+
+\end_inset
+
+ and section
+\begin_inset LatexCommand ref
+reference "sub:MCS51-variants"
+
+\end_inset
+
+ about MCS51-variants.
+\newline
+
+\end_layout
+
+\begin_layout Standard
+While these initialization modules are meant as generic startup code there
+ might be the need for customization.
+ Let's assume the return value of
+\emph on
+_sdcc_external_startup()
+\emph default
+ in
+\emph on
+crtstart.asm
+\emph default
+ should not be checked (or
+\emph on
+_sdcc_external_startup()
+\emph default
+ should not be called at all).
+ The recommended way would be to copy
+\emph on
+crtstart.asm
+\emph default
+ (f.e.
+ from
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm"
+
+\end_inset
+
+) into the source directory, adapt it there, then assemble it with
+\emph on
+asx8051 -plosgff
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+\begin_inset Quotes sld
+\end_inset
+
+-plosgff
+\begin_inset Quotes srd
+\end_inset
+
+ are the assembler options used in
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup "
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+ crtstart.asm
+\emph default
+ and when linking your project explicitly specify
+\emph on
+crtstart.rel
+\emph default
+.
+ As a bonus a listing of the relocated object file
+\emph on
+crtstart.rst
+\emph default
+ is generated.
+\end_layout
+
+\begin_layout Standard
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+HC08 Startup Code
+\end_layout
+
+\begin_layout Standard
+The HC08
+\begin_inset LatexCommand index
+name "HC08"
+
+\end_inset
+
+ startup code follows the same scheme as the MCS51 startup code.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Z80 Startup Code
+\end_layout
+
+\begin_layout Standard
+On the Z80
+\begin_inset LatexCommand index
+name "Z80"
+
+\end_inset
+
+ the startup code is inserted by linking with crt0.o which is generated from
+ sdcc/device/lib/z80/crt0.s.
+ If you need a different startup code you can use the compiler option
+\emph on
+-
+\series bold
+\emph default
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+
+\series default
+\emph on
+-no-std-crt0
+\emph default
+
+\begin_inset LatexCommand index
+name "-\\/-no-std-crt0"
+
+\end_inset
+
+ and provide your own crt0.o.
+
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Inline Assembler Code
+\begin_inset LatexCommand index
+name "Assembler routines"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+A Step by Step Introduction
+\begin_inset LatexCommand label
+name "sub:A-Step-by Assembler Introduction"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Starting from a small snippet of c-code this example shows for the MCS51
+ how to use inline assembly, access variables, a function parameter and
+ an array in xdata memory.
+ The example uses an MCS51 here but is easily adapted for other architectures.
+ This is a buffer routine which should be optimized:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+unsigned char __far
+\begin_inset LatexCommand index
+name "far (storage class)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_far (storage class)"
+
+\end_inset
+
+ __at
+\begin_inset LatexCommand index
+name "at"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_at"
+
+\end_inset
+
+(0x7f00) buf[0x100];
+\begin_inset LatexCommand index
+name "Aligned array"
+
+\end_inset
+
+
+\newline
+unsigned char head, tail;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* if interrupts
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ are involved see
+\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 ~
+section
+\begin_inset LatexCommand ref
+reference "sub:Common-interrupt-pitfall-volatile"
+
+\end_inset
+
+ about
+\family default
+
+\family typewriter
+\series bold
+volatile
+\family default
+\series default
+
+\family typewriter
+*/
+\newline
+
+\newline
+void to_buffer( unsigned char c )
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+if( head != (unsigned char)(tail-1)
+ )\InsetSpace ~
+/* cast
+\family default
+
+\family typewriter
+\series bold
+needed
+\family default
+\series default
+
+\family typewriter
+to avoid promotion
+\begin_inset LatexCommand index
+name "promotion to signed int"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "type promotion"
+
+\end_inset
+
+ to integer */
+\begin_inset Marginal
+status collapsed
+
+\begin_layout Standard
+
+\series bold
+\InsetSpace ~
+!
+\end_layout
+
+\end_inset
+
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+buf[ head++ ] = c;\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* access to a 256 byte aligned array */
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
+ then a corresponding buffer.asm file is generated.
+ We define a new function
+\family typewriter
+to_buffer_asm()
+\family default
+ in file buffer.c in which we cut and paste the generated code, removing
+ unwanted comments and some ':'.
+ Then add
+\begin_inset Quotes sld
+\end_inset
+
+
+\series bold
+_asm
+\series default
+
+\begin_inset Quotes srd
+\end_inset
+
+ and
+\begin_inset Quotes sld
+\end_inset
+
+
+\series bold
+_endasm;
+\series default
+
+\begin_inset Quotes srd
+\end_inset
+
+
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
+ and for C-99 compatibility, the double-underscore form (__asm and __endasm)
+ has to be used.
+ The latter is also used in the library functions.
+\end_layout
+
+\end_inset
+
+ to the beginning and the end of the function body:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+/* With a cut and paste from the .asm file, we have something to start with.
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+The
+ function is not yet OK! (registers aren't saved) */
+\newline
+void to_buffer_asm(
+ unsigned char c )
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_asm
+\begin_inset LatexCommand index
+name "\\_asm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_asm"
+
+\end_inset
+
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+r2,dpl
+\newline
+;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
+/* cast
+\family default
+
+\family typewriter
+\series bold
+needed
+\family default
+\series default
+
+\family typewriter
+to avoid promotion
+\begin_inset LatexCommand index
+name "promotion to signed int"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "type promotion"
+
+\end_inset
+
+ to integer */
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+a,_tail
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dec\InsetSpace ~
+\InsetSpace ~
+a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+r3,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+a,_head
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+cjne a,ar3,00106$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ret
+\newline
+00106$:
+
+\newline
+;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
+\begin_inset LatexCommand index
+name "Aligned array"
+
+\end_inset
+
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+r3,_head
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc\InsetSpace ~
+\InsetSpace ~
+_head
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+dpl,r3
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+dph,#(_buf >> 8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+a,r2
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movx @dptr,a
+
+\newline
+00103$:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ret
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_endasm
+\begin_inset LatexCommand index
+name "\\_endasm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_endasm"
+
+\end_inset
+
+;
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+The new file buffer.c should compile with only one warning about the unreferenced
+ function argument 'c'.
+ Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
+ (1) and finally have:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+\size footnotesize
+unsigned char __far __at(0x7f00) buf[0x100];
+\newline
+unsigned char head, tail;
+\newline
+#define
+ USE_ASSEMBLY (1)
+\newline
+
+\newline
+#if !USE_ASSEMBLY
+\newline
+
+\newline
+void to_buffer( unsigned char c )
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+if(
+ head != (unsigned char)(tail-1) )
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+buf[ head++ ] = c;
+\newline
+}
+\newline
+
+\newline
+#else
+\newline
+
+\newline
+void to_buffer(
+ unsigned char c )
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+c; // to avoid warning: unreferenced function argument
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_asm
+\begin_inset LatexCommand index
+name "\\_asm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_asm"
+
+\end_inset
+
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; save used registers here.
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; If we were still using r2,r3 we would have to push them here.
+
+\newline
+; if( head != (unsigned char)(tail-1) )
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+ a,_tail
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dec\InsetSpace ~
+ a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+xrl\InsetSpace ~
+ a,_head
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; we
+ could do an ANL a,#0x0f here to use a smaller buffer (see below)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+jz\InsetSpace ~
+\InsetSpace ~
+ t_b_end$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;
+\newline
+;
+ buf[ head++ ] = c;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+ a,dpl \InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; dpl holds lower byte of function argument
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+
+ dpl,_head \InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; buf is 0x100 byte aligned so head can be used directly
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+ dph,#(_bu
+f>>8)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+movx @dptr,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc \InsetSpace ~
+_head
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; we could do an ANL _head,#0x0f here to use a
+ smaller buffer (see above)
+\newline
+t_b_end$:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; restore used registers here
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_endasm
+\begin_inset LatexCommand index
+name "\\_endasm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_endasm"
+
+\end_inset
+
+;
+\newline
+}
+\newline
+#endif
+\end_layout
+
+\begin_layout Standard
+The inline assembler code can contain any valid code understood by the assembler
+, this includes any assembler directives and comment lines.
+ The assembler does not like some characters like ':' or ''' in comments.
+ You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
+\begin_inset LatexCommand index
+name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Assembler documentation"
+
+\end_inset
+
+ or online at
+\begin_inset LatexCommand url
+target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
+
+\end_inset
+
+\InsetSpace ~
+.
+\end_layout
+
+\begin_layout Standard
+The compiler does not do any validation of the code within the
+\family typewriter
+_asm
+\begin_inset LatexCommand index
+name "\\_asm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_asm"
+
+\end_inset
+
+ ...
+ _endasm
+\size footnotesize
+
+\begin_inset LatexCommand index
+name "\\_endasm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_endasm"
+
+\end_inset
+
+
+\size default
+;
+\family default
+ keyword pair.
+ Specifically it will not know which registers are used and thus register
+ pushing/popping
+\begin_inset LatexCommand index
+name "push/pop"
+
+\end_inset
+
+ has to be done manually.
+
+\end_layout
+
+\begin_layout Standard
+It is recommended that each assembly instruction (including labels) be placed
+ in a separate line (as the example shows).
+ When the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-
+\emph on
+peep-asm
+\begin_inset LatexCommand index
+name "-\\/-peep-asm"
+
+\end_inset
+
+
+\emph default
+ command line option is used, the inline assembler code will be passed through
+ the peephole optimizer
+\begin_inset LatexCommand index
+name "Peephole optimizer"
+
+\end_inset
+
+.
+ There are only a few (if any) cases where this option makes sense, it might
+ cause some unexpected changes in the inline assembler code.
+ Please go through the peephole optimizer rules defined in file
+\emph on
+SDCCpeeph.def
+\emph default
+ before using this option.
+\end_layout
+
+\begin_layout Subsection
+Naked Functions
+\begin_inset LatexCommand label
+name "sub:Naked-Functions"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Naked functions"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+A special keyword may be associated with a function declaring it as
+\emph on
+_naked
+\begin_inset LatexCommand index
+name "\\_naked"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_naked"
+
+\end_inset
+
+.
+
+\emph default
+ The
+\emph on
+_naked
+\emph default
+ function modifier attribute prevents the compiler from generating prologue
+\begin_inset LatexCommand index
+name "function prologue"
+
+\end_inset
+
+ and epilogue
+\begin_inset LatexCommand index
+name "function epilogue"
+
+\end_inset
+
+ code for that function.
+ This means that the user is entirely responsible for such things as saving
+ any registers that may need to be preserved, selecting the proper register
+ bank, generating the
+\emph on
+return
+\emph default
+ instruction at the end, etc.
+ Practically, this means that the contents of the function must be written
+ in inline assembler.
+ This is particularly useful for interrupt functions, which can have a large
+ (and often unnecessary) prologue/epilogue.
+ For example, compare the code generated by these two functions:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+volatile
+\begin_inset LatexCommand index
+name "volatile"
+
+\end_inset
+
+ data unsigned char counter;
+\newline
+
+\newline
+void simpleInterrupt(void) __interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_interrupt"
+
+\end_inset
+
+ (1)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+counter++;
+\newline
+}
+\newline
+
+\newline
+void nakedInterrupt(void) __interrupt (2) __naked
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_asm
+\begin_inset LatexCommand index
+name "\\_asm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_asm"
+
+\end_inset
+
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_counter ; does not change flags, no need to save psw
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+reti\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; MUST explicitly
+ include ret or reti in _naked function.
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_endasm
+\begin_inset LatexCommand index
+name "\\_endasm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_endasm"
+
+\end_inset
+
+;
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+For an 8051 target, the generated simpleInterrupt looks like:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+Note, this is an
+\family default
+
+\family typewriter
+\emph on
+outdated
+\family default
+\emph default
+
+\family typewriter
+example, recent versions of SDCC generate
+\newline
+the
+\family default
+
+\family typewriter
+\emph on
+same
+\family default
+\emph default
+
+\family typewriter
+code for simpleInterrupt() and nakedInterrupt()!
+\newline
+
+\newline
+_simpleInterrupt:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+push\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+acc
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+push\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+b
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+pus
+h\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dpl
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+push\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dph
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+push\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+psw
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+psw,#0x00
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_counter
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+pop\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+psw
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+pop\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dph
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+pop\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dpl
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+pop\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+b
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+pop\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+acc
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+reti
+\end_layout
+
+\begin_layout Standard
+whereas nakedInterrupt looks like:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+_nakedInterrupt:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+inc\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_counter ; does not change flags, no need to save psw
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+reti\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;
+ MUST explicitly include ret or reti in _naked function
+\end_layout
+
+\begin_layout Standard
+The related directive #pragma exclude
+\begin_inset LatexCommand index
+name "\\#pragma exclude"
+
+\end_inset
+
+ allows a more fine grained control over pushing & popping
+\begin_inset LatexCommand index
+name "push/pop"
+
+\end_inset
+
+ the registers.
+\end_layout
+
+\begin_layout Standard
+While there is nothing preventing you from writing C code inside a
+\family typewriter
+_naked
+\family default
+ function, there are many ways to shoot yourself in the foot doing this,
+ and it is recommended that you stick to inline assembler.
+\end_layout
+
+\begin_layout Subsection
+Use of Labels within Inline Assembler
+\end_layout
+
+\begin_layout Standard
+SDCC allows the use of in-line assembler with a few restrictions regarding
+ labels.
+ All labels defined within inline assembler code have to be of the form
+
+\emph on
+nnnnn$
+\emph default
+ where nnnnn is a number less than 100 (which implies a limit of utmost
+ 100 inline assembler labels
+\emph on
+per function
+\emph default
+\noun on
+)
+\noun default
+.
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+This is a slightly more stringent rule than absolutely necessary, but stays
+ always on the safe side.
+ Labels in the form of nnnnn$ are local labels in the assembler, locality
+ of which is confined within two labels of the standard form.
+ The compiler uses the same form for labels within a function (but starting
+ from nnnnn=00100); and places always a standard label at the beginning
+ of a function, thus limiting the locality of labels within the scope of
+ the function.
+ So, if the inline assembler part would be embedded into C-code, an improperly
+ placed non-local label in the assembler would break up the reference space
+ for labels created by the compiler for the C-code, leading to an assembling
+ error.
+\end_layout
+
+\begin_layout Standard
+The numeric part of local labels does not need to have 5 digits (although
+ this is the form of labels output by the compiler), any valid integer will
+ do.
+ Please refer to the assemblers documentation for further details.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+_asm
+\begin_inset LatexCommand index
+name "\\_asm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_asm"
+
+\end_inset
+
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+b,#10
+\newline
+00001$:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+djnz\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+b,00001$
+\newline
+_endasm
+\begin_inset LatexCommand index
+name "\\_endasm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_endasm"
+
+\end_inset
+
+ ;
+\end_layout
+
+\begin_layout Standard
+Inline assembler code cannot reference any C-labels, however it can reference
+ labels
+\begin_inset LatexCommand index
+name "Labels"
+
+\end_inset
+
+ defined by the inline assembler, e.g.:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+foo() {
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* some c code */
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_asm
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+; some assembler code
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ljmp 0003$
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_endasm;
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* some more c code */
+\newline
+clabel:\InsetSpace ~
+\InsetSpace ~
+/* inline assembler cannot reference this
+ label */
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+Here, the C-label
+\family typewriter
+clabel
+\family default
+ is translated by the compiler into a local label, so the locality of labels
+ within the function is not broken.
+\end_layout
+
+\end_inset
+
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_asm
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+0003$: ;label (can be referenced by inline assembler only)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+_endasm
+\begin_inset LatexCommand index
+name "\\_endasm"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_endasm"
+
+\end_inset
+
+ ;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+/* some more c code */
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+In other words inline assembly code can access labels defined in inline
+ assembly within the scope of the function.
+ The same goes the other way, i.e.
+ labels defines in inline assembly can not be accessed by C statements.
+\end_layout
+
+\begin_layout Section
+Interfacing with Assembler Code
+\begin_inset LatexCommand index
+name "Assembler routines"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Global Registers used for Parameter Passing
+\begin_inset LatexCommand index
+name "Parameter passing"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The compiler always uses the global registers
+\emph on
+DPL, DPH
+\begin_inset LatexCommand index
+name "DPTR, DPH, DPL"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "DPTR"
+
+\end_inset
+
+, B
+\begin_inset LatexCommand index
+name "B (mcs51, ds390 register)"
+
+\end_inset
+
+
+\emph default
+ and
+\emph on
+ACC
+\begin_inset LatexCommand index
+name "ACC (mcs51, ds390 register)"
+
+\end_inset
+
+
+\emph default
+ to pass the first (non-bit) parameter to a function, and also to pass the
+ return value
+\begin_inset LatexCommand index
+name "return value"
+
+\end_inset
+
+of function; according to the following scheme: one byte return value in
+
+\emph on
+DPL
+\emph default
+, two byte value in
+\emph on
+DPL
+\emph default
+ (LSB) and
+\emph on
+DPH
+\emph default
+ (MSB).
+ three byte values (generic pointers) in
+\emph on
+DPH
+\emph default
+,
+\emph on
+DPL
+\emph default
+ and
+\emph on
+B
+\emph default
+, and four byte values in
+\emph on
+DPH
+\emph default
+,
+\emph on
+DPL
+\emph default
+,
+\emph on
+B
+\emph default
+ and
+\emph on
+ACC
+\emph default
+.
+ Generic pointers
+\begin_inset LatexCommand index
+name "generic pointer"
+
+\end_inset
+
+ contain type of accessed memory in
+\emph on
+B
+\emph default
+:
+\series bold
+0x00
+\series default
+ -- xdata/far,
+\series bold
+0x40
+\series default
+ -- idata/near -- ,
+\series bold
+0x60
+\series default
+ -- pdata,
+\series bold
+0x80
+\series default
+ -- code
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+This might not be the case of certain memory models (medium???)
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+The second parameter onwards is either allocated on the stack (for reentrant
+ routines or if -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto is used) or in data/xdata memory (depending on the memory model).
+\end_layout
+
+\begin_layout Standard
+Bit parameters are passed in a virtual register called 'bits' in bit-addressable
+ space for reentrant functions or allocated directly in bit memory otherwise.
+\end_layout
+
+\begin_layout Standard
+Functions (with two or more parameters or bit parameters) that are called
+ through function pointers
+\begin_inset LatexCommand index
+name "function pointers"
+
+\end_inset
+
+ must therefor be reentrant so the compiler knows how to pass the parameters.
+\end_layout
+
+\begin_layout Subsection
+Registers usage
+\end_layout
+
+\begin_layout Standard
+Unless the called function is declared as
+\family typewriter
+_naked
+\family default
+
+\begin_inset LatexCommand index
+name "naked"
+
+\end_inset
+
+, or the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-callee-saves
+\begin_inset LatexCommand index
+name "-\\/-callee-saves"
+
+\end_inset
+
+/-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-all-callee-saves command line option or the corresponding callee_saves
+ pragma are used, the caller will save the registers (
+\emph on
+R0-R7
+\emph default
+) around the call, so the called function can destroy they content freely.
+\end_layout
+
+\begin_layout Standard
+If the called function is not declared as
+\family typewriter
+_naked
+\family default
+, the caller will swap register banks around the call, if caller and callee
+ use different register banks (having them defined by the
+\family typewriter
+_using
+\family default
+ modifier).
+
+\end_layout
+
+\begin_layout Standard
+The called function can also use
+\emph on
+DPL
+\emph default
+,
+\emph on
+DPH
+\emph default
+,
+\emph on
+B
+\emph default
+ and
+\emph on
+ACC
+\emph default
+ observing that they are used for parameter/return value passing.
+\end_layout
+
+\begin_layout Subsection
+Assembler Routine (non-reentrant)
+\end_layout
+
+\begin_layout Standard
+In the following example
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Assembler routines (non-reentrant)"
+
+\end_inset
+
+ the function c_func calls an assembler routine asm_func, which takes two
+ parameters
+\begin_inset LatexCommand index
+name "function parameter"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+extern int asm_func(unsigned char, unsigned char);
+\newline
+
+\newline
+int c_func (unsigned char
+ i, unsigned char j)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+return asm_func(i,j);
+\newline
+}
+\newline
+
+\newline
+int main()
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+return c_func(10,9);
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+The corresponding assembler function is:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+.globl _asm_func_PARM_2
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.globl _asm_func
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area OSEG
+\newline
+_asm_func_PARM_2:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.ds
+ 1
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+.area CSEG
+\newline
+_asm_func:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+a,dpl
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+add\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+a,_asm_func_PARM_2
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dpl,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+dph
+\begin_inset LatexCommand index
+name "DPTR, DPH, DPL"
+
+\end_inset
+
+,#0x00
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ret
+\end_layout
+
+\begin_layout Standard
+The parameter naming convention is _<function_name>_PARM_<n>, where n is
+ the parameter number starting from 1, and counting from the left.
+ The first parameter is passed in
+\emph on
+DPH
+\emph default
+,
+\emph on
+DPL
+\emph default
+,
+\emph on
+B
+\emph default
+ and
+\emph on
+ACC
+\emph default
+ according to the description above.
+ The variable name for the second parameter will be _<function_name>_PARM_2.
+\newline
+
+\newline
+Assem
+ble the assembler routine with the following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+asx8051 -losg asmfunc.asm
+\newline
+
+\newline
+
+\family default
+\series default
+Then compile and link the assembler routine to the C source file with the
+ following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcc cfunc.c asmfunc.rel
+\end_layout
+
+\begin_layout Subsection
+Assembler Routine (reentrant)
+\end_layout
+
+\begin_layout Standard
+In this case
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Assembler routines (reentrant)"
+
+\end_inset
+
+ the second parameter
+\begin_inset LatexCommand index
+name "function parameter"
+
+\end_inset
+
+ onwards will be passed on the stack, the parameters are pushed from right
+ to left i.e.
+ before the call the second leftmost parameter will be on the top of the
+ stack (the leftmost parameter is passed in registers).
+ Here is an example:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
+\newline
+
+\newline
+int
+ c_func (unsigned char i, unsigned char j, unsigned char k) reentrant
+\newline
+{
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+return asm_func(i,j,k);
+\newline
+}
+\newline
+
+\newline
+int main()
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+return c_func(10,9,8);
+\newline
+}
+\end_layout
+
+\begin_layout Standard
+The corresponding (unoptimized) assembler routine is:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+.globl _asm_func
+\newline
+_asm_func:
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+push\InsetSpace ~
+_bp
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+_bp,sp\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;stack contains: _bp, return
+ address, second parameter, third parameter
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+r2,dpl
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+a,_bp
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+add\InsetSpace ~
+\InsetSpace ~
+a,#0xfd\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;calculate
+ pointer to the second parameter
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+r0,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+a,_bp
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+add\InsetSpace ~
+\InsetSpace ~
+a,#0xfc\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;calculate pointer
+ to the rightmost parameter
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+r1,a
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+a,@r0
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+add\InsetSpace ~
+\InsetSpace ~
+a,@r1
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+add\InsetSpace ~
+\InsetSpace ~
+a,r2\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;calculate the
+ result (= sum of all three parameters)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+dpl,a\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;return value goes into dptr
+ (cast into int)
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+dph,#0x00
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+mov\InsetSpace ~
+\InsetSpace ~
+sp,_bp
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+pop\InsetSpace ~
+\InsetSpace ~
+_bp
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ret
+\end_layout
+
+\begin_layout Standard
+The compiling and linking procedure remains the same, however note the extra
+ entry & exit linkage required for the assembler code, _bp is the stack
+ frame pointer and is used to compute the offset into the stack for parameters
+ and local variables.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+int (16 bit)
+\begin_inset LatexCommand index
+name "int (16 bit)"
+
+\end_inset
+
+ and long (32 bit)
+\begin_inset LatexCommand index
+name "long (32 bit)"
+
+\end_inset
+
+ Support
+\end_layout
+
+\begin_layout Standard
+For signed & unsigned int (16 bit) and long (32 bit) variables, division,
+ multiplication and modulus operations are implemented by support routines.
+ These support routines are all developed in ANSI-C to facilitate porting
+ to other MCUs, although some model specific assembler optimizations are
+ used.
+ The following files contain the described routines, all of them can be
+ found in <installdir>/share/sdcc/lib.
+\newline
+
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="11" columns="2">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+Function
+\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
+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
+_mulint.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+16 bit multiplication
+\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
+_divsint.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+ signed 16 bit division (calls _divuint)
+\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
+_divuint.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+ unsigned 16 bit division
+\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
+_modsint.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+signed 16 bit modulus (calls _moduint)
+\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
+_moduint.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+unsigned 16 bit modulus
+\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
+_mullong.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+32 bit multiplication
+\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
+_divslong.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+ signed 32 division (calls _divulong)
+\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
+_divulong.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+unsigned 32 division
+\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
+_modslong.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+ signed 32 bit modulus (calls _modulong)
+\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
+_modulong.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+unsigned 32 bit modulus
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Since they are compiled as
+\emph on
+non-reentrant
+\emph default
+
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+, interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ service routines should not do any of the above operations.
+ If this is unavoidable then the above routines will need to be compiled
+ with the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\begin_inset LatexCommand index
+name "-\\/-stack-auto"
+
+\end_inset
+
+
+\emph default
+ option, after which the source program will have to be compiled with
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-int-long-reent
+\begin_inset LatexCommand index
+name "-\\/-int-long-reent"
+
+\end_inset
+
+
+\emph default
+ option.
+ Notice that you don't have to call these routines directly.
+ The compiler will use them automatically every time an integer operation
+ is required.
+\end_layout
+
+\begin_layout Section
+Floating Point Support
+\begin_inset LatexCommand index
+name "Floating point support"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+SDCC supports IEEE (single precision 4 bytes) floating point numbers.
+ The floating point support routines are derived from gcc's floatlib.c and
+ consist of the following routines:
+\newline
+
+\end_layout
+
+\begin_layout Standard
+\align center
+
+\size footnotesize
+\begin_inset Tabular
+<lyxtabular version="3" rows="17" columns="2">
+<features>
+<column alignment="left" valignment="top" leftline="true" width="0">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+Function
+\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
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+_fsadd.c
+\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
+add floating point numbers
+\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
+_fssub.c
+\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
+subtract floating point numbers
+\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
+_fsdiv.c
+\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
+divide floating point numbers
+\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
+_fsmul.c
+\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
+multiply floating point numbers
+\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
+_fs2uchar.c
+\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
+convert floating point to unsigned char
+\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
+_fs2char.c
+\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
+convert floating point to signed char
+\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
+_fs2uint.c
+\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
+convert floating point to unsigned int
+\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
+_fs2int.c
+\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
+convert floating point to signed int
+\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
+_fs2ulong.
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+c
+\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
+convert floating point to unsigned long
+\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
+_fs2long.c
+\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
+convert floating point to signed long
+\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
+_uchar2fs.c
+\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
+convert unsigned char to floating point
+\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
+_char2fs.c
+\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
+convert char to floating point number
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+_uint2fs.c
+\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
+convert unsigned int to floating point
+\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
+_int2fs.c
+\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
+convert int to floating point numbers
+\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
+_ulong2fs.c
+\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
+convert unsigned long to floating point number
+\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
+
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+_long2fs.c
+\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
+convert long to floating point number
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\newline
+
+\end_layout
+
+\begin_layout Standard
+These support routines are developed in ANSI-C so there is room for space
+ and speed improvement
+\begin_inset Foot
+status open
+
+\begin_layout Standard
+These floating point routines (
+\emph on
+not
+\emph default
+ sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
+
+\end_layout
+
+\end_inset
+
+.
+ Note if all these routines are used simultaneously the data space might
+ overflow.
+ For serious floating point usage the large model might be needed.
+ Also notice that you don't have to call this routines directly.
+ The compiler will use them automatically every time a floating point operation
+ is required.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Library Routines
+\begin_inset LatexCommand index
+name "Libraries"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\emph on
+<pending: this is messy and incomplete - a little more information is in
+ sdcc/doc/libdoc.txt
+\emph default
+ >
+\end_layout
+
+\begin_layout Subsection
+Compiler support routines (_gptrget, _mulint etc.)
+\end_layout
+
+\begin_layout Subsection
+Stdclib functions (puts, printf, strcat etc.)
+\end_layout
+
+\begin_layout Subsubsection
+<stdio.h>
+\end_layout
+
+\begin_layout Paragraph
+getchar(), putchar()
+\end_layout
+
+\begin_layout Standard
+\begin_inset LatexCommand index
+name "<stdio.h>"
+
+\end_inset
+
+As usual on embedded systems you have to provide your own
+\family typewriter
+getchar()
+\begin_inset LatexCommand index
+name "getchar()"
+
+\end_inset
+
+
+\family default
+ and
+\family typewriter
+putchar()
+\begin_inset LatexCommand index
+name "putchar()"
+
+\end_inset
+
+
+\family default
+ routines.
+ SDCC does not know whether the system connects to a serial line with or
+ without handshake, LCD, keyboard or other device.
+ And whether a
+\family typewriter
+lf
+\family default
+ to
+\family typewriter
+crlf
+\family default
+ conversion within
+\family typewriter
+putchar()
+\family default
+ is intended.
+ You'll find examples for serial routines f.e.
+ in sdcc/device/lib.
+ For the mcs51 this minimalistic polling
+\family typewriter
+putchar()
+\family default
+ routine might be a start:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+void putchar (char c) {
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+while (!TI)\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ /* assumes UART is initialized */
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+TI
+ = 0;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+SBUF = c;
+\newline
+}
+\end_layout
+
+\begin_layout Paragraph
+printf()
+\end_layout
+
+\begin_layout Standard
+The default
+\family typewriter
+printf()
+\begin_inset LatexCommand index
+name "printf()"
+
+\end_inset
+
+
+\family default
+ implementation in
+\family typewriter
+printf_large.c
+\family default
+ does not support float (except on ds390).
+ To enable this recompile it with the option
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+DUSE_FLOATS=1
+\begin_inset LatexCommand index
+name "USE\\_FLOATS"
+
+\end_inset
+
+
+\emph default
+ on the command line.
+ Use
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-model-large
+\begin_inset LatexCommand index
+name "-\\/-model-large"
+
+\end_inset
+
+
+\emph default
+ for the mcs51 port, since this uses a lot of memory.
+\end_layout
+
+\begin_layout Standard
+If you're short on code memory you might want to use
+\family typewriter
+printf_small()
+\begin_inset LatexCommand index
+name "printf\\_small()"
+
+\end_inset
+
+
+\family default
+
+\emph on
+instead
+\emph default
+ of
+\family typewriter
+printf().
+
+\family default
+ For the mcs51 there additionally are assembly versions
+\family typewriter
+printf_tiny()
+\begin_inset LatexCommand index
+name "printf\\_tiny() (mcs51)"
+
+\end_inset
+
+
+\family default
+ (subset of printf using less than 270 bytes) and
+\family typewriter
+printf_fast()
+\begin_inset LatexCommand index
+name "printf\\_fast() (mcs51)"
+
+\end_inset
+
+
+\family default
+ and
+\family typewriter
+printf_fast_f()
+\begin_inset LatexCommand index
+name "printf\\_fast\\_f() (mcs51)"
+
+\end_inset
+
+
+\family default
+ (floating-point aware version of printf_fast) which should fit the requirements
+ of many embedded systems (printf_fast() can be customized by unsetting
+ #defines to
+\emph on
+not
+\emph default
+ support long variables and field widths).
+ Be sure to use only one of these printf options within a project.
+\newline
+
+\end_layout
+
+\begin_layout Standard
+Feature matrix of different
+\emph on
+printf
+\emph default
+ options on mcs51.
+\end_layout
+
+\begin_layout Standard
+\begin_inset Tabular
+<lyxtabular version="3" rows="14" columns="7">
+<features islongtable="true">
+<column alignment="left" valignment="middle" leftline="true" width="14col%">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="12col%">
+<column alignment="center" valignment="top" leftline="true" width="10col%">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
+<column alignment="center" valignment="top" rightline="true" width="0">
+<row topline="true" bottomline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\series bold
+\size large
+mcs51
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+printf
+\begin_inset LatexCommand index
+name "printf"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+printf
+\size scriptsize
+USE_FLOATS=1
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+printf_small
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+printf_fast
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+printf_fast_f
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+printf_tiny
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+filename
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\size scriptsize
+printf_large.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\size scriptsize
+printf_large.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\size scriptsize
+printfl.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\size scriptsize
+printf_fast.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\size scriptsize
+printf_fast_f.c
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+
+\size scriptsize
+printf_tiny.c
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+\begin_inset Quotes sld
+\end_inset
+
+Hello World
+\begin_inset Quotes srd
+\end_inset
+
+ size
+\end_layout
+
+\begin_layout Standard
+small / large
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.7k / 2.4k
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+4.3k / 5.6k
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.2k / 1.8k
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.3k / 1.3k
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.9k / 1.9k
+\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.44k / 0.44k
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row topline="true" endhead="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+code size
+\end_layout
+
+\begin_layout Standard
+small / large
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.4k / 2.0k
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+2.8k / 3.7k
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.45k / 0.47k (+ _ltoa)
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.2k / 1.2k
+\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.6k / 1.6k
+\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.26k / 0.26k
+\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
+formats
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+cdi
+\emph on
+o
+\emph default
+psux
+\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
+cd
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+f
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+i
+\family default
+\series default
+\shape default
+\size default
+\emph on
+\bar default
+\noun default
+o
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+psux
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+c
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+\color none
+d
+\family default
+\series default
+\shape default
+\size default
+\emph on
+\bar default
+\noun default
+o
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
+s
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+x
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+cdsux
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+cdfsux
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+cdsux
+\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
+long (32 bit) support
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\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
+x
+\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">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+byte arguments on stack
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+b
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+b
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="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>
+<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">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+float format
+\begin_inset LatexCommand index
+name "Floating point support"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+%f
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="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
+%f
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+Range limited to +/- 4294967040, precision limited to 8 digits past decimal
+\end_layout
+
+\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
+-
+\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
+float formats %e %g
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="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>
+<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
+field width
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+x
+\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 bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+string speed
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
+\backslash
+r', '
+\backslash
+n'); standard 8051 @ 22.1184 MHz, empty putchar()
+\end_layout
+
+\end_inset
+
+,
+\end_layout
+
+\begin_layout Standard
+small / large
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.52 / 2.59 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.53 / 2.62 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.92 / 0.93 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.45 / 0.45 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.46 / 0.46 ms
+\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.45 / 0.45 ms
+\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
+int speed
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
+ putchar()
+\end_layout
+
+\end_inset
+
+,
+\end_layout
+
+\begin_layout Standard
+small / large
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+3.01 / 3.61 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+3.01 / 3.61 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+3.51 / 18.13 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.22 / 0.22 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.23 / 0.23 ms
+\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.25 / 0.25 ms
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+printf_tiny integer speed is data dependent, worst case is 0.33 ms
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+long speed
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
+ empty putchar()
+\end_layout
+
+\end_inset
+
+,
+\end_layout
+
+\begin_layout Standard
+small / large
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+5.37 / 6.31 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+5.37 / 6.31 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+8.71 / 40.65 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.40 / 0.40 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+0.40 / 0.40 ms
+\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 bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+float speed
+\begin_inset Foot
+status collapsed
+
+\begin_layout Standard
+Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
+ empty putchar()
+\end_layout
+
+\end_inset
+
+,
+\end_layout
+
+\begin_layout Standard
+small / large
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+7.49 / 22.47 ms
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+-
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Standard
+1.04 / 1.04 ms
+\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 Subsubsection
+<malloc.h>
+\begin_inset LatexCommand index
+name "malloc.h"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+As of SDCC 2.6.2 you no longer need to call an initialization routine before
+ using dynamic memory allocation
+\begin_inset LatexCommand index
+name "dynamic memory allocation (malloc)"
+
+\end_inset
+
+ and a default heap
+\begin_inset LatexCommand index
+name "heap (malloc)"
+
+\end_inset
+
+ space of 1024 bytes is provided for malloc to allocate memory from.
+ If you need a different heap size you need to recompile _heap.c with the
+ required size defined in HEAP_SIZE.
+ It is recommended to make a copy of this file into your project directory
+ and compile it there with:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+sdcc -c _heap.c -D HEAD_SIZE=2048
+\end_layout
+
+\begin_layout Standard
+And then link it with:
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+sdcc main.rel _heap.rel
+\end_layout
+
+\begin_layout Subsection
+Math functions (sinf, powf, sqrtf etc.)
+\end_layout
+
+\begin_layout Subsubsection
+<math.h>
+\end_layout
+
+\begin_layout Standard
+See definitions in file <math.h>.
+\end_layout
+
+\begin_layout Subsection
+Other libraries
+\end_layout
+
+\begin_layout Standard
+Libraries
+\begin_inset LatexCommand index
+name "Libraries"
+
+\end_inset
+
+ included in SDCC should have a license at least as liberal as the GNU Lesser
+ General Public License
+\begin_inset LatexCommand index
+name "GNU Lesser General Public License, LGPL"
+
+\end_inset
+
+
+\emph on
+LGPL
+\emph default
+.
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+license statements for the libraries are missing.
+ sdcc/device/lib/ser_ir.c
+\end_layout
+
+\begin_layout Standard
+or _decdptr f.e.
+ come with a GPL (as opposed to LGPL) License - this will not be liberal
+ enough for many embedded programmers.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+If you have ported some library or want to share experience about some code
+ which f.e.
+ falls into any of these categories Busses (I
+\begin_inset Formula $^{\textrm{2}}$
+\end_inset
+
+C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
+ cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
+ Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list
+\begin_inset LatexCommand url
+target "http://sourceforge.net/mail/?group_id=599"
+
+\end_inset
+
+\InsetSpace ~
+would certainly like to hear about it.
+\end_layout
+
+\begin_layout Standard
+Programmers coding for embedded systems are not especially famous for being
+ enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
+e these references are very valuable.
+ Let's help to create a climate where information is shared.
+\begin_inset VSpace bigskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Memory Models
+\end_layout
+
+\begin_layout Subsection
+MCS51 Memory Models
+\begin_inset LatexCommand index
+name "Memory model"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "MCS51 memory model"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsubsection
+Small, Medium and Large
+\end_layout
+
+\begin_layout Standard
+SDCC allows three memory models for MCS51 code,
+\shape slanted
+small, medium
+\shape default
+ and
+\shape slanted
+large
+\shape default
+.
+ Modules compiled with different memory models should
+\emph on
+never
+\emph default
+ be combined together or the results would be unpredictable.
+ The library routines supplied with the compiler are compiled as small,
+ medium and large.
+ The compiled library modules are contained in separate directories as small,
+ medium and large so that you can link to the appropriate set.
+\end_layout
+
+\begin_layout Standard
+When the medium or large model is used all variables declared without a
+ storage class will be allocated into the external ram, this includes all
+ parameters and local variables (for non-reentrant
+\begin_inset LatexCommand index
+name "reentrant"
+
+\end_inset
+
+ functions).
+ When the small model is used variables without storage class are allocated
+ in the internal ram.
+\end_layout
+
+\begin_layout Standard
+Judicious usage of the processor specific storage classes
+\begin_inset LatexCommand index
+name "Storage class"
+
+\end_inset
+
+ and the 'reentrant' function type will yield much more efficient code,
+ than using the large model.
+ Several optimizations are disabled when the program is compiled using the
+ large model, it is therefore recommended that the small model be used unless
+ absolutely required.
+\end_layout
+
+\begin_layout Subsubsection
+External Stack
+\begin_inset LatexCommand label
+name "sub:External-Stack"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "stack"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "External stack (mcs51)"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The external stack (-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xstack option
+\begin_inset LatexCommand index
+name "-\\/-xstack"
+
+\end_inset
+
+) is located in pdata
+\begin_inset LatexCommand index
+name "pdata (mcs51, ds390 storage class)"
+
+\end_inset
+
+ memory (usually at the start of the external ram segment) and uses all
+ unused space in pdata (max.
+ 256 bytes).
+ When -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-xstack option is used to compile the program, the parameters and local
+ variables
+\begin_inset LatexCommand index
+name "local variables"
+
+\end_inset
+
+ of all reentrant functions are allocated in this area.
+ This option is provided for programs with large stack space requirements.
+ When used with the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\begin_inset LatexCommand index
+name "-\\/-stack-auto"
+
+\end_inset
+
+ option, all parameters and local variables are allocated on the external
+ stack (note: support libraries will need to be recompiled with the same
+ options.
+ There is a predefined target in the library makefile).
+\end_layout
+
+\begin_layout Standard
+The compiler outputs the higher order address byte of the external ram segment
+ into port P2
+\begin_inset LatexCommand index
+name "P2 (mcs51 sfr)"
+
+\end_inset
+
+ (see also section
+\begin_inset LatexCommand ref
+reference "sub:MCS51-variants"
+
+\end_inset
+
+), therefore when using the External Stack option, this port
+\emph on
+may not
+\emph default
+ be used by the application program.
+\end_layout
+
+\begin_layout Subsection
+DS390 Memory Model
+\begin_inset LatexCommand index
+name "Memory model"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "DS390 memory model"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The only model supported is Flat 24
+\begin_inset LatexCommand index
+name "Flat 24 (DS390 memory model)"
+
+\end_inset
+
+.
+ This generates code for the 24 bit contiguous addressing mode of the Dallas
+ DS80C390 part.
+ In this mode, up to four meg of external RAM or code space can be directly
+ addressed.
+ See the data sheets at www.dalsemi.com for further information on this part.
+\newline
+
+\newline
+Note
+ that the compiler does not generate any code to place the processor into
+ 24 bitmode (although
+\emph on
+tinibios
+\emph default
+ in the ds390 libraries will do that for you).
+ If you don't use
+\emph on
+tinibios
+\emph default
+
+\begin_inset LatexCommand index
+name "Tinibios (DS390)"
+
+\end_inset
+
+, the boot loader or similar code must ensure that the processor is in 24
+ bit contiguous addressing mode before calling the SDCC startup code.
+\newline
+
+\newline
+Like
+ the
+\emph on
+-
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-model-large
+\emph default
+ option, variables will by default be placed into the XDATA segment.
+
+\newline
+
+\newline
+Segments may be placed anywhere in the 4 meg address space using the usual
+ -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-*-loc options.
+ Note that if any segments are located above 64K, the -r flag must be passed
+ to the linker to generate the proper segment relocations, and the Intel
+ HEX output format must be used.
+ The -r flag can be passed to the linker by using the option
+\emph on
+-Wl-r
+\emph default
+ on the SDCC command line.
+ However, currently the linker can not handle code segments > 64k.
+\end_layout
+
+\begin_layout Section
+Pragmas
+\begin_inset LatexCommand label
+name "sec:Pragmas"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "Pragmas"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Pragmas are used to turn on and/or off certain compiler options.
+ Some of them are closely related to corresponding command-line options
+ (see section
+\begin_inset LatexCommand vref
+reference "sec:Command-Line-Options"
+
+\end_inset
+
+).
+\newline
+Pragmas should be placed before and/or after a function, placing pragmas
+ inside a function body could have unpredictable results.
+\newline
+
+\newline
+SDCC supports the
+ following #pragma directives:
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+save
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma save"
+
+\end_inset
+
+ - this will save most current options to the save/restore stack.
+ See #pragma\InsetSpace ~
+restore.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+restore
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma restore"
+
+\end_inset
+
+ - will restore saved options from the last save.
+ saves & restores can be nested.
+ SDCC uses a save/restore stack: save pushes current options to the stack,
+ restore pulls current options from the stack.
+ See #pragma\InsetSpace ~
+save.
+\newline
+
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+callee_saves
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma callee\\_saves"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "function prologue"
+
+\end_inset
+
+ function1[,function2[,function3...]]
+\begin_inset LatexCommand label
+name "ite:callee_saves-function1[,function2[,function3...]]--"
+
+\end_inset
+
+- The compiler by default uses a caller saves convention for register saving
+ across function calls, however this can cause unnecessary register pushing
+ and popping
+\begin_inset LatexCommand index
+name "push/pop"
+
+\end_inset
+
+ when calling small functions from larger functions.
+ This option can be used to switch off the register saving convention for
+ the function names specified.
+ The compiler will not save registers when calling these functions, extra
+ code need to be manually inserted at the entry and exit for these functions
+ to save and restore the registers used by these functions, this can SUBSTANTIAL
+LY reduce code and improve run time performance of the generated code.
+ In the future the compiler (with inter procedural analysis) may be able
+ to determine the appropriate scheme to use for each function call.
+ If -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-callee-saves command line option is used (see page
+\begin_inset LatexCommand vpageref
+reference "lyx:--callee-saves-function1[,function2][,function3]..."
+
+\end_inset
+
+), the function names specified in #pragma\InsetSpace ~
+callee_saves
+\begin_inset LatexCommand index
+name "\\#pragma callee\\_saves"
+
+\end_inset
+
+ is appended to the list of functions specified in the command line.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+exclude
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma exclude"
+
+\end_inset
+
+ none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
+ of pairs of push/pop
+\begin_inset LatexCommand index
+name "push/pop"
+
+\end_inset
+
+ instructions in
+\emph on
+I
+\emph default
+nterrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+
+\emph on
+S
+\emph default
+ervice
+\emph on
+R
+\emph default
+outines.
+ The directive should be placed immediately before the ISR function definition
+ and it affects ALL ISR functions following it.
+ To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
+exclude\InsetSpace ~
+none
+\begin_inset LatexCommand index
+name "\\#pragma exclude"
+
+\end_inset
+
+.
+ See also the related keyword _naked
+\begin_inset LatexCommand index
+name "\\_naked"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\_\\_naked"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+less_pedantic
+\series default
+
+\begin_inset LatexCommand index
+name "pedantic"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\#pragma less\\_pedantic"
+
+\end_inset
+
+
+\begin_inset LatexCommand label
+name "ite:less_pedantic"
+
+\end_inset
+
+- the compiler will not warn you anymore for obvious mistakes, you're on
+ your own now ;-( .
+ See also the command line option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-less-pedantic
+\begin_inset LatexCommand vpageref
+reference "lyx:--less-pedantic"
+
+\end_inset
+
+.
+
+\newline
+More specifically, the following warnings will be disabled:
+\shape italic
+comparison is always [true/false] due to limited range of data type
+\shape default
+ (94);
+\shape italic
+overflow in implicit constant conversion
+\shape default
+ (158); [the (in)famous]
+\shape italic
+conditional flow changed by optimizer: so said EVELYN the modified DOG
+\shape default
+ (110);
+\shape italic
+function '[function name]' must return value
+\shape default
+ (59).
+
+\newline
+Furthermore, warnings of less importance (of PEDANTIC and INFO warning
+ level) are disabled, too, namely:
+\shape italic
+constant value '[
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+dunno what comes here - this warning appears to be unused altogether
+\end_layout
+
+\end_inset
+
+]', out of range
+\shape default
+ (81);
+\shape italic
+[left/right] shifting more than size of object changed to zero
+\shape default
+ (116);
+\shape italic
+unreachable code
+\shape default
+ (126);
+\shape italic
+integer overflow in expression
+\shape default
+ (165);
+\shape italic
+unmatched #pragma save and #pragma restore
+\shape default
+ (170);
+\shape italic
+comparison of 'signed char' with 'unsigned char' requires promotion to int
+\shape default
+ (185);
+\shape italic
+ISO C90 does not support flexible array members
+\shape default
+ (187);
+\shape italic
+extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
+nam
+e]':\InsetSpace ~
+[
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+appears to be always blank - what was supposed to be here?
+\end_layout
+
+\end_inset
+
+]
+\shape default
+ (114);
+\shape italic
+function '[function name]', # edges [number] , # nodes [number] , cyclomatic
+ complexity [number]
+\shape default
+ (121).
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+disable_warning
+\series default
+ <nnnn>
+\begin_inset LatexCommand index
+name "\\#pragma disable\\_warning"
+
+\end_inset
+
+ - the compiler will not warn you anymore about warning number <nnnn>.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+nogcse
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma nogcse"
+
+\end_inset
+
+ - will stop global common subexpression elimination.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+noinduction
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma noinduction"
+
+\end_inset
+
+ - will stop loop induction optimizations.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+noinvariant
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma noinvariant"
+
+\end_inset
+
+ - will not do loop invariant optimizations.
+ For more details see Loop Invariants in section
+\begin_inset LatexCommand ref
+reference "sub:Loop-Optimizations"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+noiv
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma noiv"
+
+\end_inset
+
+ - Do not generate interrupt
+\begin_inset LatexCommand index
+name "interrupt"
+
+\end_inset
+
+ vector table
+\begin_inset LatexCommand index
+name "interrupt vector table"
+
+\end_inset
+
+ entries for all ISR functions defined after the pragma.
+ This is useful in cases where the interrupt vector table must be defined
+ manually, or when there is a secondary, manually defined interrupt vector
+ table (e.g.
+ for the autovector feature of the Cypress EZ-USB FX2).
+ More elegantly this can be achieved by omitting the optional interrupt
+ number after the interrupt keyword, see section
+\begin_inset LatexCommand ref
+reference "sub:Interrupt-Service-Routines"
+
+\end_inset
+
+\InsetSpace ~
+about interrupts.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+nojtbound
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma nojtbound"
+
+\end_inset
+
+ - will not generate code for boundary value checking, when switch statements
+ are turned into jump-tables (dangerous).
+ For more details see section
+\begin_inset LatexCommand ref
+reference "sub:'switch'-Statements"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+noloopreverse
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma noloopreverse"
+
+\end_inset
+
+ - Will not do loop reversal optimization
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+nooverlay
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma nooverlay"
+
+\end_inset
+
+ - the compiler will not overlay the parameters and local variables of a
+ function.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+stackauto
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma stackauto"
+
+\end_inset
+
+- See option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-stack-auto
+\begin_inset LatexCommand index
+name "-\\/-stack-auto"
+
+\end_inset
+
+ and section
+\begin_inset LatexCommand ref
+reference "sec:Parameters-and-Local-Variables"
+
+\end_inset
+
+ Parameters and Local Variables.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+opt_code_speed
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma opt\\_code\\_speed"
+
+\end_inset
+
+- The compiler will optimize code generation towards fast code, possibly
+ at the expense of code size.
+ Currently this has little effect.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+opt_code_size
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma opt\\_code\\_size"
+
+\end_inset
+
+- The compiler will optimize code generation towards compact code, possibly
+ at the expense of code speed.
+ Currently this has little effect.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+opt_code_balanced
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma opt\\_code\\_balanced"
+
+\end_inset
+
+- The compiler will attempt to generate code that is both compact and fast,
+ as long as meeting one goal is not a detriment to the other (this is the
+ default).
+
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+std_sdcc89
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma std\\_sdcc89"
+
+\end_inset
+
+- Generally follow the C89 standard, but allow SDCC features that conflict
+ with the standard (default).
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+std_c89
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma std\\_c89"
+
+\end_inset
+
+- Follow the C89 standard and disable SDCC features that conflict with the
+ standard.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+std_sdcc99
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma std\\_sdcc99"
+
+\end_inset
+
+- Generally follow the C99 standard, but allow SDCC features that conflict
+ with the standard (incomplete support).
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+std_c99
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma std\\_c99"
+
+\end_inset
+
+- Follow the C99 standard and disable SDCC features that conflict with the
+ standard (incomplete support).
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+codeseg
+\series default
+ <name>
+\begin_inset LatexCommand index
+name "\\#pragma codeseg"
+
+\end_inset
+
+- Use this name (max.
+ 8 characters) for the code segment.
+ See option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-codeseg.
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+constseg
+\series default
+ <name>
+\begin_inset LatexCommand index
+name "\\#pragma constseg"
+
+\end_inset
+
+- Use this name (max.
+ 8 characters) for the const segment.
+ See option -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-constseg.
+\end_layout
+
+\begin_layout Standard
+The preprocessor SDCPP
+\begin_inset LatexCommand index
+name "sdcpp (preprocessor)"
+
+\end_inset
+
+ supports the following #pragma directives:
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+pedantic_parse_number
+\series default
+
+\begin_inset LatexCommand index
+name "pedantic"
+
+\end_inset
+
+
+\begin_inset LatexCommand index
+name "\\#pragma pedantic\\_parse\\_number"
+
+\end_inset
+
+ (+ | -)
+\begin_inset LatexCommand label
+name "ite:pedantic_parse_number"
+
+\end_inset
+
+- Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
+ properly and the macro LO_B(3) gets expanded.
+ Default is off.
+ See also the -
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+/
+\end_layout
+
+\end_inset
+
+-pedantic-parse-number command line option
+\begin_inset LatexCommand vpageref
+reference "lyx:-pedantic-parse-number"
+
+\end_inset
+
+.
+
+\newline
+Below is an example on how to use this pragma.
+
+\emph on
+Note: this functionality is not in conformance with standard!
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+#pragma pedantic_parse_number +
+\begin_inset LatexCommand index
+name "\\#pragma pedantic\\_parse\\_number"
+
+\end_inset
+
+
+\newline
+
+\newline
+#define LO_B(x) ((x) & 0xff)
+\newline
+
+\newline
+unsigned char foo(void)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+unsigned char c=0xfe-LO_B(3)
+;
+\newline
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+return c;
+\newline
+}
+\newline
+
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+preproc_asm
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma preproc\\_asm"
+
+\end_inset
+
+ (+ | -) - switch _asm _endasm block preprocessing on / off.
+ Default is on.
+ You use this pragma to define multilines of assembly code.
+ This will prevent the preprocessor from changing the formatting required
+ by assembly code.
+ Below is an example on how to use this pragma.
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+#pragma preproc_asm -
+\begin_inset LatexCommand index
+name "\\#pragma preproc\\_asm"
+
+\end_inset
+
+
+\newline
+#define MYDELAY _asm
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+nop ;my assembly comment...
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+nop
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+nop
+\newline
+_endasm
+\newline
+#pragma preproc_asm
+ +
+\newline
+
+\newline
+void foo (void)
+\newline
+{
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ ...
+
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ MYDELAY;
+\newline
+\InsetSpace ~
+\InsetSpace ~
+\InsetSpace ~
+ ...
+
+\newline
+}
+\newline
+
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+sdcc_hash
+\series default
+
+\begin_inset LatexCommand index
+name "\\#pragma sdcc\\_hash"
+
+\end_inset
+
+ (+ | -) - Allow "naked" hash in macro definition, for example:
+\newline
+
+\family typewriter
+#define DIR_LO(x) #(x & 0xff)
+\family default
+
+\newline
+Default is off.
+ Below is an example on how to use this pragma.
+\end_layout
+
+\begin_layout Verse
+
+\family typewriter
+#pragma preproc_asm +
+\newline
+#pragma sdcc_hash +
+\begin_inset LatexCommand index
+name "\\#pragma sdcc\\_hash"