#80075 - thegamefreak0134 - Tue Apr 18, 2006 5:18 pm
Is there an easy way to figure out what memory address a variable will end up being when it is declared? The variables I need to monitor are all declared before the main loop, so their positions should be the same throughtout the entire program. What would be nice is if the compiler could tell me this. Is such a feature available?
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#80083 - poslundc - Tue Apr 18, 2006 5:56 pm
thegamefreak0134 wrote: |
Is there an easy way to figure out what memory address a variable will end up being when it is declared? The variables I need to monitor are all declared before the main loop, so their positions should be the same throughtout the entire program. What would be nice is if the compiler could tell me this. Is such a feature available? |
The addresses of your global variables are undetermined until such time as your program is linked by the linker.
You can get the linker to generate a map file ("-Map filename_to_create" on the command line) or use the "nm" binutil with the "-n" flag on your .elf file to get a numerically-ordered listing of your memory addresses and the corresponding symbols.
Alternatively, if you're not using EWRAM for anything (or if you have a heap that starts at the end of EWRAM), I sometimes just stick the address I'm looking for at the beginning of EWRAM, which can then be looked up in VBA very easily:
Code: |
*(u32 *)0x02000000 = (u32)&myVar; |
Dan.
#80103 - Cearn - Tue Apr 18, 2006 8:21 pm
poslundc wrote: |
You can get the linker to generate a map file ("-Map filename_to_create" on the command line) |
"-Wl,-Map,mapname" to be precise. The "-Wl" is required to indicate to gcc that what comes after it is a linker flag, not a compiler flag.
poslundc wrote: |
Alternatively, if you're not using EWRAM for anything (or if you have a heap that starts at the end of EWRAM), I sometimes just stick the address I'm looking for at the beginning of EWRAM, which can then be looked up in VBA very easily:
Code: | *(u32 *)0x02000000 = (u32)&myVar; |
|
This will work for any section of memory, not just ewram. Unless you're using bytes, you can also dump them into the palette, VRAM, OAM if you have room to spare.
#80165 - thegamefreak0134 - Wed Apr 19, 2006 1:34 pm
Will this work with any linker or just DevKitPro?
_________________
What if the hokey-pokey really is what it's all about?
[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]
#80172 - tepples - Wed Apr 19, 2006 2:19 pm
It will work with any GNU linker, but perhaps not with the ARM SDT/ADS linker.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.