Cosmic Software Frequently Asked Questions


How do I set a data object or function to a predefined address?


Use the #pragma section definition to set a function or any other data object to a newly named segment then place it to a memory location via the linker file
#pragma section [test]   
unsigned char array[20];
#pragma section []
The above would set an uninitialized array defined as char array[20]. To link this to address 0x1000, the linker must contain this line. This method also works for a function, where the array example listed above can be substituted by the entire function.
#pragma section (bootldr)   
void foo(void)
   {
   }

#pragma section () 

+seg .bootldr –b0x1000