#pragma STRING_SEG: String Segment Definition

Scope

Next pragma STRING_SEG

Syntax
  #pragma STRING_SEG (<Modif><Name>|DEFAULT)
  
Synonym
   STRING_SECTION   
Arguments

<Modif>: Some of the following strings may be used:

__DIRECT_SEG (compatibility alias: DIRECT)

__NEAR_SEG (compatibility alias: NEAR)

__CODE_SEG (compatibility alias: CODE)

__FAR_SEG (compatibility alias: FAR)

__LINEAR_SEG

Note: Do not use a compatibility alias in new code. Compatibility aliases exist for backwards compatibility only. Some compatibility alias names conflict with defines found in certain header files. Avoid using compatibility alias names.

The __SHORT_SEG modifier specifies a segment that is accessed using 8-bit addresses. The definitions of these segment modifiers are backend-dependent. Refer to HC(S)08 Backend to find the supported modifiers and their definitions.

<Name>: The name of the segment. This name must be used in the link parameter file on the left side of the assignment in the PLACEMENT part. Refer to the linker manual for details.

Default
  DEFAULT   
Description

This pragma allocates strings into a linker segment called STRINGS. String segments may have modifiers. The modifiers instruct the Compiler to access the strings in a special way when necessary.

The linker treats segments defined with the pragma STRING_SEG like constant segments defined with #pragma CONST_SEG and allocates the segments in ROM areas.

The pragma STRING_SEG sets the current string segment and places all new strings into the current segment.

Note: The linker may support an overlapping allocation of strings (e.g., the allocation of " CDE" inside of the string " ABCDE", so that both strings together need only six bytes). When putting strings into user-defined segments, the linker may no longer do this optimization. Only use a user-defined string segment when necessary.

The synonym STRING_SECTION means exactly the same as STRING_SEG.

Example

the following shows the STRING_SEG pragma allocating strings into a segment with the name STRING_MEMORY.

Listing: Using a STRING_SEG Pragma to Allocate a Segment for Strings
#pragma STRING_SEG STRING_MEMORY
char* p="String1";

void f(char*);

void main(void) {

  f("String2");

}

#pragma STRING_SEG DEFAULT
See also

HC(S)08 Backend

Segmentation

Linker section of the Build Tool Utilities manual

#pragma CODE_SEG: Code Segment Definition

#pragma CONST_SEG: Constant Data Segment Definition

#pragma DATA_SEG: Data Segment Definition