User`s guide
C for DSP56800E
Calling Conventions and Stack Frames
116
Targeting MC56F83xx/DSP5685x Controllers
Returning Values From Functions
The compiler returns function results in registers A, R0, R2, and Y0:
• 16-bit integer values — Y0.
• 32-bit integer or float values — A.
• All pointer values — R2.
• Structure results — R0 contains a pointer to a temporary space allocated by the
caller. (The pointer is a hidden parameter value.)
Additionally, the compiler:
• Reserves R5 for the stack frame pointer when a function makes a dynamic
allocation. (This is the original stack pointer before allocations.) Otherwise, the
compiler saves R5 across function calls.
• Saves registers C10 and D10 across function calls.
• Does not save registers C2 and D2 across function calls.
Volatile and Non-Volatile Registers
Values in non-volatile registers can be saved across functions calls. Another term for
such registers is saved over a call registers (SOCs).
Values in volatile registers cannot be saved across functions calls. Another term for
such registers is non-SOC registers.
Table 6.3
lists both the volatile and non-volatile registers.
Table 6.3 Volatile and Non-Volatile Registers
Unit Register Size Type Comments
Arithmetic Logic Unit
(ALU)
Y1 16 Volatile (non-SOC)
Y0 16 Volatile (non-SOC)
Y 32 Volatile (non-SOC)
X0 16 Volatile (non-SOC)
A2 4 Volatile (non-SOC)
A1 16 Volatile (non-SOC)
A0 16 Volatile (non-SOC)