10.6 Mixing C and Assembly Language Code
The MPLAB XC32 C Compiler for PIC32A MCU generates fixed-point code that assumes that certain 32-bit MCU device resources are managed by the compiler's start-up and run-time code. Hand-written assembly code built into the same program could interfere with the state of the CPU assumed by the code the compiler generates.
MPLAB XC32 programs may contain both
fixed-point C and assembly language code that utilizes 32-bit MCU device intrinsic fixed-point capabilities directly, but in order for
these two kinds of code to inter-operate safely, the compiler must save certain PIC32A registers around calls to assembly
language functions that may change their state. The C compiler can be instructed to do so
by providing prototypes for assembly language functions for which this is necessary. These
prototypes should specify the save(CORCON)
attribute for the target
assembly language function, as described in the Function Attributes section. Programs
constructed in this manner will operate correctly, at the expense of some state saves and
restores around calls to the indicated assembly routines.