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 > Where in memory?

#2164 - Grumps - Thu Jan 30, 2003 11:34 am

A few Qs.
When you compile under HAM or devkitadv, are the binary output files directly runnable(?) in a flash cart?
Whereabouts in GBA memory do variables go? Are these automatically handled (and that goes for the stack too)?
Should all chunks of memory be malloc'd or is it safe to use hard pointers?
Why does my head hurt?
TIA.

#2171 - Splam - Thu Jan 30, 2003 1:12 pm

Not sure about HAM or DevkitAdv cuz I don't use them BUT it all probably depends on what flash software you use, some supposedly fixes up the rom header for you as it flashes and so will run directly on hardware, I have to run gbafix on my rom files else they won't work on hardware.

Variables, depends where you tell them to go (probably in makefile) with the sections commands -T text bss etc but once again, could be different on HAM or Devkit.

I wouldn't personally recommend using malloc on ANY console (and this is a personal choice) because of the fixed ram you SHOULD really know how much ram you're using for variables etc (make a map file) and how much you're allocating, if it's too big malloc will fail anyway and you're stuck PLUS malloc causes memory fragments. If you really need to use it then write your own, can be much nicer, I did one which I use sometimes which allows "shuffling" of the allocated areas when there is spare time (when fading screens or something) just moves all the allocated areas around to remove fragments.

Stack is usually set up in crt0, also some crt0.s set up predefined variables for you (copy to ram etc) and some don't, make sure you know if yours does or not else you could have problems ;)

Your head hurts because... well, could be one of many things ;)