On Wed, 12 Mar 2003, Wendy wrote:
> Is there anyway of keeping track of how much memory is being
> currently used on the GBA? Most of my data resides in ROM and i'm
> trying no to allocate anything dynamically if I can help it. Is there
> a way to keep track of the amount of RAM that i'm currently using?
You can keep track of how much the stack pointer has extended downwards to
guage how much space you're using for local variables and such. You should
be able to get the start value from your crt0.S or linker script (probably
~0x03007f00) and you can get the stack pointer by calling a function like
this:
void stack(void) {
unsigned int sp;
asm("mov %0, sp" : "=r" (sp));
printf("sp: %p\n", (void *)sp); // modify to output where/how you want
}
This will give you the stack pointer of whatever CPU mode you're in when
you call it, so don't call it from interrupt handling code if you want
the user mode stack pointer.
HTH, Pete
--
http://www.bits.bris.ac.uk/dooby/