Runtime
Environment
-
System
Initialization
The
boot
routine allocates memory for both stacks in the .bss section; this
memory
is
allocated
as
a single, static array named
SYS-STACK.
The
boot
routine defines a constant named
STACK-SIZE
that determines the size
of
the
SYS-STACK
array; the default stack size
is
2000
bytes. (For information about
changing the stack size,
see
Section 5.1.2 on page
5-3.)
The
two
stacks share the space by
growing
towards each other from opposite
sides
of
the array. A stack overflow occurs
if
the stacks collide; although there
is
no
way
to
recover from a stack overflow, you can check for overflow
con-
ditions by invoking the code generator
with
the
-x
option.
5.8.2
Autoinitialization
of
Variables
and
Constants
Some global variables must have initial values assigned
to
them before a C
program starts running. The process
of
retrieving these variables' data and
initializing them
with
the data
is
called
autoinitialization.
The compiler builds tables in a special section called
.cinit
that contain data
for
initializing global and static variables.
Each
compiled module contains
these initialization tables. The linker combines them into a single table (a
single .cinit section) that the
boot
routine uses
to
initialize all the variables that
need values before the program starts running.
Note:
In standard
C,
global and static variables
which
are
not
explicitly initialized
are
set
to
0 before program execution. The TMS3401 0 C compiler does
not
adhere
to
this convention.
Any
variable
which
must have
an
initial
value
of
0 must be explicitly initialized.
There
are
two
methods for copying the autoinitialization data into memory;
these methods
are
called the ROM and RAM models
of
autoinitialization. The
remainder
of
this section contains specific information about autoinitialization;
Section 5.8.2.1 describes the format
of
the initialization tables, Section 5.8.2.2
describes the
ROM model, and Section 5.8.2.3 describes the RAM model.
5-23