gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > which RAM to use

#134523 - cuse - Fri Jul 13, 2007 4:20 pm

Hi!

Is there a way to tell gcc which one of the various RAMs it shall use for certain data?

For example I just tried to add an additional, global array in my application C code:

Code:
unsigned char foo_buffer[SCREENWIDTH][SCREENHEIGHT];


thus a memory space of 38kB, but that causes that array to overlap with other, already occupied memory areas of the GBA. I guess because gcc puts global variables into the small, internal RAM, which is limited to 32kB.

Can I tell gcc to use the external RAM for that array instead? Probably some kind of gcc __attribute__() ?

#134532 - PeterM - Fri Jul 13, 2007 6:32 pm

I'm pretty sure there is an attribute to do this, but I'm sorry, I can't remember what it is.

I believe it changes the "section" the function/variable goes into. You may want to do a search for "attribute section" or something like that.

Hope this helps.
_________________
http://aaiiee.wordpress.com/

#134541 - gauauu - Fri Jul 13, 2007 7:28 pm

Try

Code:
__attribute__((section(".ewram")))


Like

Code:
__attribute__((section(".ewram")))  int yourData


Although I prefer to use a macro/define to make things prettier....

#134543 - cuse - Fri Jul 13, 2007 8:20 pm

Yes, that did it! Thanks a lot!