4 thoughts on “jsforth

  1. If you are the developer of jsForth. I wanted to thank you for writing this. If you are not, well just discard this.
    I am writing a microforth for the MSP430G2553 and use jsForth to help me with debugging my code. I think it is great.
    I have a question on your implementation of DUP
    which puts a 0 on the Data Stack rather than producing an error code. DROP produces an error code in jsForth … What’s your logic in DUP producing a FALSE flag?
    Thanks
    Terry Ballard

  2. drop produces an error if there’s nothing to drop, because the stack is empty. dup doesn’t produce an error, If stack is empty: top stack element is cached in a variable. contents of that variable is copied to stack by dup. That variable is there (but containing 0 on init) even when stack is formally empty. dup on empty stack is not a destructive operation, therefore this condition isn’t tested. drop on empty stack is potentially destructive, which is why that condition is tested for.

Comments are closed.