User`s guide
C for DSP56800E
Optimizing Code
132
Targeting MC56F83xx/DSP5685x Controllers
External Library Compatibility
If you enable the large data model when the compiler builds your main application,
external libraries written in C also must be built with the large data model enabled.
The linker enforces this requirement, catching global objects located out of range for
particular instructions.
A more serious compatibility problem involves pointer parameters. Applications built
with the large data memory model may pass pointer parameter values in two words of
the stack. But libraries built using the small memory model may expect pointer
arguments to occupy a single word of memory. This incompatibility will cause
runtime stack corruption.
You may or may not build external libraries or modules written in assembly with
extended addressing modes. The linker does not enforce any compatibility rules on
assembly language modules or libraries.
The compiler encodes the memory model into the object file. The linker verifies that
all objects linked into an executable have compatible memory models. The ELF
header’s e_flags field includes the bit fields that contain the encoded data memory
model attributes of the object file:
#define EF_M56800E_LDMM 0x00000001 /* Large data memory model
flag */
Additionally, C language objects are identified by an ELF header flag.
#define EF_M56800E_C 0x00000002 /* Object file generated from C
source */
Optimizing Code
Register coloring is an optimization specific to DSP56800E development. The
compiler assigns two (or more) register variables to the same register, if the code does
not use the variables at the same time. The code of Listing 6.6
does not use variables i
and j at the same time, so the compiler could store them in the same register:
Listing 6.6 Register Coloring Example
short i;
int j;