Reading a value from an address, using an array

ErnieM

Joined Apr 24, 2011
8,415
Once you compile and link your code the addresses of static variables are fixed, and yes can be discovered via the & opperator.

Placing a variable at a specific programmer defined address may be possible depending on the platform the code is run on. The GNC C compiler provides the __attribute__ Keyword to inform the linker which section to place a variable. This would also entail a custom link script to define this area.
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,366
By my opinion, a defined address means on a specific address that you want to set. If I run the application multiple times, will the array be put on the same addresses every time?
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,366
The problem is that I dont know will it change. I dont know the platform also, like you see its not written or very clear, so lets say Microsoft Windows 7 Enterprise.

"C" has automatic addressing unlike assembler, so will the compiler put the array on the same place every time? Otherwise an "unsigned int array[12]" will do.
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,366
I am sorry for the nerves. But I need to know in detail, because "int array [12]" will be put in the RAM memory for initialization and the "const unsigned int array [12]" will be put in the ROM memory as a lookup table of the "retlw" instruction, because the compiler knows it will never change.
 
Top