Keil Logo

C166: LOCATING VARIABLES TO FIXED ADDRESSES


Information in this article applies to:

  • C166 All Versions

QUESTION

How do I locate a global variable at a specific address?

ANSWER

To locate a C166 C global variable to a specific address...

  1. Create a C file that contains only that global variable.
  2. Compile the C file as normal.
  3. Link as normal. Review the linker map file (*.M66) and find the variable name in the "PUBLIC SYMBOLS OF MODULE" section of the map file. For example, the global variable junk_var appears as follows in the Public Symbols section:
    VALUE     PUBLIC SYMBOL NAME      REP   TGR  CLASS   SECTION NAME
    =================================================================
    000000H   RESET                   INTNO ---  ---     ---
    00AAAAH   junk_var                VAR   ---  NDATA0  ?ND0?MAIN
    000004H   main                    LABEL ---  NCODE   ?PR?MAIN
    
  4. Add a section to the linker command line that specifies the location for your global variable. For example, the section name to use for junk_var is ?ND0?MAIN%NDATA0. The linker command line to locate this sections is:
    L166 ???.OBJ  TO  OUTFILE.ABS  SECTIONS(?ND0?MAIN%NDATA0(0x006000))
    

In µVision, you may specify the section information in the Sections Tab of the Linker Options:

?ND0?MAIN%NDATA0(0x006000)

MORE INFORMATION

  • Refer to SECTIONS in the L166 User's Guide.

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

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.