| |||||
Technical Support Support Resources
Product Information | A251: ACCESSING GLOBAL VARIABLES DEFINED IN C CODEInformation in this article applies to:
QUESTIONI have the following global variable defined in my C code. How can I access it from assembly code? char data send_it _at_ 0x07; ANSWERUse the following line in your assembly code. It is the equivalent of a C 'extern' declaration for the global variable: EXTRN DATA : BYTE (send_it) You can easily determine what the equivalent assembler code is for your C code by getting the compiler to generate the assembler for you. For example, to find out the assembler required for the extern declaration you could write the following C source file:
#pragma src
extern char data send_it _at_ 0x07;
void main(void)
{
send_it = 7;
}
The assignment is included to prevent the optimizer from removing the variable access. Compiling this file generates an .src file which contains the equivalent assembler code. Looking at the variable declarations in this file shows how to declare the 'extern' in C and access the global variable. MORE INFORMATIONLast Reviewed: Friday, July 15, 2005 | ||||
| |||||