"I’m not sure how that would work since .S has no idea what you think
should be on the stack at any given time. It can only show you what is
there now."

It doesn't know, but it doesn't need to
... The stack has a fixed starting point. An underflowed stack's pointer
has gone beyond that point, so the stack depth becomes negative.

So what I suggested is .S could print a message if the stack depth has
become negative.

And the other thing it could do is correct the stack pointer back to it's
initial value if it has become negative.

Now since it underflowed it may have already corrupted something. So the
last bit of the suggestion was to add a little unused space past the bottom
of the stack so when you dip into it, nothing gets smacked up immediately.

Ultimately of course the answer is: keep the stack balanced. And backup
your ram to a REX bank while you're programming because everyone messes up.

Reply via email to