Top of the stack

Other misc things
Post Reply
vmorilla
Member
Posts: 13
Joined: Sun Feb 11, 2024 7:15 pm

Top of the stack

Post by vmorilla »

Is there any symbol I could reliably use to point to the "top of the stack"? This would be helpful to simplify DeZog configuration files: DeZog requires a parameter with information of the top of the stack to show the call stack window. Currently, I'm just passing the address that corresponds to the CRT configuration, but it would be much nicer to pass a symbol.

I see "__register_sp" might be a good candidate (at least in zx spectrum targets), but I haven't seen any documentation about it.

Thanks!
User avatar
dom
Well known member
Posts: 2277
Joined: Sun Jul 15, 2007 10:01 pm

Re: Top of the stack

Post by dom »

That symbol is probably the closest you‘ll get IF the stack has been set. The setting of sp is here: https://github.com/z88dk/z88dk/blob/mas ... nit_sp.inc

There are ways of walking the frame at runtime using ix eg see cmd_backtrace here: https://github.com/z88dk/z88dk/blob/mas ... er.c#L1275
vmorilla
Member
Posts: 13
Joined: Sun Feb 11, 2024 7:15 pm

Re: Top of the stack

Post by vmorilla »

That symbol is probably the closest you‘ll get IF the stack has been set. The setting of sp is here: https://github.com/z88dk/z88dk/blob/mas ... nit_sp.inc
That should be the case for most targets / CRTs, right?
User avatar
dom
Well known member
Posts: 2277
Joined: Sun Jul 15, 2007 10:01 pm

Re: Top of the stack

Post by dom »

Yes. From memory most of them set sp to an absolute address.
vmorilla
Member
Posts: 13
Joined: Sun Feb 11, 2024 7:15 pm

Re: Top of the stack

Post by vmorilla »

Thanks!
Post Reply