We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to write a function (ARM) that will run in a different initial RAM addresses. Part of the program in ASM, and part of C. The problem is that variables declared in the ASM, as seen in C are still in the same address.
EXP:
in asm file:
test_val dcd 0x5555555 export test_val BLX main_c_code
in C file:
extern int test_val; void main_c_code(void){ ... test_val = 0xAAAAAAAA; ... }
after build everything works, when it loads the applications to address eg 0x1000 (default) test_val is at addr. eg. 0x1004 but when you want to load applications to address eg 0x2000, Part C test_val still fits the data to addr 0x1004 instead of 0x2004. how to force the compiler to the use of
ADR R0, test_val
instead of
LDR R0, = 0x4
I ran into a similar problem before and I was also told to use scatter file (please read forums.arm.com/index.php). Using a scatter file is the right solution, but for my problem, we had to write a bootloader because of some other hardware requirement. In any case, instead of using variables scattered around, put all of them in a struct and access them from there. This way, you have to deal with only 1 address. Good Luck :-)