From ca7c21d49f318b053259780dafe0a62bf6f1ed36 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 22 Mar 2020 22:27:54 -0400 Subject: [PATCH] forth: make "(entry)" call WORD itself Otherwise, when a defining word would be called outside a definition itself, it would get the name of the last parsed word, that is, itself! For example, dummy.fs, instead of creating a "_______" entry, created a "(entry)" entry... --- forth/core.fs | 2 +- forth/dummy.fs | 2 +- forth/forth.asm | 8 ++++++-- forth/z80a.fs | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/forth/core.fs b/forth/core.fs index ed48a4b..746ace4 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -42,7 +42,7 @@ ; IMMEDIATE : CREATE - WORD (entry) ( empty header with name ) + (entry) ( empty header with name ) ROUTINE C [LITN] ( push cellWord addr ) , ( write it ) ; diff --git a/forth/dummy.fs b/forth/dummy.fs index a6d9605..0169336 100644 --- a/forth/dummy.fs +++ b/forth/dummy.fs @@ -1,7 +1,7 @@ ( When building a compiled dict, always include this unit at the end of it so that Forth knows how to hook LATEST into it ) -WORD _______ (entry) +(entry) _______ ( After each dummy word like this, we poke IO port 2 with our current HERE value. The staging executable needs it to know diff --git a/forth/forth.asm b/forth/forth.asm index 5559714..bb59f75 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -883,7 +883,6 @@ ENDDEF: .db 1 ; IMMEDIATE DEFINE: .dw compiledWord - .dw WORD .dw ENTRYHEAD .dw NUMBER .dw compiledWord @@ -1238,6 +1237,12 @@ PARSEI: .dw $-PARSE .db 0 ENTRYHEAD: + .dw compiledWord + .dw WORD + .dw .private + .dw EXIT + +.private: .dw nativeWord pop hl ld de, (HERE) @@ -1272,7 +1277,6 @@ ENTRYHEAD: .db 0 SYSV: .dw compiledWord - .dw WORD .dw ENTRYHEAD .dw NUMBER .dw sysvarWord diff --git a/forth/z80a.fs b/forth/z80a.fs index 80b8513..6507b8f 100644 --- a/forth/z80a.fs +++ b/forth/z80a.fs @@ -2,7 +2,7 @@ : CODE ( same as CREATE, but with ROUTINE V ) - WORD (entry) + (entry) ROUTINE V [LITN] , ;