User`s guide
Inline Assembly Language and Intrinsics
Inline Assembly Language
138
Targeting MC56F83xx/DSP5685x Controllers
6. Assembly language directives, instructions, and registers are not case-sensitive.
The following two statements are the same:
add x0,y0
ADD X0,Y0
7. Comments must have the form of C or C++ comments; they must not begin with
the ; or # characters. Listing 7.5
shows the valid syntax for comments.
Listing 7.5 Valid Comment Syntax
move.w x:(r3),y0 # ERROR
add.w x0,y0 // OK
move.w r2,x:(sp) ; ERROR
adda r0,r1,n /* OK */
8. To optimize a block of inline assembly source code, use the inline assembly
directive .optimize_iasm on before the code block. Then use the directive
.optimize_iasm off at the end of the block. (Omitting
.optimize_iasm off means that optimizations continue to the end of the
function.)
Calling Assembly Language Functions
from C Code
You can call assembly language functions from C just as you would call any standard
C function, using standard C syntax.
Calling Inline Assembly Language Functions
Listing 7.6 demonstrates how to create an inline assembly language function in a C
source file. This example adds two 16-bit integers and returns the result.
Notice that you are passing two 16-bit addresses to the add_int function. You pick
up those addresses in R2 and R3, passing the sum back in Y0.
Listing 7.6 Sample Code - Creating an Inline Assembly Language Function
asm int add_int( int * i, int * j )
{
move.w x:(r2),y0
move.w x:(r3),x0