Discussion Forum

Absolute location of constant tables in code space

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
josh lifton
Posted
13-Jan-2002 21:07 GMT
Toolset
C51
New! Absolute location of constant tables in code space
I'm looking for a way to absolutely locate a constant array in code space using the C51 compiler. I can use the 'code' memory location specifier to indicate the array should be located in program memory. For example:
int code arrayOfPrimes[3] = {2, 3, 5};
I can also use the '_at_' specifier to locate an array at an absolute memory address. For example:
int arrayOfPrimes[3] _at_ 0x80;
arrayOfPrimes[0] = 2;
arrayOfPrimes[1] = 3;
arrayOfPrimes[2] = 5;
However, I can't use both specifiers together in any meaningful way. This is because locating an array in code space requires that I initialize the array as I declare it (I can't change it in the program because it is in ROM). However, I can't initialize the array because the '_at_' specifier doesn't allow it for some reason. Thus:
/* This won't work! */
int code arrayOfPrimes[3] _at_ 0x80 = {2, 3, 5};
/* This works but is meaningless because I can't initialize the array. */
int code arrayOfPrimes[3] _at_ 0x80;
Any suggestions on how to get around this?

Thanks,
josh
Read-Only
Author
Andrew Neil
Posted
13-Jan-2002 21:36 GMT
Toolset
C51
New! RE: Absolute location of constant tables in code space
Use the Search (look left) - this has been discussed many times before!
Read-Only
Author
josh lifton
Posted
14-Jan-2002 04:54 GMT
Toolset
C51
New! RE: Absolute location of constant tables in code space
Hmm... I did try searching before hand, but didn't come up with anything. Another post points to how to do this using the linker. I saw this in the manual, but I was trying to avoid coding on the linker level.

Thanks for the pointer.

josh
Read-Only
Author
Andrew Neil
Posted
14-Jan-2002 09:55 GMT
Toolset
C51
New! RE: Absolute location of constant tables in code space
Why do you need to avoid Linker options?

The altetnative is to do it in Assembler.
Read-Only
Author
Jon Ward
Posted
13-Jan-2002 22:18 GMT
Toolset
C51
New! RE: Absolute location of constant tables in code space
Take a look at:

http://www.keil.com/support/docs/130.htm

Jon
Read-Only
Author
Andrew Neil
Posted
14-Jan-2002 08:31 GMT
Toolset
C51
New! RE: Absolute location of constant tables in code space
Jon,

I think you should include that one in your Top Ten Q&A
http://www.keil.com/support/topten.asp
Read-Only
Author
Jon Ward
Posted
14-Jan-2002 18:05 GMT
Toolset
C51
New! RE: Absolute location of constant tables in code space
The top-ten list is updated every day.

It is automatically generated based on which ones are used most frequently in a 3-month period to answer technical questions.

Jon

Next Thread | Thread List | Previous Thread Start a Thread | Settings