|
|
|
|
|
|
|
Cosmic Software Frequently Asked Questions
When I declare a global zero page, eeprom or const pointer it does not seem to be allocated in the correct memory section?
Space modifiers used with pointers depend on the placement of the modifier in relation to the asterisk. In fact, you may need to use two modifiers to achieve the desired allocation. i.e. one modifier to specify the space the pointer targets and another to specify where the pointer itself will reside. See the example below.
@tiny unsigned char var; // 8 Bit Variable located in zero page (0x0 to 0xFF)
@tiny unsigned char *zptr; // 8 bit Pointer located anywhere, but points to objects in zero page
unsigned char * @tiny zptr2; // 16 bit Pointer is located in zero page , but points anywhere
@tiny char *@tiny zptr3; // 8 bit Pointer is located in zero page and points to zero page
@dir unsigned char var; // 8 Bit Variable located in zero page
@dir unsigned char *cptr; // 16 bit Pointer located anywhere, but points to objects in zpage
unsigned char * @dir cptr2; // 16 bit Pointer is located in zpage, but points anywhere
@dir char *@dir cptr3; // 16 bit Pointer is located in zero page and points to object in zero page
const unsigned char var; // 8 Bit Variable located in const section
const unsigned char *cptr; // 16 bit Pointer located anywhere, but points to objects in const section
unsigned char * const cptr2; // 16 bit Pointer is located in const section, but points anywhere
const char * const cptr3; // 16 bit Pointer is located in const section and points to object in const section
This allocation behavior is the same for all space modifiers such as const, volatile, @dir, @tiny, @near, @far and @eeprom.
|
|
|
|
|
|
|
|
|
|
|
|
|
|