\size normal
-SDCC 2.5.6
+SDCC 2.6.1
\size footnotesize
\newline
\SpecialChar ~
b = ~b; /* equivalent to b=1 instead of toggling b */
\begin_inset Marginal
-collapsed true
+collapsed false
\layout Standard
\series bold
+\SpecialChar ~
!
\end_inset
\family typewriter
-bit test_bit;
+__bit test_bit;
\layout Standard
Writing 1 to this variable generates the assembly code:
\series bold
+\SpecialChar ~
!
\end_inset
\series bold
+\SpecialChar ~
!
\end_inset
\family typewriter
-bit
+__bit
\begin_inset LatexCommand \index{bit}
\end_inset
\end_inset
- bit MOSI;\SpecialChar ~
+ __bit MOSI;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* master out, slave in */
\newline
-extern volatile bit MISO;\SpecialChar ~
+extern volatile __bit MISO;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* master in, slave out */
\newline
-extern volatile bit MCLK;\SpecialChar ~
+extern volatile __bit MCLK;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\family typewriter
-bit __at
+__bit __at
\begin_inset LatexCommand \index{at}
\end_inset
\SpecialChar ~
/* I/O port 0, bit 0 */
\newline
-bit __at (0x81) MISO;\SpecialChar ~
+__bit __at (0x81) MISO;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 0, bit 1 */
\newline
-bit __at (0x82) MCLK;\SpecialChar ~
+__bit __at (0x82) MCLK;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\family typewriter
-bit __at (0x83) MOSI;\SpecialChar ~
+__bit __at (0x83) MOSI;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 0, bit 3 */
\newline
-bit __at (0x91) MISO;\SpecialChar ~
+__bit __at (0x91) MISO;\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
/* I/O port 1, bit 1 */
\newline
-bit
+__bit
\begin_inset LatexCommand \index{bit}
\end_inset
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-xdata unsigned char i;
+__xdata unsigned char i;
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-bit bvar;
+__bit bvar;
\newline
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
\SpecialChar ~
-data __at
+__data __at
\begin_inset LatexCommand \index{at}
\end_inset
\family typewriter
\size footnotesize
-unsigned char far
+unsigned char __far
\begin_inset LatexCommand \index{far (storage class)}
\end_inset
\series bold
+\SpecialChar ~
!
\end_inset
\family typewriter
\size footnotesize
-unsigned char far __at(0x7f00) buf[0x100];
+unsigned char __far __at(0x7f00) buf[0x100];
\newline
unsigned char head, tail;
\newline
not
\emph default
support long variables and field widths).
+\layout Subsubsection
+
+<malloc.h>
+\begin_inset LatexCommand \index{malloc.h}
+
+\end_inset
+
+
+\layout Standard
+
+Before using dynamic
+\begin_inset LatexCommand \index{dynamic}
+
+\end_inset
+
+ memory allocation with SDCC, you have to provide heap
+\begin_inset LatexCommand \index{heap}
+
+\end_inset
+
+ space for malloc to allocate memory from
+\family typewriter
+.
+
+\family default
+You can acomplish this by including the following code into your source:
+\layout Verse
+
+
+\family typewriter
+#include <malloc.h>
+\begin_inset LatexCommand \index{malloc.h}
+
+\end_inset
+
+ /* calloc
+\begin_inset LatexCommand \index{calloc}
+
+\end_inset
+
+, malloc
+\begin_inset LatexCommand \index{malloc}
+
+\end_inset
+
+, realloc
+\begin_inset LatexCommand \index{realloc}
+
+\end_inset
+
+, and free
+\begin_inset LatexCommand \index{free}
+
+\end_inset
+
+ */
+\newline
+
+\newline
+#define HEAPSIZE 0x1000 /* Adjust depending on available memory */
+\newline
+unsigned char xdata myheap[HEAPSIZE]; /* The actual heap for dynamic memory
+ */
+\newline
+
+\newline
+void main (void)
+\newline
+{
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* Your variable declarations come here*/
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+init_dynamic_memory((MEMHEADER xdata *)myheap, HEAPSIZE);
+\newline
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+ /* Rest of your code*/
+\newline
+}
+\newline
+
\layout Subsection
Math functions (sinf, powf, sqrtf etc.)
In this context a monitor is a small program which usually accepts commands
via a serial line and allows to set program counter, to single step through
a program and read/write memory locations.
- For the 8051 a good example of a monitor with a very liberal licence is
- paulmon (
-\begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
+ For the 8051 good examples of monitors are paulmon and cmon51 (see section
+
+\begin_inset LatexCommand \ref{sec:Related-open-source-tools}
\end_inset
\emph on
not
\emph default
- the same as endianness).check whether the keyword
+ the same as endianness).
+\layout Itemize
+
+check whether the keyword
\emph on
volatile
\emph default
a rewrite of the code with timer based delays instead).
\layout Itemize
-check for differences in printf parameters (some compilers push (va_arg)
- char variables as integers others as char).
+check for differences in printf parameters (some compilers push (va_arg
+\begin_inset LatexCommand \index{va\_arg}
+
+\end_inset
+
+) char variables as integers others as char).
\layout Itemize
check the resulting memory layout.
\layout Section
Related open source tools
+\begin_inset LatexCommand \label{sec:Related-open-source-tools}
+
+\end_inset
+
+
\begin_inset LatexCommand \index{Related tools}
\end_inset
\align center
\begin_inset Tabular
-<lyxtabular version="3" rows="13" columns="3">
+<lyxtabular version="3" rows="14" columns="3">
<features>
<column alignment="left" valignment="top" leftline="true" width="0pt">
<column alignment="block" valignment="top" leftline="true" width="30line%">
\layout Standard
+cmon51
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+8051 monitor (hex up-/download, single step, disassemble)
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
+
+\end_inset
+
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
doxygen
\begin_inset LatexCommand \index{doxygen (source documentation tool)}
\align center
\begin_inset Tabular
-<lyxtabular version="3" rows="6" columns="3">
+<lyxtabular version="3" rows="8" columns="3">
<features>
-<column alignment="center" valignment="top" leftline="true" width="0pt">
+<column alignment="left" valignment="top" leftline="true" width="0pt">
<column alignment="block" valignment="top" leftline="true" width="30line%">
-<column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
<row topline="true" bottomline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\end_inset
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ISO/IEC 9899:TC2
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset Quotes sld
+\end_inset
+
+C-Standard
+\begin_inset Quotes srd
+\end_inset
+
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
+
+\end_inset
+
+
+\end_inset
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ISO/IEC DTR 18037
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\begin_inset Quotes sld
+\end_inset
+
+Extensions for Embedded C
+\begin_inset Quotes srd
+\end_inset
+
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\size footnotesize
+
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
+
+\end_inset
+
+
\end_inset
</cell>
</row>
\end_inset
+\layout Standard
+
+The latest publically available version of the standard
+\emph on
+ISO/IEC 9899 - Programming languages - C
+\emph default
+ should be available at:
+\begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
+
+\end_inset
+
+.
+\newline
+
\layout Standard
Deviations from the compliance: