TMS34010
C Run-Time
Environment
5.1
Memory
Model
TMS34010
C looks at memory
as
a single linear
block
partitioned
into
sub-
blocks containing various components
of
data and program code.
Each
vari-
able that
is
external
or
static
is
allocated a block
of
memory,
as
is
each
function,
Each
block
is
contiguous
and
is
limited in size
only
by
the size
of
memory available in the system. Dynamic memory allocation (mal/oc and
free) can
be
implemented by declaring a large global
or
static array and allo-
cating memory from it.
Note:
Placement
of
both
code and data
is
done
with
the linker.
Each
item
of
code
or
data can be' individually placed in memory,
but
generally this
is
not
necessary. Memory-mapped
I/O
can
be
an
exception,
but
access
to
such physical locations can usually be accomplished
with
C pointer types.
5.1.1
TMS34010
C Stacks
5-2
In
TMS34010
C,
there
are
two
stacks: the program stack (STK) and the sys-
tem stack (SP). The program stack passes parameters
to
functions
andallo-
cates local frames
for
functions. The system stack saves the status
of
the
calling .function; in other words,
it
saves registers. The
two
stacks
are
allocated .
by the
boot
module
as
a single static array called
sys-stack.
The program
stack pointer
STK
is
set
to
the
bottom
of
this array (the
low
address) and
grows·
up
to
higher addresses,
while
the system stack
is
set
to
the
top
of
the
array (the high address) and
grows
down
to
lower addresses. Thus, the
two
stacks
grow
toward each other,
as
illustrated in Figure
5-1.
This. arrangement
must
not
be altered by customizing the
boot
module.
Three registers
are
reserved
for
stack management:
SP
Points
to
the
top
of
the system stack
A14
(STK)
Points
to
the
top
of
the program stack
A13
(FP)
Points
to
the beginning
of
the current frame (frame pointer)
Manipulation
of
these registers
is
done
automatically
for
C functions by the C
environment; however, assembly language routines linked
with
C functions
must manipulate these registers according
to
the GSPC conventions.