
6-2
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
crt0 File
The operation of
setjmp()
and
longjmp()
is described in Section 6.10 and detailed
implementation information can be obtained from the files provided with DSP56KCC.
6.3 crt0 File
The following subsections describe the various functions of the
crt0
file.
6.4 Bootstrapping the C program
The processor enters a C program through the C bootstrap code in the
crt0
file. The C
bootstrap code in
crt0
provides the C environment required to execute a C program. This
environment includes a global data area, static data area, stack area, heap area, function
calling mechanism, etc. This environment must be established before C programs will
execute correctly.
The following steps are normally taken to initialize the processor to execute C code:
1. Jump from the chip reset vector to the C bootstrap code labeled at
F_ _start
in
ctr0
. Remember that the mode select pins on the chip control the chip operating
mode when leaving reset which, in turn, controls the reset vector address (see the
Motorola DSP56000/DSP56001 User’s Manual
for more details).
2. Configure all hardware registers needed (i.e,. omr, host port, etc.). This is also a
proper place to initialize any non-C related data structures or peripheral hardware
such as the bcr, Port B and Port C.
3. Load the Stack Pointer, r6, with a pointer to the base of the stack. Remember that
the stack grows up (the value in the stack pointer gets greater as data is pushed).
The value of DSIZE is generated by the linker and is the first address above the
statically allocated data (C global and static variables). By default, this value is
used as the initial stack pointer.
4. Optional: Initialize the frame pointer, r0. This may be of use to some debuggers
when stack back traces are performed. Program execution will not be affected if
this initialization is omitted.
5. Call
main()
with instruction
jsr Fmain
. Notice that the label is Fmain and there
are no parameters passed to the main function. The normal C compiler start-up
passes two arguments but g56k does not pass any arguments because DSP56KCC
does not support a particular hosted environment.
The bootstrap code is followed with the label
F_ _crt0_end
. This label is used by Gdb56
and run56 to detect program termination.
F
Freescale Semiconductor, Inc.
n
.