3.3.7.1 How Should I Combine Assembly and C Code?
Ideally, any hand-written assembly should be written as separate routines that can be called. This offers some degree of protection from interaction between compiler-generated and hand-written assembly code. Such code can be placed into a separate assembly module that can be added to your project, as specified in 20.1 Mixing Assembly Language and C Variables and Functions.
If necessary, assembly code can be added in-line with C code by using either of two forms
of the asm
instruction; simple or extended. An explanation of these forms,
and some examples, are shown in 20.2 Using Inline Assembly Language.
Macros are provided which in-line several simple instructions, as discussed in 20.3 Predefined Macro. More complex in-line assembly that changes register contents and the device state should be used with caution.
See 14.1 Register Usage for those registers used by the compiler.