On Mon, Mar 29, 2021 at 11:25 AM Alex ... <abortretryf...@gmail.com> wrote:

> Cool, so newbie mistakes and ignorance. As long as my computer's working
> properly. :)
>
> What threw me off is in the book, (pg.25) it talks about returning usually
> 0 and printing STACK EMPTY, which is definitely not how the machine behaved
> when trying it.
>
> I don't expect everything to have bounds checking, but I'm using .S a lot
> to inspect the stack, so having to reset the machine all the time and start
> over kind of sucks. If I knew more about the system maybe I could rewrite
> .S to know if it's looking at the stack or what's underneath?
>

Modifying .S to indicate a stack underflow error would be reasonable. It's
a debugging tool, and not used by programs so it doesn't impact performance.

Modifying stack operations with underflow guards would be prohibitively
expensive performance-wise given Forth is a "stack machine" language and
our 80C85 isn't a speed demon by any stretch of the imagination.

A compromise would be to add underflow checking/correction to .S, and add a
few cells of space beyond the stack to allow it to underflow a little
without causing damage.

-- John.

Reply via email to