4.11 Mixing C and Assembly Code

Assembly language can be mixed with C code using two different techniques:

  • Assembly code placed in separate assembly source modules.
  • Assembly code placed inline with C code.
Note: The more assembly code a project contains, the more difficult and time consuming will be its maintenance. Assembly code might need revision if the compiler is updated due to differences in the way the updated compiler may work. These factors do not affect code written in C.
 If assembly must be added, it is preferable to write this as a self-contained routine in a separate assembly module, rather than in-lining it in C code.