diff --git a/apps/forth/dict.asm b/apps/forth/dict.asm index 3da919f..2af2fcb 100644 --- a/apps/forth/dict.asm +++ b/apps/forth/dict.asm @@ -165,9 +165,28 @@ abortUnderflow: .msg: .db "stack underflow", 0 + .db "ABORT", '"' + .fill 1 + .dw ABORT + .db 1 ; IMMEDIATE +ABORTI: + .dw compiledWord + .dw PRINTI + .dw .private + .dw EXIT + + .db 0b10 ; UNWORD +.private: + .dw nativeWord + ld hl, (HERE) + ld de, ABORT + call DEinHL + ld (HERE), hl + jp next + .db "BYE" .fill 4 - .dw ABORT + .dw ABORTI .db 0 BYE: .dw nativeWord diff --git a/apps/forth/dictionary.txt b/apps/forth/dictionary.txt index a2fc6e2..17db2dd 100644 --- a/apps/forth/dictionary.txt +++ b/apps/forth/dictionary.txt @@ -73,6 +73,8 @@ input stream is executed immediately. In this context, branching doesn't work. atom's cell. (bbr) -- Branches backward by the number specified in its atom's cell. +ABORT -- Resets PS and RS and returns to interpreter +ABORT" x" -- *I* Compiles a ." followed by a ABORT. AGAIN I:a -- *I* Jump backwards to preceeding BEGIN. BEGIN -- I:a *I* Marker for backward branching with AGAIN. ELSE I:a -- *I* Compiles a (fbr) and set branching cell at a.