\size normal
-SDCC 2.5.5
+SDCC 2.5.4
\size footnotesize
\newline
\newline
SDCC also comes with a companion source level debugger SDCDB, the debugger
currently uses ucSim a freeware simulator for 8051 and other micro-controllers.
+ SDCDB and ucSim are currently not available on Win32 platforms.
\newline
\layout Itemize
s51 - The ucSim 8051 simulator.
+ Not available on Win32 platforms.
\layout Itemize
sdcdb - The source debugger.
+ Not available on Win32 platforms.
\layout Itemize
packihx - A tool to pack (compress) Intel hex files.
.
It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
XA51 family.
+ S51 is currently not available on Win32 platfors.
\layout Subsection
sdcdb - Source Level Debugger
\end_inset
, but can be easily changed to use other simulators.
-
+ Sdcdb is currently not available on Win32 platfors.
\layout Chapter
Using SDCC
\labelwidthstring 00.00.0000
+\series bold
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-xstack-loc
+\series default
+
+\begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
+
+\end_inset
+
+\SpecialChar ~
+<Value> By default the external stack
+\begin_inset LatexCommand \index{xstack}
+
+\end_inset
+
+ is placed after the pdata segment.
+ Using this option the xstack can be placed anywhere in the external memory
+ space of the 8051.
+ The value entered can be in Hexadecimal or Decimal format, e.g.
+ -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-xstack-loc 0x8000 or -
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-stack-loc 32768.
+ The provided value should not overlap any other memory areas such as the
+ pdata or xdata segment and with enough space for the current application.
+\layout List
+\labelwidthstring 00.00.0000
+
+
\series bold
-
\begin_inset ERT
\labelwidthstring 00.00.0000
+\series bold
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-model-medium
+\begin_inset LatexCommand \index{-\/-model-medium}
+
+\end_inset
+
+
+\series default
+ Generate code for Medium model programs, see section Memory Models for
+ more details.
+ If this option is used all source files in the project have to be compiled
+ with this option.
+ It must also be used when invoking the linker.
+\layout List
+\labelwidthstring 00.00.0000
+
+
\series bold
-
\begin_inset ERT
\end_inset
).
+ This is the
+\series bold
+default
+\series default
+ storage class for the Medium Memory model, e.g.:
\layout Verse
if it is not reentrant.
Furthermore nonreentrant functions should not be called from the main program
while the interrupt service routine might be active.
-
+ They also must not be called from low priority interrupt service routines
+ while a high priority interrupt service routine might be active. You could use
+ semaphores or make the function
+\emph on
+ critical
+\emph default
+ if all parameters are passed in registers.
\newline
\newline
\layout Subsubsection
-Small and Large
+Small, Medium and Large
\layout Standard
-SDCC allows two memory models for MCS51 code,
+SDCC allows three memory models for MCS51 code,
\shape slanted
-small
+small, medium
\shape default
and
\shape slanted
never
\emph default
be combined together or the results would be unpredictable.
- The library routines supplied with the compiler are compiled as both small
- and large.
- The compiled library modules are contained in separate directories as small
- and large so that you can link to either set.
-
+ The library routines supplied with the compiler are compiled as small,
+ medium and large.
+ The compiled library modules are contained in separate directories as small,
+ medium and large so that you can link to the appropriate set.
\layout Standard
-When the large model is used all variables declared without a storage class
- will be allocated into the external ram, this includes all parameters and
- local variables (for non-reentrant
+When the medium or large model is used all variables declared without a
+ storage class will be allocated into the external ram, this includes all
+ parameters and local variables (for non-reentrant
\begin_inset LatexCommand \index{reentrant}
\end_inset
\begin_inset Tabular
-<lyxtabular version="3" rows="10" columns="2">
+<lyxtabular version="3" rows="11" columns="2">
<features>
<column alignment="center" valignment="top" leftline="true" width="0">
<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
\layout Standard
+SDCC_MODEL_MEDIUM
+\begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
+
+\end_inset
+
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+when
+\emph on
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash
+/
+\end_inset
+
+-model-medium
+\emph default
+ is used
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
SDCC_MODEL_LARGE
\begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
specified during configuration.
The debugger allows you debug BOTH at the C source and at the ASM source
level.
- Sdcdb is available on Unix platforms only.
+ Sdcdb is currently not available on Win32 platforms.
\layout Section
Compiling for Debugging
\emph default
be recognized.
They are standard C expressions, so I heartily recommend these be the only
- way to get the highest order bit, (it is portable).
+ way to get the higher order byte/word, (it is portable).
Of course it will be recognized even if it is embedded in other expressions,
e.g.:
\layout Verse
\end_deeper
\layout Itemize
+initialization of structure arrays must be fully braced.
+\begin_deeper
+\layout Verse
+
+
+\family typewriter
+struct s { char x } a[] = {1, 2}; /* invalid in SDCC */
+\newline
+struct s { char x } a[] = {{1}, {2}}; /* OK */
+\end_deeper
+\layout Itemize
+
'long long
\begin_inset LatexCommand \index{long long (not supported)}
not supported.
\layout Itemize
-No support for setjmp
-\begin_inset LatexCommand \index{setjmp (not supported)}
-
-\end_inset
-
- and longjmp
-\begin_inset LatexCommand \index{longjmp (not supported)}
-
-\end_inset
-
- (for now).
-\layout Itemize
-
Old K&R style
\begin_inset LatexCommand \index{K\&R style}
\end_deeper
\layout Itemize
+Most enhancements in C99 are not supported, f.e.:
+\begin_deeper
+\layout Verse
+
+
+\family typewriter
+\series bold
+inline
+\series default
+ int increment (int a) { return a+1; } /* is invalid in SDCC although allowed
+ in C99 */
+\newline
+for (
+\series bold
+int
+\series default
+ i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
+\end_deeper
+\layout Itemize
+
Certain words that are valid identifiers in the standard may be reserved
words in SDCC unless the
\series bold