LD SP,????

Post Reply
User avatar
mz-80a
Posts: 403
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

LD SP,????

Post by mz-80a »

Hi,

Just wondered, when you're writing your assembly programs, is it acceptable to use LD SP,$10F0 ? i.e. use the Monitor's work area as a stack? Or should this be avoided?
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
https: //mz-sharpworks.co.uk/
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: LD SP,????

Post by hlide »

That's a valid setting because there are some room before $10F0 for a small stack. Obviously, if you are programming a recursive code or need larger stack, you'll need to point SP somewhere else.
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: LD SP,????

Post by hlide »

At least, when just calling monitor routines in your code and using static variables, it should be enough. But for more elaborate, I will set SP somewhere else.
User avatar
mz-80a
Posts: 403
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Re: LD SP,????

Post by mz-80a »

Thanks. That's what I thought anyway. I didn't want to find myself overwriting anything that the Monitor would use the stack for. But I guess if you are resetting the SP to $10F0 like this then the Monitor routines won't change it at all and it'll all just be used correctly.
hlide wrote: Wed Sep 29, 2021 7:54 pm At least, when just calling monitor routines in your code and using static variables, it should be enough. But for more elaborate, I will set SP somewhere else.
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
https: //mz-sharpworks.co.uk/
Post Reply