-#LyX 1.1 created this file. For more info see http://www.lyx.org/
-\lyxformat 218
+#LyX 1.2 created this file. For more info see http://www.lyx.org/
+\lyxformat 220
\textclass article
\language english
\inputencoding default
-\fontscheme times
+\fontscheme pslatex
\graphics default
\paperfontsize default
\spacing single
\paperpackage a4
\use_geometry 0
\use_amsmath 0
+\use_natbib 0
+\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\papersides 1
\paperpagestyle fancy
+\layout Comment
+
+Please note: double dashed longoptions (e.g.
+ --version) need three dashes in this document to be visable in html and
+ pdf output.
\layout Title
SDCC Compiler User Guide
\newline
The latest version can be downloaded from
-\begin_inset LatexCommand \htmlurl{http://sdcc.sourceforge.net/}
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
\end_inset
\emph on
freeware
\emph default
-; source code for all the sub-packages (asxxxx assembler/linker, pre-processor)
- is distributed with the package.
+; source code for all the sub-packages (pre-processor, assemblers, linkers
+ etc) is distributed with the package.
This documentation is maintained using a freeware word processor (LyX).
-
-\layout Standard
-
+\newline
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later version.
\family default
Interesting items and new terms are printed in
\emph on
-italicised type.
+italic.
\layout Subsection
Compatibility with previous versions
\layout Itemize
short is now equivalent to int (16 bits), it used to be equivalent to char
- (8 bits)
+ (8 bits) which is not ANSI compliant
\layout Itemize
-the default directory where include, library and documention files are stored
- is no in /usr/local/share
+the default directory for gcc-builds where include, library and documention
+ files are stored is now in /usr/local/share
\layout Itemize
char type parameters to vararg functions are casted to int unless explicitly
will push a as an int and as a char resp.
\layout Itemize
-option --regextend has been removed
+option ---regextend has been removed
+\layout Itemize
+
+option ---noregparms has been removed
\layout Itemize
-option --noreparms has been removed
+option ---stack-after-data has been removed
\layout Standard
\layout Standard
The SDCC home page at
-\begin_inset LatexCommand \htmlurl{http://sdcc.sourceforge.net/}
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
\end_inset
\layout Standard
-\family sans
-\series bold
-sdcc -c --model-large -o large _atoi.c
-\family default
-\series default
- (where large could be a different basename or a directory)
-\newline
-
-\layout Standard
-
-
\family typewriter
char KernelFunction3(char p) at 0x340;
\newline
Installation
\layout Subsection
-Linux/Unix Installation
+Install and search paths
+\layout Standard
+
+Linux (and other gcc-builds like Solaris, Cygwin, Mingw32 and OSX) by default
+ install in /usr/local.
+ You can override this when configuring with ---prefix-path.
+ Subdirs used will be bin, share/sdcc/include, share/sdcc/lib and share/sdcc/doc.
+\newline
+Windows MSVC and Borland builds will install in one single tree (e.g.
+ /sdcc) with subdirs bin, lib, include and doc.
+\newline
+
+\newline
+The paths searched when running the compiler are as follows (the first catch
+ wins):
+\layout Enumerate
+
+Binary files (preprocessor, assembler and linker):
+\newline
+- the path of argv[0] (if available)
+\newline
+- getenv(
+\begin_inset Quotes sld
+\end_inset
+
+SDCC_BIN_PATH
+\begin_inset Quotes srd
+\end_inset
+
+)
+\newline
+- getenv(
+\begin_inset Quotes sld
+\end_inset
+
+SDCCHOME
+\begin_inset Quotes srd
+\end_inset
+
+)/bin
+\newline
+- $PATH
+\layout Enumerate
+
+Include files:
+\newline
+- -I dir
+\newline
+- getenv(
+\begin_inset Quotes sld
+\end_inset
+
+SDCC_INCLUDE_PATH
+\begin_inset Quotes srd
+\end_inset
+
+)
+\newline
+- getenv(
+\begin_inset Quotes sld
+\end_inset
+
+SDCCHOME
+\begin_inset Quotes srd
+\end_inset
+
+)/include
+\newline
+- /usr/local/share/sdcc/include (gcc builds)
+\newline
+- path(arv[0])/../include and then /sdcc/include (as a last resort for windoze
+ msvc and borland builds)
+\layout Enumerate
+
+Library files (the
+\shape italic
+model
+\shape default
+ is auto-appended by the compiler, e.g.
+ small, large, z80, ds390 etc.):
+\newline
+- -L dir
+\newline
+- getenv(
+\begin_inset Quotes sld
+\end_inset
+
+SDCC_LIB_PATH
+\begin_inset Quotes srd
+\end_inset
+
+)/
+\shape italic
+model
+\shape default
+
+\newline
+- getenv(
+\begin_inset Quotes sld
+\end_inset
+
+SDCCHOME
+\begin_inset Quotes srd
+\end_inset
+
+)/lib/
+\shape italic
+model
+\shape default
+
+\newline
+- /usr/local/share/sdcc/lib/
+\shape italic
+model
+\shape default
+ (gcc builds)
+\newline
+- path(argv[0])/../lib/
+\shape italic
+model
+\shape default
+ and then /sdcc/lib/
+\shape italic
+model
+\shape default
+ (as a last resort for windoze msvc and borland builds)
+\layout Enumerate
+
+Documentation (although never really searched for, you have to do that yourself
+ :):
+\newline
+- getenv(
+\begin_inset Quotes sld
+\end_inset
+
+SDCCHOME
+\begin_inset Quotes srd
+\end_inset
+
+)/doc
+\newline
+- /usr/local/share/sdcc/doc (gcc builds)
+\newline
+- /sdcc/doc (windoze msvc and borland builds)
+\layout Standard
+
+So, for windoze it is highly recommended to set the environment variable
+ SDCCHOME to prevent needless usage of -I and -L options.
+ For gcc-builds SDCCHOME should only be set when sdcc is installed in non-standa
+rd paths.
+\layout Subsection
+
+Linux and other gcc-based systems (cygwin, mingw32, osx)
\layout Enumerate
\series medium
-Download the source package, it will be named something like sdcc-2.x.x.tgz.
+Download the source package
+\series default
+ either from the SDCC CVS repository or from the
+\begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
+
+\end_inset
+
+
+\series medium
+, it will be named something like sdcc
+\series default
+.src
+\series medium
+.tgz.
\layout Enumerate
Unpack the file using a command like:
\family sans
\series bold
-"tar -xzf sdcc-2.x.x.tgz
+"tar -xzf sdcc.src.tgz
\family default
\series default
"
the documentation to the install directories.
\layout Subsection
-Windows Installation
-\layout Standard
-
-
-\emph on
-<pending: is this complete? where is borland, mingw>
-\newline
-
-\newline
-
-\emph default
-For installation under Windows you first need to pick between a pre-compiled
- binary package, or installing the source package along with the Cygwin
- package.
- The binary package is the quickest to install, while the Cygwin package
- includes all of the open source power tools used to compile the complete
- SDCC source package in the Windows environment.
- If you are not familiar with the Unix command line environment, you may
- want to read the section on additional information for Windows users prior
- to your initial installation.
+Windows
\layout Subsubsection
Windows Install Using a Binary Package
Download the binary package 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 is: c:
+ An example directory structure after unpacking the mingw32 package is:
+ c:
\backslash
usr
\backslash
lib for the include and libraries.
\layout Enumerate
-Adjust your environment PATH to include the location of the bin directory.
- For example, make a setsdcc.bat file with the following: set PATH=c:
+Adjust your environment variable PATH to include the location of the bin
+ directory or start sdcc using the full path.
+\layout Subsubsection
+
+Windows Install Using Cygwin and Mingw32
+\layout Standard
+
+Follow the instruction in
+\series bold
+Linux and other gcc-based systems
+\series default
+.
+\layout Subsubsection
+
+Windows Install Using Microsoft Visual C++ 6.0/NET
+\layout Standard
+
+
+\series medium
+Download the source package
+\series default
+ either from the SDCC CVS repository or from the
+\begin_inset LatexCommand \url[nightly snapshots]{http://sdcc.sourceforge.net/snap.php}
+
+\end_inset
+
+
+\series medium
+, it will be named something like sdcc
+\series default
+.src
+\series medium
+.tgz.
+
+\series default
+ SDCC is distributed with all the projects, workspaces, and files you need
+ to build it using Visual C++ 6.0/NET.
+ The workspace name is 'sdcc.dsw'.
+ Please note that as it is now, all the executables are created in a folder
+ called sdcc
+\backslash
+bin_vc.
+ Once built you need to copy the executables from sdcc
+\backslash
+bin_vc to sdcc
+\backslash
+bin before runnng SDCC.
+
+\newline
+
+\newline
+In order to build SDCC with Visual C++ 6.0/NET you need win32 executables
+ of bison.exe, flex.exe, and gawk.exe.
+ One good place to get them is
+\begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
+
+\end_inset
+
+
+\newline
+
+\newline
+Download the file UnxUtils.zip.
+ Now you have to install the utilities and setup Visual C++ so it can locate
+ the required programs.
+ Here there are two alternatives (choose one!):
+\layout Enumerate
+
+The easy way:
+\newline
+
+\newline
+a) Extract UnxUtils.zip to your C:
\backslash
-usr
+ hard disk PRESERVING the original paths, otherwise bison won't work.
+ (If you are using WinZip make certain that 'Use folder names' is selected)
+\newline
+
+\newline
+b) In the Visual C++ IDE click Tools, Options, select the Directory tab,
+ in 'Show directories for:' select 'Executable files', and in the directories
+ window add a new path: 'C:
+\backslash
+user
\backslash
local
\backslash
-bin;%PATH%
+wbin', click ok.
+\newline
+
+\newline
+(As a side effect, you get a bunch of Unix utilities that could be useful,
+ such as diff and patch.)
\layout Enumerate
-When you compile with sdcc, you may need to specify the location of the
- lib and include folders.
- For example, sdcc -I c:
+A more compact way:
+\newline
+
+\newline
+This one avoids extracting a bunch of files you may not use, but requires
+ some extra work:
+\newline
+
+\newline
+a) Create a directory were to put the tools needed, or use a directory already
+ present.
+ Say for example 'C:
\backslash
-usr
+util'.
+\newline
+
+\newline
+b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and gawk.exe
+ to such directory WITHOUT preserving the original paths.
+ (If you are using WinZip make certain that 'Use folder names' is not selected)
+\newline
+
+\newline
+c) Rename bison.exe to '_bison.exe'.
+\newline
+
+\newline
+d) Create a batch file 'bison.bat' in 'C:
\backslash
-local
+util
\backslash
-share
+' and add these lines:
+\newline
+\SpecialChar ~
+\SpecialChar ~
+set BISON_SIMPLE=C:
\backslash
-sdcc
+util
\backslash
-include -L c:
+bison.simple
+\newline
+\SpecialChar ~
+\SpecialChar ~
+set BISON_HAIRY=C:
\backslash
-usr
+util
\backslash
-local
+bison.hairy
+\newline
+\SpecialChar ~
+\SpecialChar ~
+_bison %1 %2 %3 %4 %5 %6 %7 %8 %9
+\newline
+
+\newline
+Steps 'c' and 'd' are needed because bison requires by default that the
+ files 'bison.simple' and 'bison.hairy' reside in some weird Unix directory,
+ '/usr/local/share/' I think.
+ So it is necessary to tell bison where those files are located if they
+ are not in such directory.
+ That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
+\newline
+
+\newline
+e) In the Visual C++ IDE click Tools, Options, select the Directory tab,
+ in 'Show directories for:' select 'Executable files', and in the directories
+ window add a new path: 'c:
\backslash
-share
+util', click ok.
+ Note that you can use any other path instead of 'c:
\backslash
-sdcc
+util', even the path where the Visual C++ tools are, probably: 'C:
+\backslash
+Program Files
\backslash
-lib
+Microsoft Visual Studio
\backslash
-small test.c
+Common
+\backslash
+Tools'.
+ So you don't have to execute step 'e' :)
+\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.
\layout Subsubsection
-Windows Install Using Cygwin
+Windows Install Using Borland
\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.exe (which currently doesn't build under Borland C++).
+\layout Enumerate
-\series medium
-Download and install the cygwin package from the redhat site
-\series default
-
-\begin_inset LatexCommand \htmlurl{http://sources.redhat.com/cygwin/}
-
-\end_inset
-
+If you modify any source files and need to rebuild, be aware that the dependanci
+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 commmand:
+\newline
-\series medium
-.
- Currently, this involved downloading a small install program which then
- automates downloading and installing
-\series default
-selected parts of
-\series medium
- the package
-\series default
- (a large 80M byte sized dowload for the whole thing)
-\series medium
-.
+\newline
-\series default
+\family sans
+\series bold
+find .
-\layout Enumerate
+\backslash
+( -name '*.obj' -o -name '*.lib' -o -name '*.rul'
+\backslash
+) -print -exec rm {}
+\backslash
+;
+\family default
+\series default
+\newline
-\series medium
-Bring up a
-\series default
-Unix/Bash
-\series medium
-command line terminal from the Cygwin menu.
-\layout Enumerate
+\newline
+or on Windows NT/2000/XP from the command prompt with the commmand:
+\newline
+\family sans
+\series bold
-\series medium
-Follow the instructions in the preceding Linux/Unix installation section.
+\newline
+del /s *.obj *.lib *.rul
+\family default
+\series default
+ from the sdcc directory.
\layout Subsection
Testing out the SDCC Compiler
Type
\family sans
\series bold
-"sdcc --version"
+"sdcc ---version"
\family default
\series default
at the prompt, and the program should run and tell you the version.
\newline
\series medium
-SDCC binaries are commonly installed in a directory arrangement like this:
+SDCC
\series default
+is commonly installed as described in section
+\begin_inset Quotes sld
+\end_inset
-\newline
+Install and search paths
+\begin_inset Quotes srd
+\end_inset
-\newline
-\begin_inset Tabular
-<lyxtabular version="2" rows="3" columns="2">
-<features rotate="false" islongtable="false" endhead="0" endfirsthead="0" endfoot="0" endlastfoot="0">
-<column alignment="left" valignment="top" leftline="true" rightline="false" width="" special="">
-<column alignment="left" valignment="top" leftline="true" rightline="true" width="" special="">
-<row topline="true" bottomline="true" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
-\begin_inset Text
+\newline
-\layout Standard
+\newline
-/
\series medium
-usr/local/bin
-\end_inset
-</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
-\begin_inset Text
-
-\layout Standard
-
-
-\series medium
-Holds executables(sdcc, s51, aslink,
+Make sure the compiler works on a very simple example.
+ Type in the following test.c program using your favorite
\series default
-...
-\series medium
-)
-\end_inset
-</cell>
-</row>
-<row topline="true" bottomline="false" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
-\begin_inset Text
-
-\layout Standard
-
-/
-\series medium
-usr/local/share/sdcc/lib
-\end_inset
-</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
-\begin_inset Text
-
-\layout Standard
-
-
+ascii
\series medium
-Holds common C
+editor:
\series default
-libraries
-\end_inset
-</cell>
-</row>
-<row topline="true" bottomline="true" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
-\begin_inset Text
-
-\layout Standard
-
-/
-\series medium
-usr/local/share/sdcc/include
-\end_inset
-</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
-\begin_inset Text
-
-\layout Standard
-
-
-\series medium
-Holds common C header files
-\end_inset
-</cell>
-</row>
-</lyxtabular>
-
-\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 editor:
-\series default
+\family typewriter
\newline
-
-\emph on
-
+char test;
\newline
-\family typewriter
-\emph default
-int test(int t) {
+\newline
+void main(void) {
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-return t+3;
+test=0;
\newline
}
\family default
\newline
\newline
+
+\family typewriter
#include <string.h>
\newline
-main() {
-\newline
-\family typewriter
+\newline
char str1[10];
\newline
-\SpecialChar ~
-\SpecialChar ~
+
+\newline
+void main(void) {
+\newline
\SpecialChar ~
\SpecialChar ~
strcpy(str1, "testing");
Install Trouble-shooting
\layout Subsubsection
-SDCC cannot find libraries or header files.
+SDCC does not build correctly.
\layout Standard
-The default installation assumes the libraries and header files are located
- at
-\begin_inset Quotes eld
-\end_inset
-
-/usr/local/share/sdcc/lib
-\begin_inset Quotes erd
-\end_inset
-
- and
-\begin_inset Quotes eld
-\end_inset
+A thing to try is starting from scratch by unpacking the .tgz source package
+ again in an empty directory.
+ Confure it like:
+\newline
-/usr/local/share/sdcc/include
-\begin_inset Quotes erd
-\end_inset
+\newline
-.
- An alternative is to specify these locations as compiler options like this:
-
\family sans
\series bold
-"sdcc\SpecialChar ~
--L\SpecialChar ~
-/usr/local/sdcc/lib/small\SpecialChar ~
--I\SpecialChar ~
-/usr/local/sdcc/include\SpecialChar ~
-test.c"
+./configure 2>&1 | tee configure.log
\family default
\series default
-.
-\layout Subsubsection
-SDCC does not compile correctly.
-\layout Standard
+\newline
-A thing to try is starting from scratch by unpacking the .tgz source package
- again in an empty directory.
- Confure it again and build like:
+\newline
+and build it like:
\newline
\newline
\family sans
\series bold
-make 2&>1 | tee make.log
+make 2>&1 | tee make.log
\family default
\series default
\newline
\newline
-After this you can review the make.log file to locate the problem.
- Or a relevant part of this be attached to an email that could be helpful
+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.
\layout Subsubsection
command does.
\layout Standard
-This will install the compiler, other executables and libraries in to the
- appropriate system directories.
- The default is to copy the executables to /usr/local/bin and the libraries
- and header files to /usr/local/share/sdcc/lib and /usr/local/share/sdcc/include.
-\layout Subsection
-
-Additional Information for Windows Users
-\layout Standard
-
-
-\emph on
-<pending: is this up to date?>
-\newline
-
-\newline
-
-\emph default
-The standard method of installing on a Unix system involves compiling the
- source package.
- This is easily done under Unix, but under Windows it can be a more difficult
- process.
- The Cygwin is a large package to download, and the compilation runs considerabl
-y slower under Windows due to the overhead of the Cygwin tool set.
- An alternative is to install a pre-compiled Windows binary package.
- There are various trade-offs between each of these methods.
-
-\layout Standard
-
-The Cygwin package allows a Windows user to run a Unix command line interface
- (bash shell) and also implements a Unix like file system on top of Windows.
- Included are many of the famous GNU software development tools which can
- augment the SDCC compiler.This is great if you have some experience with
- Unix command line tools and file system conventions, if not you may find
- it easier to start by installing a binary Windows package.
- The binary packages work with the Windows file system conventions.
-\layout Subsubsection
-
-Getting started with Cygwin
-\layout Standard
-
-SDCC is typically distributed as a tarred/gzipped file (.tgz).
- This is a packed file similar to a .zip file.
- Cygwin includes the tools you will need to unpack the SDCC distribution
- (tar and gzip).
- To unpack it, simply follow the instructions under the Linux/Unix install
- section.
- Before you do this you need to learn how to start a cygwin shell and some
- of the basic commands used to move files, change directory, run commands
- and so on.
- The change directory command is
-\family sans
-\series bold
-
-\begin_inset Quotes eld
-\end_inset
-
-cd
-\begin_inset Quotes erd
-\end_inset
-
-
-\family default
-\series default
-, the move command is
-\family sans
-\series bold
-
-\begin_inset Quotes eld
-\end_inset
-
-mv
-\begin_inset Quotes erd
-\end_inset
-
-
-\family default
-\series default
-.
- To print the current working directory, type
-\family sans
-\series bold
-
-\begin_inset Quotes eld
-\end_inset
-
-pwd
-\begin_inset Quotes erd
-\end_inset
-
-
-\family default
-\series default
-.
- To make a directory, use
-\family sans
-\series bold
-
-\begin_inset Quotes eld
-\end_inset
-
-mkdir
-\begin_inset Quotes erd
-\end_inset
-
-
-\family default
-\series default
-.
-\layout Standard
-
-There are some basic differences between Unix and Windows file systems you
- should understand.
- When you type in directory paths, Unix and the Cygwin bash prompt uses
- forward slashes '/' between directories while Windows traditionally uses
- '
-\backslash
-' backward slashes.
- So when you work at the Cygwin bash prompt, you will need to use the forward
- '/' slashes.
- Unix does not have a concept of drive letters, such as
-\begin_inset Quotes eld
+This will install the compiler, other executables libraries and include
+ files in to the appropriate directories.
+ See section
+\begin_inset Quotes sld
\end_inset
-c:
-\begin_inset Quotes eld
+Install and Search PATHS
+\begin_inset Quotes srd
\end_inset
-, instead all files systems attach and appear as directories.
-\layout Subsubsection
-
-Running SDCC as Native Compiled Executables
-\layout Standard
-
-If you use the pre-compiled binaries, the install directories for the libraries
- and header files may need to be specified on the sdcc command line like
- this:
-\family sans
-\series bold
-"sdcc -L c:
-\backslash
-usr
-\backslash
-local
-\backslash
-sdcc
-\backslash
-lib
-\backslash
-small -I c:
-\backslash
-usr
-\backslash
-local
-\backslash
-sdcc
-\backslash
-include test.c"
-\family default
-\series default
- if you are running outside of a Unix bash shell.
-\layout Standard
-
-If you have successfully installed and compiled SDCC with the Cygwin package,
- it is possible to compile into native .exe files by using the additional
- makefiles included for this purpose.
- For example, with the Borland 32-bit compiler you would run
-\family sans
-\series bold
-"make -f Makefile.bcc"
-\family default
-\series default
.
- A command line version of the Borland 32-bit compiler can be downloaded
- from the Inprise web site.
-\layout Subsection
-
-SDCC on Other Platforms
-\layout Itemize
-
-
-\series bold
-FreeBSD and other non-GNU Unixes
-\series default
-- Make sure the GNU make is installed as the default make tool.
-\layout Itemize
-
-SDCC has been ported to run under a variety of operating systems and processors.
- If you can run GNU GCC/make then chances are good SDCC can be compiled
- and run on your system.
-\layout Subsection
-
-Advanced Install Options
-\layout Standard
-
-The
-\begin_inset Quotes eld
-\end_inset
-
-configure
-\begin_inset Quotes erd
-\end_inset
-
- command has several options.
- The most commonly used option is --prefix=<directory name>, where <directory
- name> is the final location for the sdcc executables and libraries, (default
- location is /usr/local).
- The installation process will create the following directory structure
- under the <directory name> specified (if they do not already exist).
-
-\newline
-
-\newline
-bin/ - binary exectables (add to PATH environment variable)
-\newline
-bin/share/
-\newline
-bin/share/sdcc/include/ - include header files
-\newline
-bin/share/sdcc/lib/
-\newline
-bin/share/sdcc/lib/small/ - Object & library files for small model library
\newline
-bin/share/sdcc/lib/large/ - Object & library files for large model library
-\newline
-bin/share/sdcc/lib/ds390/ - Object & library files forDS80C390 library
-\newline
-
-\newline
-The command
-\family sans
-\series bold
-
-\begin_inset Quotes sld
-\end_inset
-
-./configure --prefix=/usr/local
-\begin_inset Quotes erd
-\end_inset
-
-
-\family default
-\series default
-will configure the compiler to be installed in directory /usr/local.
+On most systems you will need super-user privilages to do this.
\layout Subsection
Components of SDCC
\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:
+ At the time of this writing, we find the following programs for gcc-builds:
\newline
\newline
sdcdb - The source debugger.
\layout Itemize
-packihx - A tool to pack Intel hex files.
+packihx - A tool to pack (compress) Intel hex files.
\layout Standard
In <installdir>/share/sdcc/include
In <installdir>/share/sdcc/lib
\layout Itemize
-the sources of the runtime library and the subdirs small large and ds390
- with the precompiled relocatables.
+the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
+ relocatables.
\layout Standard
In <installdir>/share/sdcc/doc
the assembler and linkage editor.
\layout Subsubsection
-sdcpp (C-Preprocessor)
+sdcpp - The C-Preprocessor
\layout Standard
The preprocessor is a modified version of the GNU preprocessor.
statements, #defines and so on.
\layout Subsubsection
-asx8051, as-z80, as-gbz80, aslink, link-z80, link-gbz80 (The Assemblers
- and Linkage Editors)
+asx8051, as-z80, as-gbz80, aslink, link-z80, link-gbz80 - The Assemblers
+ and Linkage Editors
\layout Standard
This is retargettable assembler & linkage editor, it was developed by Alan
enhancements and bug fixes for it to work properly with the SDCC.
\layout Subsubsection
-s51 - Simulator
+s51 - The Simulator
\layout Standard
S51 is a freeware, opensource simulator developed by Daniel Drotos (
\end_inset
- .
+.
+ It currently support the core mcs51, the Dallas DS80C390 and the Philips
+ XA51 family.
\layout Subsubsection
sdcdb - Source Level Debugger
\layout Standard
+
+\family typewriter
+\shape italic
+<todo: is this thing still alive?>
+\newline
+
+\newline
+
+\family default
+\shape default
Sdcdb is the companion source level debugger.
The current version of the debugger uses Daniel's Simulator S51, but can
be easily changed to use other simulators.
sourcefile.map - The memory map for the load module, created by the Linker
\newline
sourcefile.ihx - The load module in Intel hex format (you can select the
- Motorola S19 format with --out-fmt-s19)
+ Motorola S19 format with ---out-fmt-s19)
\newline
-sourcefile.cdb - An optional file (with --debug) containing debug information
+sourcefile.cdb - An optional file (with ---debug) containing debug information
\newline
+sourcefile.dump* - Dump file to debug the compiler it self (with ---dumpall)
+ (see section
+\begin_inset Quotes sld
+\end_inset
+
+Anatomy of the compiler
+\begin_inset Quotes srd
+\end_inset
+).
\layout Subsubsection
Projects with Multiple Source Files
\series bold
-mavr
\series default
- Generate code for the Atmel AVR processor(In development, not complete).
+ Generate code for the Atmel AVR processor (In development, not complete).
\layout List
\labelwidthstring 00.00.0000
\series bold
-mpic14
\series default
- Generate code for the PIC 14-bit processors(In development, not complete).
+ Generate code for the PIC 14-bit processors (In development, not complete).
\layout List
\labelwidthstring 00.00.0000
\series bold
-mtlcs900h
\series default
- Generate code for the Toshiba TLCS-900H processor(In development, not complete).
+ Generate code for the Toshiba TLCS-900H processor (In development, not
+ complete).
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+-mxa51
+\series default
+ Generate code for the Philips XA51 processor (In development, not complete).
\layout Subsubsection
Preprocessor Options
\series bold
-L\SpecialChar ~
---lib-path
+---lib-path
\bar under
\series default
\series bold
---xram-loc
+---xram-loc
\series default
<Value> The start location of the external ram, default value is 0.
- The value entered can be in Hexadecimal or Decimal format, e.g.: --xram-loc
- 0x8000 or --xram-loc 32768.
+ The value entered can be in Hexadecimal or Decimal format, e.g.: ---xram-loc
+ 0x8000 or ---xram-loc 32768.
\layout List
\labelwidthstring 00.00.0000
\series bold
---code-loc
+---code-loc
\series default
<Value> The start location of the code segment, default value 0.
Note when this option is used the interrupt vector table is also relocated
to the given address.
- The value entered can be in Hexadecimal or Decimal format, e.g.: --code-loc
- 0x8000 or --code-loc 32768.
-\layout List
-\labelwidthstring 00.00.0000
-
-
-\series bold
---stack-loc
-\series default
-<Value> The initial value of the stack pointer.
- The default value of the stack pointer is 0x07 if only register bank 0
- is used, if other register banks are used then the stack pointer is initialized
- to the location above the highest register bank used.
- eg.
- if register banks 1 & 2 are used the stack pointer will default to location
- 0x18.
- The value entered can be in Hexadecimal or Decimal format, eg.
- --stack-loc 0x20 or --stack-loc 32.
- If all four register banks are used the stack will be placed after the
- data segment (equivalent to --stack-after-data)
+ The value entered can be in Hexadecimal or Decimal format, e.g.: ---code-loc
+ 0x8000 or ---code-loc 32768.
\layout List
\labelwidthstring 00.00.0000
\series bold
---stack-after-data
+---stack-loc
\series default
- This option will cause the stack to be located in the internal ram after
- the data segment.
+<Value> By default the stack 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.
+ ---stack-loc 0x20 or ---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.
\layout List
\labelwidthstring 00.00.0000
\series bold
---data-loc
+---data-loc
\series default
-<Value> The start location of the internal ram data segment, the default
- value is 0x30.The value entered can be in Hexadecimal or Decimal format,
- eg.
- --data-loc 0x20 or --data-loc 32.
+<Value> The start location of the internal ram data segment.
+ The value entered can be in Hexadecimal or Decimal format, eg.
+ ---data-loc 0x20 or ---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 ---data-loc is not used, to location 0x10.)
\layout List
\labelwidthstring 00.00.0000
\series bold
---idata-loc
+---idata-loc
\series default
<Value> The start location of the indirectly addressable internal ram, default
value is 0x80.
The value entered can be in Hexadecimal or Decimal format, eg.
- --idata-loc 0x88 or --idata-loc 136.
+ ---idata-loc 0x88 or ---idata-loc 136.
\layout List
\labelwidthstring 00.00.0000
\series bold
---out-fmt-ihx
+---out-fmt-ihx
\bar under
\series default
\series bold
---out-fmt-s19
+---out-fmt-s19
\bar under
\series default
\series bold
---model-large
+---model-large
\series default
Generate code for Large model programs see section Memory Models for more
details.
\series bold
---model-small
+---model-small
\series default
\size large
\emph on
\series bold
---model-flat24
+---model-flat24
\series default
\size large
\emph on
\series bold
---stack-10bit
+---stack-10bit
\series default
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
any re-entrant functions compiled with this option.
In principle, this should work with the
\emph on
---stack-auto
+---stack-auto
\emph default
option, but that has not been tested.
It is incompatible with the
\emph on
---xstack
+---xstack
\emph default
option.
It also only makes sense if the processor is in 24 bit contiguous addressing
mode (see the
\emph on
---model-flat24 option
+---model-flat24 option
\emph default
).
\layout Subsubsection
\series bold
---nogcse
+---nogcse
\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
\series bold
---noinvariant
+---noinvariant
\series default
Will not do loop invariant optimizations, this may be turned off for reasons
explained for the previous option.
\series bold
---noinduction
+---noinduction
\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\SpecialChar ~
\series bold
---nojtbound
+---nojtbound
\size large
\bar under
\series bold
---noloopreverse
+---noloopreverse
\series default
\size large
\size default
Will not do loop reversal optimization.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+---no-xinit-opt
+\series default
+ This will disable the memcpy of initialized data in far space from code
+ space
\layout Subsubsection
Other Options
\series bold
-c\SpecialChar ~
---compile-only
+---compile-only
\series default
will compile and assemble the source, but will not call the linkage editor.
\layout List
\labelwidthstring 00.00.0000
+\series bold
+--c1mode
+\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.
+\layout List
+\labelwidthstring 00.00.0000
+
+
\series bold
-E
\series default
\series bold
---stack-auto
+-o\SpecialChar ~
+<path/file>
+\series default
+The output path resp.
+ file where everything will be placed.
+ If the parameter is a path, it must have a trailing slash (or backslash
+ for the Windows binaries) to be recognized as a path.
+
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+---stack-auto
\series default
\size large
\emph on
\series bold
---xstack
+---xstack
\series default
Uses a pseudo stack in the first 256 bytes in the external ram for allocating
variables and passing parameters.
\series bold
---callee-saves function1[,function2][,function3]....
+---callee-saves function1[,function2][,function3]....
\series default
The compiler by default uses a caller saves convention for register saving
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 --callee-saves option string.
+ should be compiled with the same ---callee-saves option string.
Also see #pragma\SpecialChar ~
CALLEE-SAVES.
\layout List
\series bold
---debug
+---debug
\bar under
\series default
\series bold
-\emph on
---regextend
-\bar under
-
-\series default
-\bar default
- This option is obsolete and isn't supported anymore.
-\layout List
-\labelwidthstring 00.00.0000
-
-
-\series bold
-\emph on
---noregparms
-\series default
- This option is obsolete and isn't supported anymore.
-\layout List
-\labelwidthstring 00.00.0000
-
-
-\series bold
---peep-file
+---peep-file
\series default
<filename> This option can be used to use additional rules to be used by
the peep hole optimizer.
\series bold
---int-long-reent
+---int-long-reent
\series default
\size large
\series bold
---cyclomatic
+---cyclomatic
\bar under
\series default
\series bold
---float-reent
+---float-reent
\bar under
\series default
\series bold
---nooverlay
+---nooverlay
\series default
The compiler will not overlay parameters and local variables of any function,
see section Parameters and local variables for more details.
\series bold
---main-return
+---main-return
\series default
This option can be used when the code generated is called by a monitor
program.
\series bold
---no-peep
+---no-peep
\series default
Disable peep-hole optimization.
\layout List
\series bold
---peep-asm
+---peep-asm
\series default
Pass the inline assembler code through the peep hole optimizer.
This can cause unexpected changes to inline assembler code, please go through
\series bold
---iram-size
+---iram-size
+\series default
+<Value> Causes the linker to check if the internal ram usage is within limits
+ of the given value.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+---xram-size
\series default
-<Value> Causes the linker to check if the interal ram usage is within limits
+<Value> Causes the linker to check if the external ram usage is within limits
of the given value.
\layout List
\labelwidthstring 00.00.0000
\series bold
---nostdincl
+---code-size
+\series default
+<Value> Causes the linker to check if the code usage is within limits of
+ the given value.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+---nostdincl
\series default
This will prevent the compiler from passing on the default include path
to the preprocessor.
\series bold
---nostdlib
+---nostdlib
\series default
This will prevent the compiler from passing on the default library path
to the linker.
\series bold
---verbose
+---verbose
\series default
Shows the various actions the compiler is performing.
\layout List
-V
\series default
Shows the actual commands the compiler is executing.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+---no-c-code-in-asm
+\series default
+ Hides your ugly and inefficient c-code from the asm file, so you can always
+ blame the compiler :).
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+---i-code-in-asm
+\series default
+ Include i-codes in the asm file.
+ Looks like noise but is most helpfull for debugging the compiler itself.
\layout Subsubsection
Intermediate Dump Options
\series bold
---dumpraw
+---dumpraw
\series default
This option will cause the compiler to dump the intermediate code into
a file of named
\series bold
---dumpgcse
+---dumpgcse
\series default
Will create a dump of iCode's, after global subexpression elimination,
into a file named
\series bold
---dumpdeadcode
+---dumpdeadcode
\series default
Will create a dump of iCode's, after deadcode elimination, into a file
named
\series bold
---dumploop
+---dumploop
\series default
\size large
\series bold
---dumprange
+---dumprange
\series default
\size large
\series bold
---dumlrange
+---dumlrange
\series default
Will dump the life ranges for all symbols.
\layout List
\series bold
---dumpregassign
+---dumpregassign
\bar under
\series default
\series bold
---dumplrange
+---dumplrange
\series default
Will create a dump of the live ranges of iTemp's
\layout List
\series bold
---dumpall
+---dumpall
\size large
\bar under
Will cause all the above mentioned dumps to be created.
\layout Subsection
+Environment variables
+\layout Standard
+
+SDCC recognizes the following environment variables:
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+SDCC_LEAVE_SIGNALS
+\series default
+ SDCC installs a signal handler 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.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+TMP,\SpecialChar ~
+TEMP,\SpecialChar ~
+TMPDIR
+\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.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+(coming\SpecialChar ~
+soon:\SpecialChar ~
+SDCC_BIN_PATH)
+\series default
+ Path, see
+\begin_inset Quotes sld
+\end_inset
+
+2.1 Install and search paths
+\begin_inset Quotes srd
+\end_inset
+
+.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+(coming\SpecialChar ~
+soon:\SpecialChar ~
+SDCC_INCLUDE_PATH)
+\series default
+ Path, see
+\begin_inset Quotes sld
+\end_inset
+
+2.1 Install and search paths
+\begin_inset Quotes srd
+\end_inset
+
+.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+(coming\SpecialChar ~
+soon:\SpecialChar ~
+SDCC_LIB_PATH)
+\series default
+ Path, see
+\begin_inset Quotes sld
+\end_inset
+
+2.1 Install and search paths
+\begin_inset Quotes srd
+\end_inset
+
+.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold
+SDCCDIR\SpecialChar ~
+(soon\SpecialChar ~
+replaced\SpecialChar ~
+by:\SpecialChar ~
+SDCCPATH)
+\series default
+ Path, see
+\begin_inset Quotes sld
+\end_inset
+
+2.1 Install and search paths
+\begin_inset Quotes srd
+\end_inset
+
+.
+\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 documentated.
+\layout Subsection
+
MCS51/DS390 Storage Class Language Extensions
\layout Standard
SDCC allows (via language extensions) pointers to explicitly point to any
of the memory spaces of the 8051.
- In addition to the explicit pointers, the compiler also allows a
-\emph on
-_generic
-\emph default
- class of pointers which can be used to point to any of the memory spaces.
+ 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
\newline
\newline
-
-\emph on
-For compatibility with the previous version of the compiler, the following
- syntax for pointer declaration is still supported but will disappear int
- the near future.
-
-\newline
-
-\newline
-
-\family typewriter
-unsigned char _xdata *ucxdp; /* pointer to data in external ram */
-\newline
-unsigned char _data \SpecialChar ~
-*ucdp ; /* pointer to data in internal ram */
-\newline
-unsigned char _code \SpecialChar ~
-*uccp ; /* pointer to data in R/O code space */
-\newline
-unsigned char _idata *uccp; \SpecialChar ~
-/* pointer to upper 128 bytes of ram */
-\family default
-\size small
-\emph default
-
-\newline
-
-\newline
-
-\size default
All unqualified pointers are treated as 3-byte (4-byte for the ds390)
\emph on
generic
\emph default
pointers.
- These type of pointers can also to be explicitly declared.
-\newline
-
-\newline
-
-\family typewriter
-unsigned char _generic *ucgp;
-\family default
+
\size small
\newline
These are useful for developing reusable library routines.
Explicitly specifying the pointer type will generate the most efficient
code.
- Pointers declared using a mixture of OLD and NEW style could have unpredictable
- results.
\layout Subsection
Parameters & Local Variables
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 Large model).
+ RAM (for small model) or external RAM (for large model).
This in fact makes them
\emph on
static
\emph default
so by default functions are non-reentrant.
-\layout Standard
+\newline
+\newline
They can be placed on the stack either by using the
\emph on
- --stack-auto
+ ---stack-auto
\emph default
- compiler option or by using the
+ option or by using the
\emph on
reentrant
\emph default
\emph default
keyword or the
\emph on
- --stack-auto
+ ---stack-auto
\emph default
option should be used sparingly.
Note that the reentrant keyword just means that the parameters & local
in internal ram.
When compiled with
\emph on
---stack-auto
+---stack-auto
\emph default
or when a function is declared as
\emph on
reentrant
\emph default
- this can only be done for static variables.
+ this should only be done for static variables.
\layout Standard
Parameters however are not allowed any storage class, (storage classes for
these operations then the support routines (as mentioned in a following
section) will have to be recompiled using the
\emph on
- --stack-auto
+ ---stack-auto
\emph default
option and the source file will need to be compiled using the
\emph on
---int-long-ren
+---int-long-ren
\emph default
t compiler option.
\layout Standard
\begin_inset Tabular
-<lyxtabular version="2" rows="6" columns="3">
-<features rotate="false" islongtable="false" endhead="0" endfirsthead="0" endfoot="0" endlastfoot="0">
-<column alignment="center" valignment="top" leftline="true" rightline="false" width="" special="">
-<column alignment="center" valignment="top" leftline="true" rightline="false" width="" special="">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="" special="">
-<row topline="true" bottomline="true" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<lyxtabular version="3" rows="6" columns="3">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0pt">
+<column alignment="center" valignment="top" leftline="true" width="0pt">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
Interrupt #
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
Description
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
\end_inset
</cell>
</row>
-<row topline="true" bottomline="false" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
0
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
External 0
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
\end_inset
</cell>
</row>
-<row topline="true" bottomline="false" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
1
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
Timer 0
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
\end_inset
</cell>
</row>
-<row topline="true" bottomline="false" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
2
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
External 1
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
\end_inset
</cell>
</row>
-<row topline="true" bottomline="false" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
3
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
Timer 1
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
\end_inset
</cell>
</row>
-<row topline="true" bottomline="true" newpage="false">
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
4
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
Serial
\end_inset
</cell>
-<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
Critical Functions
\layout Standard
+
+\shape italic
+<TODO: this isn't implemented at all!>
+\shape default
+
+\newline
+
+\newline
A special keyword may be associated with a function declaring it as
\emph on
critical
\newline
While there is nothing preventing you from writing C code inside a _naked
function, there are many ways to shoot yourself in the foot doing this,
- and is is recommended that you stick to inline assembler.
+ and it is recommended that you stick to inline assembler.
\layout Subsection
Functions using private banks
non-interrupt
\emph default
function (but may occasionally be useful anyway
-\begin_float footnote
+\begin_inset Foot
+collapsed true
+
\layout Standard
possible exception: if a function is called ONLY from 'interrupt' functions
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_float
+\end_inset
+
).
\newline
be placed in a separate line (as the example shows).
When the
\emph on
---peep-asm
+---peep-asm
\emph default
command line option is used, the inline assembler code will be passed through
the peephole optimizer.
labels defines in inline assembly CANNOT be accessed by C statements.
\layout Subsection
-int(16 bit) and long (32 bit) Support
+int (16 bit) and long (32 bit) Support
\layout Standard
For signed & unsigned int (16 bit) and long (32 bit) variables, division,
If this is unavoidable then the above routines will need to be compiled
with the
\emph on
---stack-auto
+---stack-auto
\emph default
option, after which the source program will have to be compiled with
\emph on
---int-long-rent
+---int-long-rent
\emph default
option.
\layout Subsection
\newline
Like the
\emph on
---model-large
+---model-large
\emph default
option, variables will by default be placed into the XDATA segment.
\newline
Segments may be placed anywhere in the 4 meg address space using the usual
- --*-loc options.
+ ---*-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.
SDCC_STACK_AUTO - this symbol is defined when
\emph on
---stack-auto
+---stack-auto
\emph default
option is used.
\layout Itemize
SDCC_MODEL_SMALL - when
\emph on
---model-small
+---model-small
\emph default
is used.
\layout Itemize
SDCC_MODEL_LARGE - when
\emph on
---model-large
+---model-large
\emph default
is used.
\layout Itemize
SDCC_USE_XSTACK - when
\emph on
---xstack
+---xstack
\emph default
option is used.
\layout Itemize
The compiler will generate a warning message when it is forced to allocate
extra space either on the stack or data space.
If this extra space allocation is undesirable then induction optimization
- can be eliminated either for the entire source file (with --noinduction
+ can be eliminated either for the entire source file (with ---noinduction
option) or for a given function only using #pragma\SpecialChar ~
NOINDUCTION.
\newline
\layout Itemize
There are NO switch statements in the loop.
-\layout Standard
-
-Note djnz instruction can be used for 8-bit values
-\emph on
-only
-\emph default
-, therefore it is advantageous to declare loop control symbols as
-\emph on
-char
-\emph default
-.
- Ofcourse this may not be possible on all situations.
\layout Subsubsection
Algebraic Simplifications
A default set of rules are compiled into the compiler, additional rules
may be added with the
\emph on
---peep-file <filename>
+---peep-file <filename>
\emph default
option.
The rule language is best illustrated with examples.
\newline
Other special case optimizations may be added by the user (via
\emph on
---peep-file option
+---peep-file option
\emph default
).
E.g.
the rules again from the top, this option for a rule is expensive (performance)
, it is intended to be used in situations where a transformation will trigger
the same rule again.
- A good example of this the following rule:
+ An example of this (not a good one, it has side effects) is the following
+ rule:
\newline
\newline
have some better means.
If you are looking at this file, you will also see the default rules that
are compiled into the compiler, you can add your own rules in the default
- set there if you get tired of specifying the --peep-file option.
+ set there if you get tired of specifying the ---peep-file option.
\layout Subsection
Pragmas
none.
\layout Itemize
+NOIV - Do not generate interrupt vector table 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).
+\layout Itemize
+
CALLEE-SAVES function1[,function2[,function3...]] - The compiler by default
uses a caller saves convention for register saving across function calls,
however this can cause unneccessary register pushing & popping when calling
reduce code & improve run time performance of the generated code.
In future the compiler (with interprocedural analysis) will be able to
determine the appropriate scheme to use for each function call.
- If --callee-saves command line option is used, the function names specified
+ If ---callee-saves command line option is used, the function names specified
in #pragma\SpecialChar ~
CALLEE-SAVES is appended to the list of functions specified inthe
command line.
<pending: this is messy and incomplete>
\emph default
Library Routines
-\layout Standard
+\layout Enumerate
+
+Compiler support routines (_gptrget, _mulint etc)
+\layout Enumerate
+
+Stdclib functions (puts, printf, strcat etc)
+\layout Enumerate
+
+Math functions (sin, pow, sqrt etc)
+\layout Subsection
+
+Interfacing with Assembly Routines
+\layout Subsubsection
-The following library routines are provided for your convenience.
+Global Registers used for Parameter Passing
\layout Standard
-stdio.h - Contains the following functions printf & sprintf these routines
- are developed by Martijn van Balen <balen@natlab.research.philips.com>.
+The compiler always uses the global registers
+\emph on
+DPL,DPH,B
+\emph default
+and
+\emph on
+ ACC
+\emph default
+ to pass the first parameter to a routine.
+ The second parameter onwards is either allocated on the stack (for reentrant
+ routines or if ---stack-auto is used) or in the internal / external ram
+ (depending on the memory model).
-\layout Standard
+\layout Subsubsection
-%[flags][width][b|B|l|L]type
+Assembler Routine(non-reentrant)
\layout Standard
+In the following example the function cfunc calls an assembler routine asm_func,
+ which takes two parameters.
+\newline
+
+\newline
+
+\family typewriter
+extern int asm_func(unsigned char, unsigned char);
+\newline
+
+\newline
+int c_func (unsigned char i, unsigned char j)
+\newline
+{
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+return asm_func(i,j);
+\newline
+}
+\newline
+
+\newline
+int main()
+\newline
+{
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- flags: -\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- left justify output in specified field width
+return c_func(10,9);
+\newline
+}
+\newline
+
+\newline
+
+\family default
+The corresponding assembler function is:
+\newline
+
+\newline
+
+\family typewriter
+.globl _asm_func_PARM_2
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+.globl _asm_func
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- +\SpecialChar ~
+.area OSEG
+\newline
+_asm_func_PARM_2:
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- prefix output with +/- sign if output is signed type
-\newline
\SpecialChar ~
\SpecialChar ~
+.ds 1
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+.area CSEG
+\newline
+_asm_func:
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- space\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- prefix output with a blank if it's a signed positive value
+mov a,dpl
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
- width:\SpecialChar ~
+add a,_asm_func_PARM_2
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- specifies minimum number of characters outputted for numbers
+mov dpl,a
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov dpl,#0x00
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ret
+\newline
+
+\newline
+
+\family default
+Note here that the return values are placed in 'dpl' - One byte return value,
+ 'dpl' LSB & 'dph' MSB for two byte values.
+ 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
+b' & 'acc' for four byte values.
+\layout Standard
+
+The parameter naming convention is _<function_name>_PARM_<n>, where n is
+ the parameter number starting from 1, and counting from the left.
+ The first parameter is passed in
+\begin_inset Quotes eld
+\end_inset
+
+dpl
+\begin_inset Quotes erd
+\end_inset
+
+ for One bye parameter,
+\begin_inset Quotes eld
+\end_inset
+
+dptr
+\begin_inset Quotes erd
+\end_inset
+
+ if two bytes,
+\begin_inset Quotes eld
+\end_inset
+
+b,dptr
+\begin_inset Quotes erd
+\end_inset
+
+ for three bytes and
+\begin_inset Quotes eld
+\end_inset
+
+acc,b,dptr
+\begin_inset Quotes erd
+\end_inset
+
+ for four bytes, the varible name for the second parameter will be _<function_na
+me>_PARM_2.
+\newline
+
+\newline
+Assemble the assembler routine with the following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+asx8051 -losg asmfunc.asm
+\newline
+
+\newline
+
+\family default
+\series default
+Then compile and link the assembler routine to the C source file with the
+ following command:
+\newline
+
+\newline
+
+\family sans
+\series bold
+sdcc cfunc.c asmfunc.rel
+\layout Subsubsection
+
+Assembler Routine(reentrant)
+\layout Standard
+
+In this case the second parameter onwards will be passed on the stack, the
+ parameters are pushed from right to left i.e.
+ after the call the left most parameter will be on the top of the stack.
+ Here is an example:
+\newline
+
+\newline
+
+\family typewriter
+extern int asm_func(unsigned char, unsigned char);
+\newline
+
+\newline
+int c_func (unsigned char i, unsigned char j) reentrant
+\newline
+{
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+return asm_func(i,j);
+\newline
+}
+\newline
+
+\newline
+int main()
+\newline
+{
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
- or strings.
-
+return c_func(10,9);
+\newline
+}
+\newline
+
+\family default
+
+\newline
+The corresponding assembler routine is:
+\newline
+
+\newline
+
+\family typewriter
+.globl _asm_func
+\newline
+_asm_func:
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+push _bp
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov _bp,sp
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov r2,dpl
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov a,_bp
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+clr c
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
- - For numbers, spaces are added on the left when needed.
-
+add a,#0xfd
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov r0,a
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+add a,#0xfc
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov r1,a
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov a,@r0
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+add a,r2
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- If width starts with a zero character, zeroes and used
+mov dpl,a
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov dph,#0x00
+\newline
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mov sp,_bp
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+pop _bp
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ret
+\newline
+
+\newline
+
+\family default
+The compiling and linking procedure remains the same, however note the extra
+ entry & exit linkage required for the assembler code, _bp is the stack
+ frame pointer and is used to compute the offset into the stack for parameters
+ and local variables.
+\layout Subsection
+
+External Stack
+\layout Standard
+
+The external stack is located at the start of the external ram segment,
+ and is 256 bytes in size.
+ When ---xstack option is used to compile the program, the parameters and
+ local variables of all reentrant functions are allocated in this area.
+ This option is provided for programs with large stack space requirements.
+ When used with the ---stack-auto option, all parameters and local variables
+ are allocated on the external stack (note support libraries will need to
+ be recompiled with the same options).
+\layout Standard
+
+The compiler outputs the higher order address byte of the external ram segment
+ into PORT P2, therefore when using the External Stack option, this port
+ MAY NOT be used by the application program.
+\layout Subsection
+
+ANSI-Compliance
+\layout Standard
+
+Deviations from the compliancy.
+\layout Itemize
+
+functions are not always reentrant.
+\layout Itemize
+
+structures cannot be assigned values directly, cannot be passed as function
+ parameters or assigned to each other and cannot be a return value from
+ a function, e.g.:
+\family typewriter
+
+\newline
+
+\newline
+struct s { ...
+ };
+\newline
+struct s s1, s2;
+\newline
+foo()
+\newline
+{
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+...
+
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */
+\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- instead of spaces.
+...
\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- - For strings, spaces are are added on the left or right (when
+}
\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- flag '-' is used) when needed.
-
+struct s foo1 (struct s parms) /* is invalid in SDCC although allowed in
+ ANSI */
\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-
+{
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- b/B:\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- byte argument (used by d, u, o, x, X)
+struct s rets;
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- l/L:\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- long argument (used by d, u, o, x, X)
+...
+
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- type:\SpecialChar ~
- d\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- decimal number
+return rets;/* is invalid in SDCC although allowed in ANSI */
\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- u\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- unsigned decimal number
+}
+\layout Itemize
+
+'long long' (64 bit integers) not supported.
+\layout Itemize
+
+'double' precision floating point not supported.
+\layout Itemize
+
+No support for setjmp and longjmp (for now).
+\layout Itemize
+
+Old K&R style function declarations are NOT allowed.
\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- o\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- unsigned octal number
+
+\family typewriter
+
\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- x\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- unsigned hexadecimal number (0-9, a-f)
+foo(i,j) /* this old style of function declarations */
\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- X\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- unsigned hexadecimal number (0-9, A-F)
+int i,j; /* are valid in ANSI but not valid in SDCC */
+\newline
+{
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- c\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- character
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- s\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- string (generic pointer)
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- p\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- generic pointer (I:data/idata, C:code, X:xdata, P:paged)
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- f\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- float (still to be implemented)
-\layout Standard
-
-Also contains a very simple version of printf (printf_small).
- This simplified version of printf supports only the following formats.
-\layout Standard
-
-format\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-output\SpecialChar ~
-type\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-argument-type
-\newline
-%d \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-decimal \SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- short/int
-\newline
-%ld\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-decimal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-long
-\newline
-%hd\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-decimal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-char
-\newline
-%x\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-hexadecimal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-short/int
-\newline
-%lx\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-hexadecimal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-long
-\newline
-%hx\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-hexadecimal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-char
-\newline
-%o\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-octal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-short/int
-\newline
-%lo\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-octal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-long
-\newline
-%ho\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-octal\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-char
-\newline
-%c\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-character\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-char
-\newline
-%s\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-character\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-_generic pointer
-\layout Standard
-
-The routine is very stack intesive, --stack-after-data parameter should
- be used when using this routine, the routine also takes about 1K of code
- space.
- It also expects an external function named putchar(char) to be present
- (this can be changed).
- When using the %s format the string / pointer should be cast to a generic
- pointer.
- eg.
-\layout Standard
-
-printf_small(
-\begin_inset Quotes eld
-\end_inset
-
-my str %s, my int %d
-\backslash
-n
-\begin_inset Quotes erd
-\end_inset
-
-,(char _generic *)mystr,myint);
-\layout Itemize
-
-stdarg.h - contains definition for the following macros to be used for variable
- parameter list, note that a function can have a variable parameter list
- if and only if it is 'reentrant'
-\begin_deeper
-\layout Standard
-
-va_list, va_start, va_arg, va_end.
-\end_deeper
-\layout Itemize
-
-setjmp.h - contains defintion for ANSI setjmp & longjmp routines.
- Note in this case setjmp & longjmp can be used between functions executing
- within the same register bank, if long jmp is executed from a function
- that is using a different register bank from the function issuing the setjmp
- function, the results may be unpredictable.
- The jump buffer requires 3 bytes of data (the stack pointer & a 16 byte
- return address), and can be placed in any address space.
-\layout Itemize
-
-stdlib.h - contains the following functions.
-\begin_deeper
-\layout Standard
-
-atoi, atol.
-\end_deeper
-\layout Itemize
-
-string.h - contains the following functions.
-\begin_deeper
-\layout Standard
-
-strcpy, strncpy, strcat, strncat, strcmp, strncmp, strchr, strrchr, strspn,
- strcspn, strpbrk, strstr, strlen, strtok, memcpy, memcmp, memset.
-\end_deeper
-\layout Itemize
-
-ctype.h - contains the following routines.
-\begin_deeper
-\layout Standard
-
-iscntrl, isdigit, isgraph, islower, isupper, isprint, ispunct, isspace,
- isxdigit, isalnum, isalpha.
-\end_deeper
-\layout Itemize
-
-malloc.h - The malloc routines are developed by Dmitry S.
- Obukhov (dso@usa.net).
- These routines will allocate memory from the external ram.
- Here is a description on how to use them (as described by the author).
-\begin_deeper
-\layout Standard
-
-//Example:
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- #define DYNAMIC_MEMORY_SIZE 0x2000
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- .....
-
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- unsigned char xdata * current_buffer;
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- .....
-
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- void main(void)
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- {
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- ...
-
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-//\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE);
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //Now it's possible to use malloc.
-
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- ...
-
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- current_buffer = malloc(0x100);
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
- //
-\end_deeper
-\layout Itemize
-
-serial.h - Serial IO routines are also developed by Dmitry S.
- Obukhov (dso@usa.net).
- These routines are interrupt driven with a 256 byte circular buffer, they
- also expect external ram to be present.
- Please see documentation in file SDCCDIR/sdcc51lib/serial.c.
- Note the header file
-\begin_inset Quotes eld
-\end_inset
-
-serial.h
-\begin_inset Quotes erd
-\end_inset
-
- MUST be included in the file containing the 'main' function.
-\layout Itemize
-
-ser.h - Alternate serial routine provided by Wolfgang Esslinger <wolfgang@WiredMi
-nds.com> these routines are more compact and faster.
- Please see documentation in file SDCCDIR/sdcc51lib/ser.c
-\layout Itemize
-
-ser_ir.h - Another alternate set of serial routines provided by Josef Wolf
- <jw@raven.inka.de>, these routines do not use the external ram.
-\layout Itemize
-
-reg51.h - contains register definitions for a standard 8051
-\layout Itemize
-
-float.h - contains min, max and other floating point related stuff.
-\layout Standard
-
-All library routines are compiled as --model-small, they are all non-reentrant,
- if you plan to use the large model or want to make these routines reentrant,
- then they will have to be recompiled with the appropriate compiler option.
-\layout Standard
-
-Have not had time to do the more involved routines like printf, will get
- to them shortly.
-\layout Subsection
-
-Interfacing with Assembly Routines
-\layout Subsubsection
-
-Global Registers used for Parameter Passing
-\layout Standard
-
-The compiler always uses the global registers
-\emph on
-DPL,DPH,B
-\emph default
-and
-\emph on
- ACC
-\emph default
- to pass the first parameter to a routine.
- The second parameter onwards is either allocated on the stack (for reentrant
- routines or if --stack-auto is used) or in the internal / external ram
- (depending on the memory model).
-
-\layout Subsubsection
-
-Assembler Routine(non-reentrant)
-\layout Standard
-
-In the following example the function cfunc calls an assembler routine asm_func,
- which takes two parameters.
-\newline
-
-\newline
-
-\family typewriter
-extern int asm_func(unsigned char, unsigned char);
-\newline
-
-\newline
-int c_func (unsigned char i, unsigned char j)
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return asm_func(i,j);
-\newline
-}
-\newline
-
-\newline
-int main()
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return c_func(10,9);
-\newline
-}
-\newline
-
-\newline
-
-\family default
-The corresponding assembler function is:
-\newline
-
-\newline
-
-\family typewriter
-.globl _asm_func_PARM_2
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.globl _asm_func
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.area OSEG
-\newline
-_asm_func_PARM_2:
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.ds 1
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-.area CSEG
-\newline
-_asm_func:
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov a,dpl
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add a,_asm_func_PARM_2
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov dpl,a
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov dpl,#0x00
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-ret
-\newline
-
-\newline
-
-\family default
-Note here that the return values are placed in 'dpl' - One byte return value,
- 'dpl' LSB & 'dph' MSB for two byte values.
- 'dpl', 'dph' and 'b' for three byte values (generic pointers) and 'dpl','dph','
-b' & 'acc' for four byte values.
-\layout Standard
-
-The parameter naming convention is _<function_name>_PARM_<n>, where n is
- the parameter number starting from 1, and counting from the left.
- The first parameter is passed in
-\begin_inset Quotes eld
-\end_inset
-
-dpl
-\begin_inset Quotes erd
-\end_inset
-
- for One bye parameter,
-\begin_inset Quotes eld
-\end_inset
-
-dptr
-\begin_inset Quotes erd
-\end_inset
-
- if two bytes,
-\begin_inset Quotes eld
-\end_inset
-
-b,dptr
-\begin_inset Quotes erd
-\end_inset
-
- for three bytes and
-\begin_inset Quotes eld
-\end_inset
-
-acc,b,dptr
-\begin_inset Quotes erd
-\end_inset
-
- for four bytes, the varible name for the second parameter will be _<function_na
-me>_PARM_2.
-\newline
-
-\newline
-Assemble the assembler routine with the following command:
-\newline
-
-\newline
-
-\family sans
-\series bold
-asx8051 -losg asmfunc.asm
-\newline
-
-\newline
-
-\family default
-\series default
-Then compile and link the assembler routine to the C source file with the
- following command:
-\newline
-
-\newline
-
-\family sans
-\series bold
-sdcc cfunc.c asmfunc.rel
-\layout Subsubsection
-
-Assembler Routine(reentrant)
-\layout Standard
-
-In this case the second parameter onwards will be passed on the stack, the
- parameters are pushed from right to left i.e.
- after the call the left most parameter will be on the top of the stack.
- Here is an example:
-\newline
-
-\newline
-
-\family typewriter
-extern int asm_func(unsigned char, unsigned char);
-\newline
-
-\newline
-int c_func (unsigned char i, unsigned char j) reentrant
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return asm_func(i,j);
-\newline
-}
-\newline
-
-\newline
-int main()
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return c_func(10,9);
-\newline
-}
-\newline
-
-\family default
-
-\newline
-The corresponding assembler routine is:
-\newline
-
-\newline
-
-\family typewriter
-.globl _asm_func
-\newline
-_asm_func:
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-push _bp
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov _bp,sp
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov r2,dpl
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov a,_bp
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-clr c
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add a,#0xfd
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov r0,a
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add a,#0xfc
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov r1,a
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov a,@r0
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-add a,r2
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov dpl,a
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov dph,#0x00
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-mov sp,_bp
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-pop _bp
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-ret
-\newline
-
-\newline
-
-\family default
-The compiling and linking procedure remains the same, however note the extra
- entry & exit linkage required for the assembler code, _bp is the stack
- frame pointer and is used to compute the offset into the stack for parameters
- and local variables.
-\layout Subsection
-
-External Stack
-\layout Standard
-
-The external stack is located at the start of the external ram segment,
- and is 256 bytes in size.
- When --xstack option is used to compile the program, the parameters and
- local variables of all reentrant functions are allocated in this area.
- This option is provided for programs with large stack space requirements.
- When used with the --stack-auto option, all parameters and local variables
- are allocated on the external stack (note support libraries will need to
- be recompiled with the same options).
-\layout Standard
-
-The compiler outputs the higher order address byte of the external ram segment
- into PORT P2, therefore when using the External Stack option, this port
- MAY NOT be used by the application program.
-\layout Subsection
-
-ANSI-Compliance
-\layout Standard
-
-Deviations from the compliancy.
-\layout Itemize
-
-functions are not always reentrant.
-\layout Itemize
-
-structures cannot be assigned values directly, cannot be passed as function
- parameters or assigned to each other and cannot be a return value from
- a function, e.g.:
-\family typewriter
-
-\newline
-
-\newline
-struct s { ...
- };
-\newline
-struct s s1, s2;
-\newline
-foo()
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
-
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
-
-\newline
-}
-\newline
-struct s foo1 (struct s parms) /* is invalid in SDCC although allowed in
- ANSI */
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-struct s rets;
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
-
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-return rets;/* is invalid in SDCC although allowed in ANSI */
-\newline
-}
-\layout Itemize
-
-'long long' (64 bit integers) not supported.
-\layout Itemize
-
-'double' precision floating point not supported.
-\layout Itemize
-
-No support for setjmp and longjmp (for now).
-\layout Itemize
-
-Old K&R style function declarations are NOT allowed.
-\newline
-
-\family typewriter
-
-\newline
-foo(i,j) /* this old style of function declarations */
-\newline
-int i,j; /* are valid in ANSI but not valid in SDCC */
-\newline
-{
-\newline
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-\SpecialChar ~
-...
-
+...
+
\newline
}
\layout Itemize
Use the smallest data type to represent your data-value.
If it is known in advance that the value is going to be less than 256 then
- use a 'char' instead of a 'short' or 'int'.
+ use an 'unsigned char' instead of a 'short' or 'int'.
\layout Itemize
Use unsigned when it is known in advance that the value is not going to
variables (induction).
\layout Itemize
-Since the compiler does not do implicit integral promotion, the programmer
- should do an explicit cast when integral promotion is required.
+Since the compiler does not always do implicit integral promotion, the programme
+r should do an explicit cast when integral promotion is required.
\layout Itemize
Reducing the size of division, multiplication & modulus operations can reduce
\newline
For the modulus operation the variable ch will be promoted to unsigned int
first then the modulus operation will be performed (this will lead to a
- call to support routine _muduint()), and the result will be casted to an
- int.
+ call to support routine _moduint()), and the result will be casted to a
+ char.
If the code is changed to
\newline
\layout Standard
The amount of stack being used is affected by the use of the "internal stack"
- to save registers before a subroutine call is made (--stack-auto will declare
- parameters and local variables on the stack) and the number of nested subroutin
-es.
+ to save registers before a subroutine call is made (---stack-auto will
+ declare parameters and local variables on the stack) and the number of
+ nested subroutines.
\layout Standard
If you detect that the stack is over writing you data, then the following
can be done.
- --xstack will cause an external stack to be used for saving registers and
- (if --stack-auto is being used) storing parameters and local variables.
+ ---xstack will cause an external stack to be used for saving registers
+ and (if ---stack-auto is being used) storing parameters and local variables.
However this will produce more code which will be slower to execute.
\layout Standard
---stack-loc will allow you specify the start of the stack, i.e.
+---stack-loc will allow you specify the start of the stack, i.e.
you could start it after any data in the general purpose area.
However this may waste the memory not used by the register banks and if
the size of the "near data" increases, it may creep into the bottom of
the stack.
\layout Standard
---stack-after-data, similar to the --stack-loc, but it automatically places
+---stack-after-data, similar to the ---stack-loc, but it automatically places
the stack after the end of the "near data".
Again this could waste any spare register space.
\layout Standard
---data-loc allows you to specify the start address of the near data.
+---data-loc allows you to specify the start address of the near data.
This could be used to move the "near data" further away from the stack
giving it more room to grow.
This will only work if no bit variables are being used and the stack can
If you find that the stack is over writing your bit variables or "near data"
then the approach which best utilised the internal memory is to position
the "near data" after the last bank of used registers or, if you use bit
- variables, after the last bit variable by using the --data-loc, e.g.
- if two register banks are being used and no bit variables, --data-loc 16,
- and use the --stack-after-data option.
+ variables, after the last bit variable by using the ---data-loc, e.g.
+ if two register banks are being used and no bit variables, ---data-loc
+ 16, and use the ---stack-after-data option.
\layout Standard
If bit variables are being used, another method would be to try and squeeze
The intermediate code generation assumes the target machine has unlimited
number of registers, and designates them with the name iTemp.
The compiler can be made to dump a human readable form of the code generated
- by using the --dumpraw option.
+ by using the ---dumpraw option.
\layout Itemize
This phase does the bulk of the standard optimizations and is also MCU independe
How the Debugger Works
\layout Standard
-When the --debug option is specified the compiler generates extra symbol
+When the ---debug option is specified the compiler generates extra symbol
information some of which are put into the the assembler source and some
are put into the .cdb file, the linker updates the .cdb file with the address
information for the symbols.
Command Line Options.
\layout Itemize
---directory=<source file directory> this option can used to specify the
+---directory=<source file directory> this option can used to specify the
directory search list.
The debugger will look into the directory list specified for source, cdb
& ihx files.
The items in the directory list must be separated by ':', e.g.
if the source files can be in the directories /home/src1 and /home/src2,
- the --directory option should be --directory=/home/src1:/home/src2.
+ the ---directory option should be ---directory=/home/src1:/home/src2.
Note there can be no spaces in the option.
\layout Itemize
\layout Standard
\SpecialChar ~
-
-\family typewriter
-
-\newline
-;; Current Listing ::
-\newline
-;;key\SpecialChar ~
+
+\family typewriter
+
+\newline
+;; Current Listing ::
+\newline
+;;key\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+binding\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+Comment
+\newline
+;;---\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+------\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+--------
+\newline
+;;
+\newline
+;; n\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ sdcdb-next-from-src\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+SDCDB next command
+\newline
+;; b\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ sdcdb-back-from-src\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+SDCDB back command
+\newline
+;; c\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdb-cont-from-src\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-binding\SpecialChar ~
+SDCDB continue command
+\newline
+;; s\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdb-step-from-src\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-Comment
+SDCDB step command
\newline
-;;---\SpecialChar ~
+;; ?\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdb-whatis-c-sexp\SpecialChar ~
\SpecialChar ~
--------\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+SDCDB ptypecommand for data at
+\newline
+;;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
--------
-\newline
-;;
-\newline
-;; n\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdb-next-from-src\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB next command
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ buffer point
\newline
-;; b\SpecialChar ~
+;; x\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdb-back-from-src\SpecialChar ~
+ sdcdbsrc-delete\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB back command
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+SDCDB Delete all breakpoints if no arg
\newline
-;; c\SpecialChar ~
+;;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdb-cont-from-src\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB continue command
-\newline
-;; s\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdb-step-from-src\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB step command
+\SpecialChar ~
+given or delete arg (C-u arg x)
\newline
-;; ?\SpecialChar ~
+;; m\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdb-whatis-c-sexp\SpecialChar ~
+ sdcdbsrc-frame\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB ptypecommand for data at
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+SDCDB Display current frame if no arg,
\newline
;;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- buffer point
+\SpecialChar ~
+given or display frame arg
\newline
-;; x\SpecialChar ~
+;;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdbsrc-delete\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB Delete all breakpoints if no arg
-\newline
-;;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+buffer point
+\newline
+;; !\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdbsrc-goto-sdcdb\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+Goto the SDCDB output buffer
+\newline
+;; p\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-given or delete arg (C-u arg x)
-\newline
-;; m\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdb-print-c-sexp\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdbsrc-frame\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+SDCDB print command for data at
+\newline
+;;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB Display current frame if no arg,
-\newline
-;;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ buffer point
+\newline
+;; g\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-given or display frame arg
-\newline
-;;\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ sdcdbsrc-goto-sdcdb\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+Goto the SDCDB output buffer
+\newline
+;; t\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+\SpecialChar ~
+ sdcdbsrc-mode\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+Toggles Sdcdbsrc mode (turns it off)
+\newline
+;;
+\newline
+;; C-c C-f\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdb-finish-from-src\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-buffer point
+SDCDB finish command
\newline
-;; !\SpecialChar ~
+;;
+\newline
+;; C-x SPC\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdb-break\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdbsrc-goto-sdcdb\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-Goto the SDCDB output buffer
+\SpecialChar ~
+Set break for line with point
\newline
-;; p\SpecialChar ~
+;; ESC t\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+ sdcdbsrc-mode\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
- sdcdb-print-c-sexp\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-SDCDB print command for data at
+Toggle Sdcdbsrc mode
\newline
-;;\SpecialChar ~
+;; ESC m\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+ sdcdbsrc-srcmode\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+\SpecialChar ~
+ Toggle list mode
+\newline
+;;
+\family default
+
+\newline
+
+\layout Section
+
+Other Processors
+\layout Subsection
+
+The Z80 and gbz80 port
+\layout Standard
+
+SDCC can target both the Zilog Z80 and the Nintendo Gameboy's Z80-like gbz80.
+ The port is incomplete - long support is incomplete (mul, div and mod are
+ unimplimented), and both float and bitfield support is missing.
+ Apart from that the code generated is correct.
+\layout Standard
+
+As always, the code is the authoritave reference - see z80/ralloc.c and z80/gen.c.
+ The stack frame is similar to that generated by the IAR Z80 compiler.
+ IX is used as the base pointer, HL is used as a temporary register, and
+ BC and DE are available for holding varibles.
+ IY is currently unusued.
+ Return values are stored in HL.
+ One bad side effect of using IX as the base pointer is that a functions
+ stack frame is limited to 127 bytes - this will be fixed in a later version.
+\layout Section
+
+Support
+\layout Standard
+
+SDCC has grown to be a large project.
+ The compiler alone (without the preprocessor, assembler and linker) is
+ about 40,000 lines of code (blank stripped).
+ The open source nature of this project is a key to its continued growth
+ and support.
+ You gain the benefit and support of many active software developers and
+ end users.
+ Is SDCC perfect? No, that's why we need your help.
+ The developers take pride in fixing reported bugs.
+ You can help by reporting the bugs and helping other SDCC users.
+ There are lots of ways to contribute, and we encourage you to take part
+ in making SDCC a great software package.
+\layout Subsection
+
+Reporting Bugs
+\layout Standard
+
+Send an email to the mailing list at 'user-sdcc@sdcc.sourceforge.net' or 'devel-sd
+cc@sdcc.sourceforge.net'.
+ Bugs will be fixed ASAP.
+ When reporting a bug, it is very useful to include a small test program
+ which reproduces the problem.
+ If you can isolate the problem by looking at the generated assembly code,
+ this can be very helpful.
+ Compiling your program with the ---dumpall option can sometimes be useful
+ in locating optimization problems.
+\layout Section
+
+The anatomy of the compiler
+\layout Standard
+
+
+\shape italic
+This is an excerpt from an atricle published in Circuit Cellar MagaZine
+ in august 2000.
+ It's a little outdated (the compiler is much more efficient now and user/devell
+oper friendly), but pretty well exposes the guts of it all.
+\shape default
+
+\newline
+
+\newline
+The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
+ It is fairly easy to retarget for other 8-bit MCU.
+ Here we take a look at some of the internals of the compiler.
+
+\layout Paragraph*
+
+Parsing
+\layout Standard
+
+Parsing the input source file and creating an AST (Annotated Syntax Tree).
+ This phase also involves propagating types (annotating each node of the
+ parse tree with type information) and semantic analysis.
+ There are some MCU specific parsing rules.
+ For example the storage classes, the extended storage classes are MCU specific
+ while there may be a xdata storage class for 8051 there is no such storage
+ class for z80 or Atmel AVR.
+ SDCC allows MCU specific storage class extensions, i.e.
+ xdata will be treated as a storage class specifier when parsing 8051 C
+ code but will be treated as a C identifier when parsing z80 or ATMEL AVR
+ C code.
+\layout Paragraph*
+
+Generating iCode
+\layout Standard
+
+Intermediate code generation.
+ In this phase the AST is broken down into three-operand form (iCode).
+ These three operand forms are represented as doubly linked lists.
+ ICode is the term given to the intermediate form generated by the compiler.
+ ICode example section shows some examples of iCode generated for some simple
+ C source functions.
+\layout Paragraph*
+
+Optimizations.
+\layout Standard
+
+Bulk of the target independent optimizations is performed in this phase.
+ The optimizations include constant propagation, common sub-expression eliminati
+on, loop invariant code movement, strength reduction of loop induction variables
+ and dead-code elimination.
+\layout Paragraph*
+
+Live range analysis
+\layout Standard
+
+During intermediate code generation phase, the compiler assumes the target
+ machine has infinite number of registers and generates a lot of temporary
+ variables.
+ The live range computation determines the lifetime of each of these compiler-ge
+nerated temporaries.
+ A picture speaks a thousand words.
+ ICode example sections show the live range annotations for each of the
+ operand.
+ It is important to note here, each iCode is assigned a number in the order
+ of its execution in the function.
+ The live ranges are computed in terms of these numbers.
+ The from number is the number of the iCode which first defines the operand
+ and the to number signifies the iCode which uses this operand last.
+\layout Paragraph*
+
+Register Allocation
+\layout Standard
+
+The register allocation determines the type and number of registers needed
+ by each operand.
+ In most MCUs only a few registers can be used for indirect addressing.
+ In case of 8051 for example the registers R0 & R1 can be used to indirectly
+ address the internal ram and DPTR to indirectly address the external ram.
+ The compiler will try to allocate the appropriate register to pointer variables
+ if it can.
+ ICode example section shows the operands annotated with the registers assigned
+ to them.
+ The compiler will try to keep operands in registers as much as possible;
+ there are several schemes the compiler uses to do achieve this.
+ When the compiler runs out of registers the compiler will check to see
+ if there are any live operands which is not used or defined in the current
+ basic block being processed, if there are any found then it will push that
+ operand and use the registers in this block, the operand will then be popped
+ at the end of the basic block.
+
+\layout Standard
+
+There are other MCU specific considerations in this phase.
+ Some MCUs have an accumulator; very short-lived operands could be assigned
+ to the accumulator instead of general-purpose register.
+\layout Paragraph*
+
+Code generation
+\layout Standard
+
+Figure II gives a table of iCode operations supported by the compiler.
+ The code generation involves translating these operations into corresponding
+ assembly code for the processor.
+ This sounds overly simple but that is the essence of code generation.
+ Some of the iCode operations are generated on a MCU specific manner for
+ example, the z80 port does not use registers to pass parameters so the
+ SEND and RECV iCode operations will not be generated, and it also does
+ not support JUMPTABLES.
+
+\newline
+
+\series bold
+\shape italic
+\color red
+<Where is Figure II ?>
+\layout Paragraph*
+
+ICode Example
+\layout Standard
+
+This section shows some details of iCode.
+ The example C code does not do anything useful; it is used as an example
+ to illustrate the intermediate code generated by the compiler.
+\newline
+
+\newline
+
+\family typewriter
+1.\SpecialChar ~
+xdata int * p;
+\newline
+2.\SpecialChar ~
+int gint;
+\newline
+3.\SpecialChar ~
+/* This function does nothing useful.
+ It is used
+\newline
+4.\SpecialChar ~
+\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+for the purpose of explaining iCode */
+\newline
+5.\SpecialChar ~
+short function (data int *x)
+\newline
+6.\SpecialChar ~
+{
+\newline
+7.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+short i=10; /* dead initialization eliminated */
+\newline
+8.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+short sum=10; /* dead initialization eliminated */
+\newline
+9.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+short mul;
+\newline
+10.\SpecialChar ~
\SpecialChar ~
+int j ;
+\newline
+11.\SpecialChar ~
\SpecialChar ~
+while (*x) *x++ = *p++;
+\newline
+12.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+sum = 0 ;
+\newline
+13.\SpecialChar ~
\SpecialChar ~
+mul = 0;
+\newline
+14.\SpecialChar ~
\SpecialChar ~
+/* compiler detects i,j to be induction variables */
+\newline
+15.\SpecialChar ~
\SpecialChar ~
+for (i = 0, j = 10 ; i < 10 ; i++, j---) {
+\newline
+16.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+sum += i;
+\newline
+17.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+mul += i * 3; /* this multiplication remains */
+\newline
+18.\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
+gint += j * 3;/* this multiplication changed to addition */
+\newline
+19.\SpecialChar ~
\SpecialChar ~
+}
+\newline
+20.\SpecialChar ~
\SpecialChar ~
+return sum+mul;
+\newline
+21.\SpecialChar ~
+}
+\newline
+
+\newline
+
+\family default
+In addition to the operands each iCode contains information about the filename
+ and line it corresponds to in the source file.
+ The first field in the listing should be interpreted as follows:
+\newline
+
+\shape italic
+\size footnotesize
+Filename(linenumber: iCode Execution sequence number : ICode hash table
+ key : loop depth of the iCode).
+\shape default
+\size default
+
+\newline
+Then follows the human readable form of the ICode operation.
+ Each operand of this triplet form can be of three basic types a) compiler
+ generated temporary b) user defined variable c) a constant value.
+ Note that local variables and parameters are replaced by compiler generated
+ temporaries.
+ Live ranges are computed only for temporaries (i.e.
+ live ranges are not computed for global variables).
+ Registers are allocated for temporaries only.
+ Operands are formatted in the following manner:
+\newline
+
+\shape italic
+\size footnotesize
+Operand Name [lr live-from : live-to ] { type information } [ registers
+ allocated ].
+\shape default
+\size default
+
+\newline
+As mentioned earlier the live ranges are computed in terms of the execution
+ sequence number of the iCodes, for example
+\newline
+the iTemp0 is live from (i.e.
+ first defined in iCode with execution sequence number 3, and is last used
+ in the iCode with sequence number 5).
+ For induction variables such as iTemp21 the live range computation extends
+ the lifetime from the start to the end of the loop.
+\newline
+The register allocator used the live range information to allocate registers,
+ the same registers may be used for different temporaries if their live
+ ranges do not overlap, for example r0 is allocated to both iTemp6 and to
+ iTemp17 since their live ranges do not overlap.
+ In addition the allocator also takes into consideration the type and usage
+ of a temporary, for example itemp6 is a pointer to near space and is used
+ as to fetch data from (i.e.
+ used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer registers (r0).
+ Some short lived temporaries are allocated to special registers which have
+ meaning to the code generator e.g.
+ iTemp13 is allocated to a pseudo register CC which tells the back end that
+ the temporary is used only for a conditional jump the code generation makes
+ use of this information to optimize a compare and jump ICode.
+\newline
+There are several loop optimizations performed by the compiler.
+ It can detect induction variables iTemp21(i) and iTemp23(j).
+ Also note the compiler does selective strength reduction, i.e.
+ the multiplication of an induction variable in line 18 (gint = j * 3) is
+ changed to addition, a new temporary iTemp17 is allocated and assigned
+ a initial value, a constant 3 is then added for each iteration of the loop.
+ The compiler does not change the multiplication in line 17 however since
+ the processor does support an 8 * 8 bit multiplication.
+\newline
+Note the dead code elimination optimization eliminated the dead assignments
+ in line 7 & 8 to I and sum respectively.
+\newline
+
+\layout Standard
+
+
+\size footnotesize
+Sample.c (5:1:0:0) _entry($9) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:4:53:0) preHeaderLbl0($11) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
+ * int}[r2]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:6:5:1) _whilecontinue_0($1) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
+ int}[r0]]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
+ * int}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
+ {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
+ * int}[DPTR]]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
+}[r2 r3]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
+ * int}[r0] + 0x2 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:16:20:1) goto _whilecontinue_0($1)
+\layout Standard
+
+
+\size footnotesize
+Sample.c(11:17:21:0)_whilebreak_0($3) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:20:54:0)preHeaderLbl1($13) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:24:26:1)_forcond_0($4) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
+ < 0xa {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
+\layout Standard
+
+
+\size footnotesize
+Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
+ + ITemp21 [lr21:38]{short}[r4]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
+ * 0x3 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
+ + iTemp15 [lr29:30]{short}[r1]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
+ r0]- 0x3 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
+int}[r7 r0]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
+ + 0x1 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
+ r6]- 0x1 {short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(19:38:47:1) goto _forcond_0($4)
+\layout Standard
+
+
+\size footnotesize
+Sample.c(19:39:48:0)_forbreak_0($7) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
+ + ITemp11 [lr19:40]{short}[r3]
+\layout Standard
+
+
+\size footnotesize
+Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
+\layout Standard
+
+
+\size footnotesize
+Sample.c(20:42:51:0)_return($8) :
+\layout Standard
+
+
+\size footnotesize
+Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
+\size default
+
+\newline
+
+\newline
+Finally the code generated for this function:
+\newline
+
+\layout Standard
+
+
+\size footnotesize
+.area DSEG (DATA)
+\layout Standard
+
+
+\size footnotesize
+_p::
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+.ds 2
+\layout Standard
+
+
+\size footnotesize
+_gint::
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+.ds 2
+\layout Standard
+
+
+\size footnotesize
+; sample.c 5
+\layout Standard
+
+
+\size footnotesize
+; ----------------------------------------------
+\layout Standard
+
+
+\size footnotesize
+; function function
+\layout Standard
+
+
+\size footnotesize
+; ----------------------------------------------
+\layout Standard
+
+
+\size footnotesize
+_function:
+\layout Standard
+
+
+\size footnotesize
+; iTemp0 [lr3:5]{_near * int}[r2] = recv
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r2,dpl
+\layout Standard
+
+
+\size footnotesize
+; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
- buffer point
-\newline
-;; g\SpecialChar ~
+mov ar0,r2
+\layout Standard
+
+
+\size footnotesize
+;_whilecontinue_0($1) :
+\layout Standard
+
+
+\size footnotesize
+00101$:
+\layout Standard
+
+
+\size footnotesize
+; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
+\layout Standard
+
+
+\size footnotesize
+; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov ar2,@r0
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+inc r0
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov ar3,@r0
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+dec r0
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r2
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+orl a,r3
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
- sdcdbsrc-goto-sdcdb\SpecialChar ~
\SpecialChar ~
+jz 00103$
+\layout Standard
+
+
+\size footnotesize
+00114$:
+\layout Standard
+
+
+\size footnotesize
+; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov dpl,_p
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov dph,(_p + 1)
+\layout Standard
+
+
+\size footnotesize
+; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,#0x02
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
-Goto the SDCDB output buffer
-\newline
-;; t\SpecialChar ~
+add a,_p
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov _p,a
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+clr a
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+addc a,(_p + 1)
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov (_p + 1),a
+\layout Standard
+
+
+\size footnotesize
+; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+movx a,@dptr
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r2,a
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
- sdcdbsrc-mode\SpecialChar ~
\SpecialChar ~
+inc dptr
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+movx a,@dptr
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r3,a
+\layout Standard
+
+
+\size footnotesize
+; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov @r0,ar2
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+inc r0
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov @r0,ar3
+\layout Standard
+
+
+\size footnotesize
+; iTemp6 [lr5:16]{_near * int}[r0] =
+\layout Standard
+
+
+\size footnotesize
+; iTemp6 [lr5:16]{_near * int}[r0] +
+\layout Standard
+
+
+\size footnotesize
+; 0x2 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+inc r0
+\layout Standard
+
+
+\size footnotesize
+; goto _whilecontinue_0($1)
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
-Toggles Sdcdbsrc mode (turns it off)
-\newline
-;;
-\newline
-;; C-c C-f\SpecialChar ~
+sjmp 00101$
+\layout Standard
+
+
+\size footnotesize
+; _whilebreak_0($3) :
+\layout Standard
+
+
+\size footnotesize
+00103$:
+\layout Standard
+
+
+\size footnotesize
+; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r2,#0x00
+\layout Standard
+
+
+\size footnotesize
+; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r3,#0x00
+\layout Standard
+
+
+\size footnotesize
+; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r4,#0x00
+\layout Standard
+
+
+\size footnotesize
+; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
- sdcdb-finish-from-src\SpecialChar ~
\SpecialChar ~
+mov r5,#0x0A
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r6,#0x00
+\layout Standard
+
+
+\size footnotesize
+; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r7,#0x1E
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
-SDCDB finish command
-\newline
-;;
-\newline
-;; C-x SPC\SpecialChar ~
+mov r0,#0x00
+\layout Standard
+
+
+\size footnotesize
+; _forcond_0($4) :
+\layout Standard
+
+
+\size footnotesize
+00104$:
+\layout Standard
+
+
+\size footnotesize
+; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
+\layout Standard
+
+
+\size footnotesize
+; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+clr c
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r4
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+xrl a,#0x80
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
- sdcdb-break\SpecialChar ~
\SpecialChar ~
+subb a,#0x8a
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+jnc 00107$
+\layout Standard
+
+
+\size footnotesize
+00115$:
+\layout Standard
+
+
+\size footnotesize
+; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] +
+\layout Standard
+
+
+\size footnotesize
+; iTemp21 [lr21:38]{short}[r4]
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r4
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+add a,r2
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r2,a
+\layout Standard
+
+
+\size footnotesize
+; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov b,#0x03
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r4
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mul ab
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
-Set break for line with point
-\newline
-;; ESC t\SpecialChar ~
+mov r1,a
+\layout Standard
+
+
+\size footnotesize
+; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] +
+\layout Standard
+
+
+\size footnotesize
+; iTemp15 [lr29:30]{short}[r1]
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+add a,r3
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r3,a
+\layout Standard
+
+
+\size footnotesize
+; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r7
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+add a,#0xfd
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
- sdcdbsrc-mode\SpecialChar ~
\SpecialChar ~
+mov r7,a
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r0
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+addc a,#0xff
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov r0,a
+\layout Standard
+
+
+\size footnotesize
+; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r7
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+add a,_gint
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov _gint,a
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
-Toggle Sdcdbsrc mode
-\newline
-;; ESC m\SpecialChar ~
+mov a,r0
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+addc a,(_gint + 1)
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov (_gint + 1),a
+\layout Standard
+
+
+\size footnotesize
+; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+inc r4
+\layout Standard
+
+
+\size footnotesize
+; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+dec r5
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
- sdcdbsrc-srcmode\SpecialChar ~
\SpecialChar ~
+cjne r5,#0xff,00104$
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+dec r6
+\layout Standard
+
+
+\size footnotesize
+; goto _forcond_0($4)
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+sjmp 00104$
+\layout Standard
+
+
+\size footnotesize
+; _forbreak_0($7) :
+\layout Standard
+
+
+\size footnotesize
+00107$:
+\layout Standard
+
+
+\size footnotesize
+; ret iTemp24 [lr40:41]{short}
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+mov a,r3
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
+add a,r2
+\layout Standard
+
+
+\size footnotesize
\SpecialChar ~
\SpecialChar ~
- Toggle list mode
-\newline
-;;
-\family default
+mov dpl,a
+\layout Standard
-\newline
-\layout Section
+\size footnotesize
+; _return($8) :
+\layout Standard
-Other Processors
-\layout Subsection
-The Z80 and gbz80 port
+\size footnotesize
+00108$:
\layout Standard
-SDCC can target both the Zilog Z80 and the Nintendo Gameboy's Z80-like gbz80.
- The port is incomplete - long support is incomplete (mul, div and mod are
- unimplimented), and both float and bitfield support is missing.
- Apart from that the code generated is correct.
-\layout Standard
-As always, the code is the authoritave reference - see z80/ralloc.c and z80/gen.c.
- The stack frame is similar to that generated by the IAR Z80 compiler.
- IX is used as the base pointer, HL is used as a temporary register, and
- BC and DE are available for holding varibles.
- IY is currently unusued.
- Return values are stored in HL.
- One bad side effect of using IX as the base pointer is that a functions
- stack frame is limited to 127 bytes - this will be fixed in a later version.
+\size footnotesize
+\SpecialChar ~
+\SpecialChar ~
+ret
+\size default
+
+\newline
+
\layout Section
-Support
+Acknowledgments
\layout Standard
-SDCC has grown to be a large project.
- The compiler alone (without the preprocessor, assembler and linker) is
- about 40,000 lines of code (blank stripped).
- The open source nature of this project is a key to its continued growth
- and support.
- You gain the benefit and support of many active software developers and
- end users.
- Is SDCC perfect? No, that's why we need your help.
- The developers take pride in fixing reported bugs.
- You can help by reporting the bugs and helping other SDCC users.
- There are lots of ways to contribute, and we encourage you to take part
- in making SDCC a great software package.
-\layout Subsection
-Reporting Bugs
-\layout Standard
+\begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
-Send an email to the mailing list at 'user-sdcc@sdcc.sourceforge.net' or 'devel-sd
-cc@sdcc.sourceforge.net'.
- Bugs will be fixed ASAP.
- When reporting a bug, it is very useful to include a small test program
- which reproduces the problem.
- If you can isolate the problem by looking at the generated assembly code,
- this can be very helpful.
- Compiling your program with the --dumpall option can sometimes be useful
- in locating optimization problems.
-\layout Section
+\end_inset
-Acknowledgments
-\layout Standard
-Sandeep Dutta (sandeep.dutta@usa.net) - SDCC, the compiler, MCS51 code generator,
- Debugger, AVR port
-\newline
-Alan Baldwin (baldwin@shop-pdp.kent.edu) - Initial version of ASXXXX & ASLINK.
-
-\newline
-John Hartman (jhartman@compuserve.com) - Porting ASXXX & ASLINK for 8051
-\newline
-Dmitry S.
- Obukhov (dso@usa.net) - malloc & serial i/o routines.
-
-\newline
-Daniel Drotos (drdani@mazsola.iit.uni-miskolc.hu) - for his Freeware simulator
-\newline
-Malini Dutta(malini_dutta@hotmail.com) - my wife for her patience and support.
-\newline
-Unknown - for the GNU C - preprocessor.
-\newline
-Michael Hope - The Z80 and Z80GB port, 186 development
-\newline
-Kevin Vigor - The DS390 port.
-\newline
-Johan Knol - Lots of fixes and enhancements, DS390/TINI libs.
-\newline
-Scott Datallo - The PIC port.
\newline
\newline