Runtime
Environment
-
Memory
Model
A13
(FP)
is
the
frame
pointer;
it points to the beginning
of
the current
local frame. (The local frame
is
an
area
on the program stack
used for storing arguments and
local variables.)
The C environment automatically manipulates these registers when a C
func-
tion
is
called.
If
you interface assembly language routines
to
C,
be
sure to use
the registers in the same
way
that the C compiler uses them.
5.1.3
Dynamic
Memory
Allocation
The runtime-support library supplied
with
the compiler contains several func-
tions (such
as
malloc, calloc, and realloc) that allow you
to
dynamically allo-
cate memory for variables at run time. This
is
accomplished by declaring a
large memory pool, or heap, and then using the functions
to
allocate memory
from the heap. Dynamic
allocation
is
not
a standard part
of
the C language;
it
is
provided by standard runtime-support functions.
A
C module called
memory.
c reserves space for this memory pool in the .bss
section. The
module also defines a constant MEMORY-SIZE that determines
the size
of
the memory pool; the default size is
1000
bytes. You can change
the size
of
the memory pool by
following
these steps:
1)
Extract
memory.
c from the source library
rts.
src.
2) Edit
memory.
c; change the value
of
the constant MEMORY-SIZE to the
desired memory
pool size.
3)
Recompile and assemble
memory.
c and replace the resulting object file,
memory.
obj,
in the object library
rts
.lib.
4) Replace the copy
of
memory.
c that's in
rts.
src
with
the edited ver-
sion.
5.1.4
RAM
and
ROM
Models
5-4
The C compiler produces code that
is
suitable
for
use
as
firmware in a
ROM-based system.
In such a system, the initialization tables in the .cinit
section
are
stored in ROM.
At
system initialization time, the C boot routine
copies data from these
tables from ROM
to
the initialized variables in .bss
(RAM).
In situations where a program
is
loaded directly from
an
object file into mem-
ory and then run, you can avoid having the .cinit section occupy space in
memory. A
loader can
read
the initialization tables directly from the object file
(instead
of
from ROM) and perform the initialization directly at load time
(in-
stead
of
at run time). You can specify this to the linker by using the
-cr
linker
option.
For more information about autoinitialization, refer
to
Section 5.8.2 on page
5-23.