#8178 - Alunze - Thu Jul 03, 2003 9:50 pm
The situation is this: I have two .c files I want to link together. My problem is that both, among other thigs, declare an array, and when I link them, in the resulting program the arrays overlap themselves (share memory positions). What could be causing this and/or what could I do to prevent this from happening?
Thanks in *advance* >_6
#8180 - niltsair - Thu Jul 03, 2003 9:55 pm
How big are your arrays? The Gba only has 32kb of Ram and 256kb of external Ram.
#8186 - Alunze - Fri Jul 04, 2003 12:39 am
Well they aren't that big, one weights 2400 bytes and the other 1204.
Wait, you weren't really wrong. Those arrays aren't very big, but I have other which is no less than 48000 bytes long. This one should really reside in ROM, but I kept it in RAM provisionally.
What takes me to think: if variables are stored in internal RAM and the compiler/linkscript/whatever doesn't check if the 32K limit is surpassed, how could I allocate things in external RAM in case I needed room for mode data?
Thanks for the hint niltsair :).
#8190 - Cyberman - Fri Jul 04, 2003 2:41 am
You can have a 48000 "byte" sized easily in the GBA. However it behoves one to use ones resources wisely in the GBA.
Anyhow use rom define the array const.
If you are putting information into the array then you can't use it as a const. Etc. if you define the array with predefined data but do not specify const it loads the data from ROM into memory.
IRAM is generally used for local variables (for functions) and the stack.
WRAM is generally used for things you allocate such has big arrays etc.
Cyb
#8193 - niltsair - Fri Jul 04, 2003 4:01 am
Code: |
#define IN_EWRAM __attribute__ ((section (".ewram")))
u16 gWorkPic[38400] IN_EWRAM; |
Take note that External Ram has a much slower access speed.