From 0418f658ab70836d8dfec91839945d3b6eb45cb7 Mon Sep 17 00:00:00 2001 From: jesusc Date: Wed, 30 Aug 2006 18:37:26 +0000 Subject: [PATCH] * doc/sdccman.lyx: added note on dynamic memory heap initialization git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4347 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 +++ doc/sdccman.lyx | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4f21b28c..caefe81e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-08-30 Jesus Calvino-Fraga + + * doc/sdccman.lyx: added note on dynamic memory heap initialization + 2006-08-27 Maarten Brock * src/mcs51/gen.c (genAnd, genOr, genXor): fixed bug 1546986 diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index 1cef5515..9d5e87c0 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -15465,6 +15465,100 @@ and not \emph default support long variables and field widths). +\layout Subsubsection + + +\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 +\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.) -- 2.30.2