Sets the current code segment.
#pragma CODE_SEG <name>|DEFAULT
<name>
The name of the code segment being defined. This segment must be explicitly allocated within the PLACEMENT block in the link parameter file. For more information, refer to the chapter Linker Issues of the Build Tools Utilities reference manual.
DEFAULT
This pragma sets the current code segment, either the default code segment (that is, DEFAULT_ROM), or a user-defined segment. All the functions subsequently defined are allocated into that segment by the linker.
The following listing exemplifies correct usage of the CODE_SEG pragma:
/* p.h */ #pragma CODE_SEG MY_ROM extern void func1(); #pragma CODE_SEG DEFAULT extern void func2(); /* p.c */ #pragma CODE_SEG MY_ROM void func1() { c = a + b; } #pragma CODE_SEG DEFAULT void func2() { c = a - b; }
The following listing contains examples of improper CODE_SEG pragma usage:
#pragma CONST_SEG MY_ROM #pragma CODE_SEG MY_ROM /** incorrect: the same segment name used with different segment types **/ #pragma CODE_SEG MY_ROM extern void func1(); #pragma CODE_SEG DEFAULT extern void func1(); /** incorrect: function 'func1' is declared in two different segments **/ /* p.h */ #pragma CODE_SEG MY_ROM extern void func1(); #pragma CODE_SEG DEFAULT extern void func2(); #pragma CODE_SEG MY_ROM extern void func3(); #pragma CODE_SEG DEFAULT /* p.c */ #pragma CODE_SEG MY_ROM void func1() { z = x + y; } #pragma CODE_SEG DEFAULT void func2() { z = x - y; } void func3() { z = x * y; } /** incorrect: 'func3' is declared in segment MY_ROM and defined in segment DEFAULT **/