CODE_SEG

Sets the current code segment.

Syntax
  #pragma CODE_SEG <name>|DEFAULT  
Parameters

<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

DEFAULT

Remarks

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.

Note: The CODE_SEG pragma affects function declarations as well as definitions. Ensure that, for a given function, the declaration and definition are in the same segment.

The following listing exemplifies correct usage of the CODE_SEG pragma:

Listing: Using pragma CODE_SEG
/* 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:

Listing: Improper Usage of CODE_SEG pragma
#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 **/