
The asm Statement
5-9
TMS320C2x/C2xx/C5x C Language
5.5 The asm Statement
The TMS320C2x/C2xx/C5x C compiler can embed ’C6000 assembly lan-
guage instructions or directives directly into the assembly language output of
the compiler. This capability is an extension to the C language—the
asm
state-
ment. The asm statement provides access to hardware features that C cannot
provide. The asm statement is syntactically like a call to a function named
asm, with one string constant argument:
asm(”
assembler text
”);
The compiler copies the argument string directly into your output file. The
assembler text must be enclosed in double quotes. All of the usual character
string escape codes retain their definitions. For example, you can insert a
.string directive that contains quotes:
asm( ”STR: .string \”
abc\
””);
The inserted code must be a legal assembly language statement. Like all
assembly language statements, the line of code inside the quotes must begin
with a label, a blank, a tab, or a comment (asterisk or semicolon). The compiler
performs no checking on the string; if there is an error, the assembler detects
it. For more information about the assembly language statements, see the
TMS320C1x/C2x/C2xx/C5x Assembly Language Tools User’s Guide
.
The asm statements do not follow the syntactic restrictions of normal C state-
ments. Each can appear as a statement or a declaration, even outside of
blocks. This is useful for inserting directives at the very beginning of a com-
piled module.
Note: Avoid Disrupting the C Environment With asm Statements
Be careful not to disrupt the C environment with asm statements. The com-
piler does not check the inserted instructions. Inserting jumps and labels into
C code can cause unpredictable results in variables manipulated in or
around the inserted code. Directives that change sections or otherwise affect
the assembly environment can also be troublesome.
Be especially careful when you use the optimizer with asm statements.
Although the optimizer cannot remove asm statements, it can significantly
rearrange the code order near them and cause undesired results.
Содержание TMS320C2x
Страница 8: ...viii...
Страница 69: ...2 47 C Compiler Description...
Страница 159: ...6 36...
Страница 226: ...8 6...
Страница 250: ...Index Index 14 Z z shell option 2 2 2 4 2 14 overriding with c option 4 5 overriding with n option 2 13...