Interfacing C with Assembly Language
6.4.2
Using Inline Assembly Language
6-22
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 creates.
A series of asm statements places sequential lines of assembly language into
the compiler output with no intervening code.
Note: Using the asm Statement
The asm statement lets you access features of the hardware that would be
otherwise inaccessible from C. When you use the asm statement, be careful
not to disrupt the C environment. The compiler does not check or analyze the
inserted instructions.
Inserting jumps or labels into C code may produce unpredictable results by
confusing the register-tracking algorithms that the code generator uses.
Do not change the value of a C variable. You can, however, safely read the
current value of any variable.
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. You can simply start the assembly code string with an asterisk (*) as shown
below:
asm("**** this is an assembly language comment");
Need help?
Do you have a question about the TMS320C2x and is the answer not in the manual?