+2007-05-29 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * doc/sdccman.lyx: documented initialization and allocation of absolute
+ variables, bit parameter passing, the need for function pointers to be
+ reentrant and alpha quality support of inline and retrict
+
2007-05-26 Borut Razem <borut.razem AT siol.net>
* support/regression/tests/bug1057979.c, support/regression/tests/malloc.c,
-#LyX 1.4.4 created this file. For more info see http://www.lyx.org/
+#LyX 1.4.3 created this file. For more info see http://www.lyx.org/
\lyxformat 245
\begin_document
\begin_header
\end_inset
) are good places to look for such overlaps.
- Variables with an absolute address are
-\emph on
-not
-\begin_inset Marginal
-status collapsed
+\end_layout
\begin_layout Standard
-
-\series bold
-\InsetSpace ~
-!
-\end_layout
+If however you provide an initializer
+\begin_inset LatexCommand \index{Variable initialization}
\end_inset
+ actual memory allocation will take place and overlaps will be detected
+ by the linker.
+ E.g.:
+\end_layout
-\emph default
- initialized
-\begin_inset LatexCommand \index{Variable initialization}
+\begin_layout Verse
+\family typewriter
+__code __at (0x7ff0) char Id[5] =
+\begin_inset Quotes sld
\end_inset
-.
+SDCC
+\begin_inset Quotes srd
+\end_inset
+
+;
+\end_layout
+
+\begin_layout Standard
+In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
+ in code memory.
\end_layout
\begin_layout Standard
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 medium or large model).
This in fact makes them similar to
\emph on
static
\InsetSpace ~
\InsetSpace ~
\InsetSpace ~
-0003$: ;label (can be referenced by inline assembler only)
-
+0003$: ;label (can be referenced by inline assembler only)
\newline
\InsetSpace ~
\InsetSpace ~
\emph default
- to pass the first parameter to a function, and also to pass the return
- value
+ to pass the first (non-bit) parameter to a function, and also to pass the
+ return value
\begin_inset LatexCommand \index{return value}
\end_inset
\end_inset
-stack-auto is used) or in data/xdata memory (depending on the memory model).
-
+\end_layout
+
+\begin_layout Standard
+Bit parameters are passed in a virtual register called 'bits' in bit-addressable
+ space for reentrant functions or allocated directly in bit memory otherwise.
+\end_layout
+
+\begin_layout Standard
+Functions (with two or more parameters or bit parameters) that are called
+ through function pointers
+\begin_inset LatexCommand \index{function pointers}
+
+\end_inset
+
+ must therefor be reentrant so the compiler knows how to pass the parameters.
\end_layout
\begin_layout Subsection
\family typewriter
foo(i,j) /* this old style of function declarations */
\newline
-int i,j; /* are valid
+int i,j; /* is valid
in ANSI but not valid in SDCC */
\newline
{
\end_deeper
\begin_layout Itemize
-Most enhancements in C99 are not supported, f.e.:
+Most enhancements in C99 are not supported, e.g.:
+\end_layout
+
+\begin_deeper
+\begin_layout Verse
+
+\family typewriter
+for (
+\series bold
+int
+\series default
+ i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+But some have been added recently in SDCC 2.7.0.
+ They must be considered alpha quality however.
\end_layout
\begin_deeper
\series default
- int increment (int a) { return a+1; } /* is invalid in SDCC although allowed
- in C99.
- An empty define
-\emph on
-#define inline
-\emph default
- can be used as a work around */
-\newline
-
+ int increment (int a) { return a+1; } /* inlines the increment without
+ function call overhead */
\newline
-for (
+int *
\series bold
-int
+restrict
+\begin_inset LatexCommand \index{inline (not supported)}
+
+\end_inset
+
+
\series default
- i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
+ p; /* accepted but ignored */
\end_layout
\end_deeper