With the CC-RH, assembler instruction can be described in the functions of a C source program.
One of the #pragma directives to embed assembler instructions is #pragma inline_asm.
This treats the function itself as an assembler instruction only, and performs inline expansion at the call site.
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.
Specifying (size = numerical value) does not affect the result of compilation.
#pragma inline_asm func_add static int func_add(int a, int b){ add r6, r7 mov r7, r10 } void func(int *p){ *p = func_add(10,20); } |
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. |
The compiler passes strings in #pragma inline_asm to the assembler as-is, without checking or modifying them. |
Only positive integer constants are specifiable for (size = numerical value). Specifying a floating-point number or value less than 0 will cause an error. |
If #pragma inline_asm is specified for a static function, then the function definition will be deleted after inline expansion. |
Assembly code is targeted by the preprocessor. Caution is therefore needed when using #define to define a macro with the same name as an instruction or register used in assembly language (e.g. "MOV" or "r5"). |
Although it is possible to use comments starting with a hash ("#") in RH850 assembly language, if you use this comment, 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. |