Calling Inline Assembly Language Functions

The following listing demonstrates how to create an inline assembly function in a C source file. This example adds two integers and returns the result.

Note that you are passing the two parameters in registers D0, D1, and the result is returned in D0.

Listing: Sample Code - An Inline Assembly Function
asm int my_inlineasm_func(int a, int b)
{

subq.l   #4,a7

move.l   d1,(a7)

add.l    (a7),d0

addq.l   #4,a7

rts

}

The following listing shows the C calling statement for this inline-assembly-language function.

Listing: Sample Code - Inline Assembly Function Call
rez = my_inlineasm_func(10, 1);