File-scope inline assembly
Inline assembly can be used at file-scope to insert assembly into the output of the compiler.
All file-scope inline assembly code is inserted into the output of the compiler before the code for any functions or variables declared in the file, regardless of where they appear in the input. If multiple blocks of file-scope inline assembly code are present in one file, they are emitted in the same order as they appear in the source code.
Compiling multiple files containing file-scope inline assembly with the
-flto option does not affect the ordering of the blocks
within each file, but the ordering of blocks in different files is not defined.
If you include multiple assembly statements in one file-scope inline assembly block, you must separate them by newlines or semicolons. The assembly string does not have to end in a new-line or semicolon.
// Simple file-scope inline assembly. __asm(".global __use_realtime_heap"); // Multiple file-scope inline assembly statements in one block: __asm("add_ints:\n" " add r0, r0, r1\n" " bx lr"); // C++11 raw string literals can be used for long blocks, without needing to // include escaped newlines in the assembly string (requires C++11): __asm(R"( sub_ints: sub r0, r0, r1 bx lr )");