EasyManuals Logo
Home>Texas Instruments>Computer Hardware>TMS34010

Texas Instruments TMS34010 Reference Guide

Texas Instruments TMS34010
181 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #61 background imageLoading...
Page #61 background image
Runtime
Environment
-
Interfacing
C
with
Assembly Language
5.4
Interfacing
C
with
Assembly Language
There
are
three ways
to
use assembly language in
conjunction
with
C code:
• Use separate modules
of
assembled code and
link
them
with
compiled
C modules (see Section 5.4.1). This
is
the most versatile method.
• Use in line assembly language, imbedded directly in
th~
C source (see
Section 5.4.2).
•
Modify
the assembly language code
that
the compiler produces (see
Section 5.4.3).
5.4.1 Assembly Langua"ge
Modules
5-12
Interfacing
with
assembly language
functions
is
straightforward
if
you
follow
the calling conventions defined in Section 5.3 and the register conventions
defined in Section 5.2.
C code can access variables and call
functions
that
are defined in assembly language, and assembly code can access C variables
and call
C functions.
Follow
these guidelines
to
interface assembly language and
C:
1 ) All functions, whether they
are
written in C or assembly language, must
follow
the conventions outlined in Section 5.3 (page
5-8).
2)
You must preserve any registers that are modified
by
a function, except
register A8. When returning from a function,
FS1
must equal 32.
3)
Interrupt routines must save all the registers they use. (For more
infor-
mation about interrupt handling, see Section 5.5, page
5-16.)
4)
If
the caller passes arguments or
if
the called
function
returns a float
or
a double, save the program stack pointer
(A14)
by
pushing
it
on the
system stack, then push any arguments on the program stack in reverse
order.
5) Functions must return values correctly according
to
their C declarations.
Integers and pointers are returned in register A8. All
floating-point
val-
ues
are
returned on the stack. Section 5.3.5 discusses returning struc-
tures.
6)
No assembly language module should use the
.cinit
section
for
any
purpose other than autoinitialization
of
global variables. The C
boot
routine
(boot.
c)
assumes that the .cinit section consists
entirely
of
initialization tables. Disrupting the tables by
putting
other information
in .cinit can cause unpredictable results.
7)
The compiler prefixes all identifiers
with
an
underscore
(_).
This means
that you must prefix the name
of
all objects that
are
to
be accessible from
C
with
- when
writing
assembly language. For example, a C object
called
x
is
called
-x
in assembly. For identifiers that are
to
be used
only
in
an
assembly language module or modules, any name
that
does
not
begin
with
a leading underscore may be safely used
without
conflicting
with
a C identifier.
8)
Any
object or function declared
by
an
assembly language routine that
is
to
be accessed
or
called from C must be declared
with
the .global as-

Table of Contents

Other manuals for Texas Instruments TMS34010

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TMS34010 and is the answer not in the manual?

Texas Instruments TMS34010 Specifications

General IconGeneral
BrandTexas Instruments
ModelTMS34010
CategoryComputer Hardware
LanguageEnglish

Related product manuals