Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Memory Management   Message List  
Reply | Forward Message #13815 of 15019 |
Re: [gbadev] Memory Management

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/





Thu Mar 13, 2003 11:57 am

dooby@...
Send Email Send Email

Forward
Message #13815 of 15019 |
Expand Messages Author Sort by Date

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...
Wendy
nekowendy
Offline Send Email
Mar 13, 2003
10:07 am

Depends entirely on what method you are using to allocate RAM in the first place. The GBA itself has no concept of "allocated" memory. You didn't even say if...
Jonathan Perret
jonathan.perret@...
Send Email
Mar 13, 2003
11:42 am

... 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...
Pete
dooby@...
Send Email
Mar 13, 2003
12:06 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help