Runtime
Environment
-
Interfacing
C
with
Assembly
Language
You can use a named section to define
as
many variables
as
you like (in the
same
way
that the compiler uses .bss for multiple variables).
It
is not neces-
sary
to
use a .sect or .usect section for each new variable unless you
want
to
allocate it in memory separately from other variables. For example, you may
want
to
define a lookup table in its
own
named section
if
you
don't
want
to
allocate it into RAM
with
the .bss section.
5.4.2
Inline
Assembly
Language
Within a C program, you can use the
asm
statement
to inject a single line
of
assembly language into the assembly language file that the compiler cre-
ates. A series
of
asm
statements places sequential lines
of
assembly language
into the compiler
output
with
no intervening C code.
See
Section 4.8, page
4-10,
for
more information about the
asm
statement.
Warning:
When
you
use
asm
statements,
be
extremely
careful
not
to
dis-
rupt
the
C
environment.
The
compiler
does
not
check
or
ana-
lyze
the
inserted
instructions.
Inserting
jumps
or
labels
into
the
C
code
may
produces
unpre-
dictable
results
by
confusing
the
register-tracking
algorithms
that
the
code
generator
uses.
The
asm
statement
is
provided
so
that
you
can
access
features
of
the
hardware
which
would
be
otherwise
inaccessible
from
C.
Do
not
change
the
value
of
a C
variable;
however,
you
can
safely
read
the
current
value
of
any
variable.
In
addition,
do
not
use
the
asm
statement
to
insert
assembler
directives
that
would
change
the
assembly
environment.
The
asm
statement
is
also useful for inserting comments in the compiler
out-
put; simply start the assembly language statement
with
an
asterisk:
asm("***
this
is
an
assembly
language
comment
***");
5.4.3
Modifying
Compiler
Output
You can inspect and change the assembly language
output
that the compiler
produces by compiling the source and then editing the
output
file before as-
sembling it. The warnings in Section 5.4.2 about disrupting the C environ-
ment
also apply to modifying compiler output.
5-15