From 8186511727724ae9efafad37eae4f25c48e1bcc0 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 30 Mar 2020 13:50:53 -0400 Subject: [PATCH] forth: fix bootstrapping issues with "LITN" and "+" --- emul/forth/z80c.bin | Bin 1276 -> 1276 bytes forth/icore.fs | 25 ++++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index b5545dd8bb25e959a88cea4ded9bd0229969d72c..801370e9304867000f62405b1436c2223bc7a700 100644 GIT binary patch delta 76 zcmV-S0JH!63H%ALp#lXW6w(V;v!((!0SG8%Zgg^aDJ_%y1Fj-)3PA!)NmNch00a&I i#swe%7yu^+2m=TMK>|7v0D%qwE|awcDFNk^-vk|Gl@vYz delta 76 zcmV-S0JH!63H%ALp#lXE6u=8av!((!0Uu0BR8A@Y1P%bk1t0(z04E0s0|)~_0w`r} ibaHtq7n9`!t_z0>K>|8F0D%qwMU%AzDFG{!-vk{2f)ix` diff --git a/forth/icore.fs b/forth/icore.fs index 2ae132d..230fc44 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -17,6 +17,12 @@ properly stabilized. 4. Make sure that the words you compile are not overridden by the full interpreter. + 5. When using words as immediates, make sure that they're + not defined in icore or, if they are, make sure that + they contain no "_c" references. + + All these rules make this unit a bit messy, but this is the + price to pay for the awesomeness of self-bootstrapping. ) ( When referencing words from native defs or this very unit, @@ -49,7 +55,10 @@ , ( write! ) ; IMMEDIATE -: QUIT 0 FLAGS ! _c (resRS) LIT< INTERPRET (find) DROP EXECUTE ; +: QUIT + 0 FLAGS ! _c (resRS) + LIT< INTERPRET (find) DROP EXECUTE +; : ABORT _c (resSP) _c QUIT ; @@ -116,12 +125,6 @@ [ JTBL 30 + @ LITN ] ; -: LITN - ( JTBL+24 == NUMBER ) - JTBL 24 _c + , - , -; - : (entry) HERE @ ( h ) _c WORD ( h s ) @@ -159,6 +162,14 @@ _c INTERPRET ; +( LITN has to be defined after the last immediate usage of + it to avoid bootstrapping issues ) +: LITN + ( JTBL+24 == NUMBER ) + JTBL 24 _c + , + , +; + ( : and ; have to be defined last because it can't be executed now also, they can't have their real name right away )