| |||||
Technical Support Support Resources
Product Information | BL51: INITIALIZING & LOCATING A VARIABLE TO A FIXED ADDRESSInformation in this article applies to:
QUESTIONCan I direct my initialized constant string to a specific location? I tried using the _at_ keyword in C51, but I can't initialize this variable and locate it at a fixed address. ANSWERYes. To initialize and locate a constant string, place the string in a file by itself. Then, use the linker to locate it at the address you want. For example: create the following file called TAB1.C:
unsigned char code tab1 [] = { 1, 2, 3, 4, 5, 0 };
When you compile this file, the compiler creates a segment named ?CO?TAB1. This indicates that the data is stored in the code area and the source file is named TAB1. On the linker command line, specify BL51 ... CODE(?CO?TAB1(08000h)) ... to locate this array at address 8000h. In µVision...
This also locates the table at 8000h. Refer to the 8051 Utilities User's Guide for more information. Note that this will work for variables located in XDATA, DATA, and IDATA as well as those located in the CODE area. MORE INFORMATION
SEE ALSO
FORUM THREADSThe following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Tuesday, March 27, 2007 | ||||
| |||||