Cosmic UK Cosmic US Cosmic Germany Cosmic Italia Cosmic France


Cosmic Software Frequently Asked Questions


Can I create my own segment names other than the reserved segment names used by the linker?


The compiler allows you to redefine a reserved section name for a block of code or data using #pragmas. Redefining of section names is a popular technique that gives the user more control in locating code and data images at specific memory addresses. It is possible to redirect any memory type to a user defined section by using the following pragma definition: See the section "Redefining Sections" in the user's manual for more information.
 #pragma section <attribute> <qualified_name>
where <attribute> is either empty or one of the following sequences:
const, @dir, @eeprom, @far 
and <qualified_name> is a section name enclosed as follows:
(name) - parenthesis indicating a code section
[name] - square brackets indicating uninitialized data
{name} - curly braces indicating initialized data 
The following example redefines the .text section to .mycode where the parenthesis indicate that it's a code section. This causes all code under the first #pragma to be allocated to the .mycode section instead of the .text section. The second #pragma ends the redefinition so any subsequent code would be allocated to the .text section.
#pragma section (mycode) 

     Any code or data

#pragma section ()
Example Linker segment using the .code section
+seg .mycode -b0xC000