A.2.2 Embedding assembler instructions

With the CC-RL assembler instructions can be described in the following formats within C source programs. This treats the function itself as assembler instruction, and performs inline expansion at the call site.

-

#pragma directive

#pragma inline_asm func
static int func(int a, int b) {
        /*Assembler instruction*/
}

Remark 1.

Note the following when using inline assembly.

-

Specify #pragma inline_asm before the definition of the function body.

-

External definitions are also generated for functions specified with #pragma inline_asm.

-

Comments starting with # can be used in the assembly-language programs of the CC-RL. However, if a comment starting with # is used for inline assembly, the CC-RL preprocessor interprets it as a C-language preprocessing directive and does not regard it as an assembly-language comment. Therefore, comments starting with # should not be used in assembly-language functions.

-

If you write a label in a function coded in assembly, labels with the same name will be created for each inline expansion. In this situation, use local labels coded in assembly. Although local labels have the same name in the assembly source, the assembler converts them to different names automatically.