|
|||||||||||
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?
ANSWERUse the following line in your assembly code. It is the equivalent of a C 'extern' declaration for the global variable:
You can easily determine what the equivalent assembler code is for your C code by getting the compiler to generate the assembler code for you. For example, to find out the assembler code required for the extern declaration you could write the following C source file:
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: Thursday, February 25, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.