I want to add a macro in in extended assembly in c code. is this possible ?
I am looking for something like this:
ANY_MACRO (Instruction) asm volatile(
"li t0, 0xcafebabe;"
"li t1, 0x00c0fee;"
<----///Replace instruction here like ()////---->
:[dummy_output]"=r"(dummy_output_var)
:[dummy_var_addr]"r"(&dummy_var1)
:"t0","t1","t2","a0"
);
Note: I am also manipulating some C-Variables in this Macro as shown above!
Compiler: GCC Assembly: RISCV
The
__asm__construct takes the assembly as a quoted string (a string literal), so the macro needs to produce its result as a quoted string. This can be in the form of consecutive quoted strings, which the compiler will automatically concatenate into one string, and you can use the#preprocessor operator to convert macro arguments into quoted strings:If any of the arguments to your
INSERT_INSTmacro are themselves macros that you want expanded, you will need another macro to replace and quote them: