10.6 Mixing C and Assembly Language Code
The MPLAB XC-DSC C Compiler generates fixed-point code that assumes that certain DSC 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 XC-DSC programs may contain both
fixed-point C and assembly language code that utilizes DSC device intrinsic fixed-point capabilities directly, but in order for these two
kinds of code to inter-operate safely, the compiler must save certain dsPIC 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 14.1.2 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.