GARTHWILSON wrote:
scotws wrote:
It's the legal (!) empty status that can be the real problem. Some words like 1+ only work if there is a non-empty stack; SWAP needs at least two entries, ROT even three. We can either accept those errors silently (which is fastest) or check in the word itself (which takes longer).
Quote:
After all the intended execution of a word being tested, any empty-stack condition is caught by INTERPRET with ABORT" Empty stack". This is only in development, and is never needed after development is completed, and has no effect on execution speed. You could still mess it up with something like 5 ROLL but how often are you going to do that and have inadequate depth? In my 25+ years of playing with this, I've never had the problem.
Code: Select all
CODE 2DROP
INX, INX,
// DROP's CFA POINTS HERE
INX, INX,
NEXT 0< NOT BRAN, // branch to next if no underflow
80 # LDX, // limit the underflow
NEXT JMP, END-CODE
Edit: Forgot to mention that the X register is the data stack pointer and when the stack is empty X has the hexadecimal value 7E.