A.2.3 Embedding assembler instructions

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

-

#pragma directive

#pragma inline_asm
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.

-

Also generate external definitions of functions specified with #pragma inline_asm.

-

If you use a register to guarantee the entrance and exit of an inline function with embedded assembly, you must save and restore this register at the beginning and end of the function.

-

RH850 assembly language can use comments starting with the hash character ("#"). Do not use # comments inside functions coded in assembly, because the preprocessor will interpret these as preprocessing directives.

-

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.