Texas Instruments TMS34010 User Manual

Page 1
TMS34010
C Compiler
User's Guide
."
TEXAS
INSTRUMENTS
SPVUOO5
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8
Page 9
Page 10
Page 11
Page 12
Page 13
Page 14
Page 15
Page 16
Page 17
Page 18
Page 19
Page 20
Page 21
Page 22
Page 23
Page 24
Invocation
and
Operation
of
the
TMS34010
C
Compiler
3.5
Assembling
a C
Program
The GSPC batch file
automatically
produces and assembles
TMS34010
as-
sembly language source from C programs, The assembly language source file
is
available
under
the name
<input
file>,ASM,
If
you
wish
to
see
an
assembler
listing
of
the file,
you
must
explicitly
assemble this file using the
-I
option
of
the
GSP assembler,
Appendix
E is
an
example
showing
the assembly language produced from C
programs,
3.6
Archiving
a C
Program
C program
object
files may be archived using the GSPAR archiver program,
Libraries
should
be organized so
that
all references
to
external symbols
or
functions
are defined
within
the same library
or
in a
following
library, See the
TMS34010
Assembly
Language Tools User's Guide
for
more information,
3.7
Linking a C
Program
Modular
code is an
important
concept
in
writing
software
because it simplifies
the tasks
of
debugging
and
porting,
To
make
this
modularization
possible, the
programmer
must
have
the
capability
to
link
separate
modules
into
one exe-
cutable program, The
TMS3401
0 C
environment
offers
this
capability
by
pro-
viding
an assembler
that
produces
object
code
which
is linkable
by
the
TMS34010
linker.
In
the
simplest case, a C program consisting
of
modules
prog1,
prog2, etc, can
be
linked
to
produce
an
executable
output
file called
prog,out
by
invoking
the
linker
as
follows:
gsplnk
~
~
prog.out
progl.obj
prog2.obj
~
rts.lib
[flib.libJ
For
further
information,
refer
to
the
TMS34010
Assembly
Language Tools
User's Guide,
3.7.1
Run-Time
Initialization
All
C programs
must
be linked
with
an
object
module
called boot.obj,
which
contains
code
and data
for
initializing
the
run-time
environment, This
is
the
first
code
executed
when
the
program begins
running,
and
it
has the
following
responsi bi I ities:
Sets
up
the
system stack.
Processes
the
run-time
initialization table and auto-initializes
global
variables,
Disables
interrupts and calls
-main.
Boot.obj
is
supplied
in
the
run-time
support
object
library RTS,LI
B,
If
you
use
the C code
option
with
GSPLNK
and
include
RTS,LlB in
your
link
control
file,
boot.obj
is
automatically
linked in (see Section 3,7,3, The
-c
Option
in the
Linker).
Alternatively,
you
can use the archiver GSPAR
to
extract
boot.obj
from
the library and
link
it
in explicitly.
3-7
Page 25
Page 26
Page 27
Page 28
Page 29
Page 30
Page 31
Page 32
Page 33
Page 34
Page 35
Page 36
Page 37
Page 38
Page 39
Page 40
Page 41
TMS34010
C
Run-Time
Environment
necessity
for
a graphics
environment),
and
memory-mapped
I/O
is
much
more
straightforward.
5.2
Register
Conventions
Strict
conventions
are used
to
determine
which
registers are used
for
what
operations in the C environment. A
good
understanding
of
these
conventions
is
necessary
to
interface assembly language
to
a C program.
5.2.1
Dedicated
Registers
Three registers are used exclusively
by
the C environment
and
cannot
be
mo-
dified
by
a user in any
way
other
than
those
prescribed in Section 5.5,
Func-
tion
Call Conventions, page
5-7.
These registers
are:
SP
A14
(STK)
A13
(FP)
Pointer
to
the
top
of
the
system stack
Pointer
to
the
program
(user)
stack
Pointer
to
the
base
of
the
currently active frame
5.2.2
Using
Registers
5-4
Registers
AO
through A 12
are generally available
for
use by a
function.
However,
two
conventions
apply:
1)
A
function
must
save
the
contents
of
each register used on entrance
to
the
function
and restore
those
contents
on exiting
the
function.
A8
is
the
only
exception; its
contents
do
not
have
to
be saved and restored.
2)
If
an integer value or a
pointer
is
to
be returned
from a function;
it
must
be placed in A8.
The codegen uses the registers in the
following
fashion:
Address generation Expression analysis Holding
constants
Return
value/Scratch
User register variabJes
Note:
AO,A2,A4,A6
A1,A3,A5,A7
A1,
A3,
A5,
A7,
A9
through
A12 A8 A9,
A10,
A11,
A12
Registers
BO
through
B14
are available for use
by
the
assembly-language
programmer and are
not
used
by
the
C compiler.
Address generation registers are allocated on a least-recently-used
(LRU)
basis,
with
the
low
registers allocated first. Expression analysis registers are
allocated from high
to
low
registers, based on availability and current use.
(Note
that
all integer expression analysis uses
32-bit
math.)
To
hold
con-
stants,
both
the
user registers and
the
expression analysis registers can be
used and are allocated
from
high
to
low
registers.
Page 42
Page 43
Page 44
Page 45
Page 46
Page 47
Page 48
Page 49
Page 50
Page 51
Page 52
Page 53
Page 54
Page 55
Page 56
Page 57
Page 58
Page 59
Page 60
Page 61
Page 62
Page 63
Page 64
Page 65
Page 66
Page 67
Page 68
strcmp
Syntax
Description
Compare
Strings
#include
<string.h>
int
strcmp(string1
,string2)
char
'string1
,'string2;
strcmp
This
function
compares
two
strings, character
by
character, and returns an
indicator
of
which
string
is
lower
in the
ASCII
character set.
The
indicators
are:
-1
if
string 1 is less than string2
o
if
string 1
is
equal
to
string2
1
if
string 1
is
greater
than
string2
6-17
Page 69
Page 70
Page 71
Page 72
Page 73
Page 74
Page 75
Page 76
Page 77
Page 78
Page 79
Page 80
Page 81
Page 82
Page 83
Page 84
Page 85
Page 86
Page 87
Page 88
#ifndef
Begin
Conditional
Compilation
#ifndef
Syntax
#ifndef
<name>
Description
The lines
of
code between
#ifndef
and
#endif
or
#else
will
appear in
the
output
if
and
only
if
name has
not
been defined
(by
#define) or has been
the subject
of
a subsequent #undef.
C-7
Page 89
Page 90
Page 91
Page 92
Page 93
Page 94
Page 95
Page 96
Page 97
Page 98
Page 99
Page 100
Loading...