Describing assembler instruction (#pragma inline_asm)


This specifies inline expansion of a function written in the assembly language.

[Function]

-

Performs inline expansion on functions coded in assembly and declared with #pragma inline_asm.

-

The calling conventions for an inline function with embedded assembly are the same as for ordinary function calls.

[Usage]

-

#pragma inline_asm is declared before the target functions.

#pragma inline_asm  [(]function-name [,...][)]

[Restrictions]

-

#pragma inline_asm should be specified before the definition of the function body.

-

An external definition is also generated for a function specified with #pragma inline_asm.

-

The compiler passes the character strings written in the functions specified with #pragma inline_asm to the assembler without change.

-

The codes written in assembly language are processed by the preprocessor. Therefore, special care must be taken when the same names as the instructions or registers used in the assembly language are defined as the names of macros with #define.

-

When a label is written in an assembly-language function, labels having the same name are generated for the number of times the function is expanded inline. In this case, use a local label written in the assembly language. A local label has a single name in the assembly-language code, but the assembler automatically converts it into separate names.
See ".LOCAL" for local label.

[Example]

The following shows a sample C source code.

#pragma inline_asm func
void func(int x) {
        movw    !_a, ax
}
void main(void) {
          :
        func(3);
          :
}

 

The following shows the assembly source output by compiler.

        .SECTION        .textf, TEXTF
_func:
                :
        ._line_top inline_asm
        movw    !_a, ax
        ._line_end inline_asm
        ret
_main:
                :
        movw    ax,  #0x0003
        ._line_top inline_asm
        movw    !_a, ax
        ._line_end inline_asm
                :