Cosmic UK Cosmic US Cosmic Germany Cosmic Italia Cosmic France


Cosmic Software Frequently Asked Questions


How do I locate data objects explicitly in zero page or external memory?


Cosmic compilers use either the @tiny or @dir (direct) space modifier to locate data objects into the zero page and use the more efficient direct addressing mode. The @dir modifier is used by the Cosmic HC11 and HC12 compilers to mark objects that the compiler can use the direct addressing mode. The @tiny modifier is used with the HC05, HC08 and ST7 processors to mark objects that the compiler can use direct addressing, 8-bit data references and 8-bit pointers.
Alternatively, the +zpg compiler option may be used to allocate all data objects in a source module to the zero page except const objects. The @near space modifier is used to explicitly allocate data objects outside of the zero page i.e. data addressable anywhere in the 16 bit addressable space. By default, @near is the default allocation for all Cosmic compilers except for the HC05. The @near modifier is useful when most objects are to be located in the zero page, but not all. In this case, you can use the +zpg option to allocate all of the objects to the zero page and then override this behavior for selected data objects using the @near modifier.
The @tiny modifier specifies that the compiler can use direct addressing and single byte pointers and references. The @near modifier instructs the compiler to use 16 bit addressing modes, pointers and references(default behavior).
@tiny unsigned char var;	// 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
Please note: The default behavior of the Cosmic HC05 compiler locates all data objects in the zero page. To override this behavior and locate objects outside of the zero page use the @near modifier. e.g.
@near unsigned char var;	// Variable located anywhere in 64K address space 
The Cosmic HC11 and HC12 compilers use the @dir modifier instead of @tiny to locate objects in the zero page. The @dir modifier specifies that the compiler can use the direct addressing modes available on the HC11 and HC12 however single byte pointers and data references are not supported by the HC11 or HC12 processors.