Next pragma CODE_SEG
#pragma CODE_SEG (<Modif> <Name>|DEFAULT)
CODE_SECTION
<Modif>: Some of the following strings may be used:
__DIRECT_SEG (compatibility alias: DIRECT)
__NEAR_CODE
__NEAR_SEG (compatibility alias: NEAR)
__CODE_SEG (compatibility alias: CODE)
__ FAR_CODE
__FAR_SEG (compatibility alias: FAR)
The meaning of these segment modifiers are backend-dependent. Refer to HC(S)08 Backend for information on supported modifiers and their definitions.
<Name>: The segment name. You must use the segment name in the link parameter file on the left side of the assignment in the PLACEMENT section. Refer to the Linker manual for details.
DEFAULT
This pragma specifies the allocated function segment. The segment modifiers also specify the function's calling convention. The CODE_SEG pragma sets the current code segment. This segment places all new function definitions. Also, all function declarations, when they occur, get the current code segment.
The CODE_SEG pragma affects function declarations as well as definitions. Ensure that all function declarations and their definitions are in the same segment.
The synonym CODE_SECTION means exactly the same as CODE_SEG. See the following listing for some CODE_SEG examples.
/* in a header file */ #pragma CODE_SEG __FAR_SEG MY_CODE1 extern void f(void); #pragma CODE_SEG MY_CODE2 extern void h(void); #pragma CODE_SEG DEFAULT /* in the corresponding C file: */ #pragma CODE_SEG __FAR_SEG MY_CODE1 void f(void){ /* f has FAR calling convention */ h(); /* calls h with default calling convention */ } #pragma CODE_SEG MY_CODE2 void h(void){ /* f has default calling convention */ f(); /* calls f with the FAR calling convention */ } #pragma CODE_SEG DEFAULT
The following listing shows some errors when using pragmas.
#pragma DATA_SEG DATA1 #pragma CODE_SEG DATA1 /* error: segment name has different types! */ #pragma CODE_SEG DATA1 #pragma CODE_SEG __FAR_SEG DATA1 /* error: segment name has modifiers! */ #pragma CODE_SEG DATA1 void g(void); #pragma CODE_SEG DEFAULT void g(void) {} /* error: g is declared in two different segments */ #pragma CODE_SEG __FAR_SEG DEFAULT /* error: modifiers for DEFAULT segment are not allowed */
Linker Manual
#pragma CONST_SEG: Constant Data Segment Definition
#pragma DATA_SEG: Data Segment Definition
#pragma STRING_SEG: String Segment Definition
-Cc: Allocate Const Objects into ROM compiler option