Cosmic UK Cosmic US Cosmic Germany Cosmic Italia Cosmic France


Cosmic Software Frequently Asked Questions


How do I access global variables declared in C from an Assembly module?


The compiler declares any global variable in C with an underscore (_) prefix. Meaning, if you have a variable declared as:
unsigned char counter; 
and wish to access its value in assembly; your assembly code would look something like
xref _counter 
ldab _counter
If the variable is located in the zero page (if supported)
@tiny unsigned char test;
OR
@dir unsigned char test
Then in assembly
xref.b _test 
ldab _test