#26216 - pan69 - Thu Sep 09, 2004 6:26 pm
If I understood correctly, the stack grows down from the top in IWRAM. I was wondering if it was possible to generate an interrupt of some sort when a stack overflow happens at a set stack limit, say 1K.
Thanks!
- Pan
#26227 - torne - Thu Sep 09, 2004 9:06 pm
Nope. What you can do is have a canary value (a few bytes with a known value) and check that it's still intact in each iteration of your main loop. If you put the canary far enough away from the end of the stack you'll get a warning when you have used more than that much stack space, but before the stack actually runs out (hopefully).
#26236 - tepples - Fri Sep 10, 2004 12:50 am
If you are running your GBA program in a debugging emulator, you can set a watch on writes to the address 1024 bytes below the base of the stack. This would be 0x03fffc00 or 0x03007fc0 depending on how your crt0 sets up the stack.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#28375 - sasq - Sat Oct 30, 2004 12:17 pm
OR you could put the stack at the beginning IWRAM so that when the stackptr wraps from 03000000 to 02FFFFFF it will give an exception.
#33366 - pan69 - Sun Jan 02, 2005 2:42 pm
Quote: |
OR you could put the stack at the beginning IWRAM so that when the stackptr wraps from 03000000 to 02FFFFFF it will give an exception. |
But that would use up all of IWRAM for stack usage. Me not want. :)
- Pan
#33374 - Lupin - Sun Jan 02, 2005 6:21 pm
Another idea would be to put the stack into EWRAM, that would of course slow down execution but if your code heavily depends on a large stack that might be the only solution.
_________________
Team Pokeme
My blog and PM ASM tutorials
#33460 - Miked0801 - Mon Jan 03, 2005 8:45 pm
Are you overflowing your stack in code?
#33494 - sasq - Tue Jan 04, 2005 2:44 pm
pan69 wrote: |
Quote: | OR you could put the stack at the beginning IWRAM so that when the stackptr wraps from 03000000 to 02FFFFFF it will give an exception. |
But that would use up all of IWRAM for stack usage. Me not want. :)
- Pan |
Why? Just use the space above the stack. like the stack goes from 03001000 -> 03000000 and down and you can use iwram 03001000 -> 03007FFF for normal stuff.
If you use a linkscript you need to change iwram start though.