From 97b6b09881f94f55d0419d8557d2b00f816a18cb Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Mon, 6 Jun 2016 23:01:39 +1200 Subject: [PATCH] Functionally complete implementation. --- README.md | 26 ++++++++++---------------- src/lib_1_basic.4th | 9 +++++---- src/lib_7_vocab.4th | 11 +++++------ src/lib_8_decompiler.4th | 5 +---- src/lib_9_misc.4th | 4 ++++ 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index f14be39..c213372 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ project [JonesForth] (https://rwmj.wordpress.com/2010/08/07/jonesforth-git-repos which was an amazing read. To a large degree my package is simply a port of that project from x86 assembly + forth to julia + forth, although the mapping is in a few places non-trivial due to the fact that julia is a high level -language. A huge proportion (say 80%) of the library code in src/lib.4th is -directly copied from JonesForth. (The fact that it was possible to reuse this -code was satisfying in its own right!) I've added some additional core -definitions and modified some of the others with the eventual aim of F83 -compliance (discussed below). +language. During the bootstrapping process, a huge proportion (say 80%) of the +library code in src/lib.4th was directly copied from JonesForth. (The fact +that it was possible to reuse this code was satisfying in its own right!) Since +that time I've added a significant number of core definitions and modified some +of the others with the eventual aim of F83 compliance (discussed below). There's quite a lot to say about the implementation, especially due to its high-level grounding, but that will have to wait for another time. @@ -90,16 +90,10 @@ as makes sense given the underlying VM. (Actually, my main goal goes a bit beyond this: I want to be able to, with a couple of exceptions, be compatible with the description of forth contained in the second edition of Leo Brodie's book "Starting Forth".) I'm fairly happy with my progress so far. Of the -131 required F83 words, only 21 remain unimplemented. These words fall into -three categories: those I intend to implement in the near future, those I may -possibly implement at some point, and those that I do not intend to ever implement -for reasons of obsolescence or incompatibility with the design of the VM. - -### F83 Words to be implemented soon - - PAD - -The word `PAD` is a simple oversite. +131 required F83 words, only 20 remain unimplemented. These words fall into +two categories: those I may possibly implement at some point, and those that I +do not intend to ever implement for reasons of obsolescence or incompatibility +with the design of the VM. ### F83 Words that may be implemented someday @@ -114,7 +108,7 @@ not been interested in enough yet to get on top of. SAVE-BUFFERS UPDATE BLK HOLD LOAD FORTH-83 These words don't make sense to implement. The double-length integer words are -useless, because the smallest unit of memory in our VM is a full 64 bit +useless because the smallest unit of memory in our VM is a full 64 bit integer. For the same reason, there's no point in dealing with unsigned values just to gain access to another bit. The block I/O words don't make sense because we have access to a filesystem via the OS. diff --git a/src/lib_1_basic.4th b/src/lib_1_basic.4th index b6f75e4..bc21965 100644 --- a/src/lib_1_basic.4th +++ b/src/lib_1_basic.4th @@ -64,13 +64,14 @@ ['] LIT , , ; -\ Address containing LFA of most recent definition -: LATEST - CURRENT @ 1+ ; +\ Convert vocabulary CFA to link addr it contains +: VOCAB>LATEST + 1+ @ +; \ Compile in recursive call to current word : RECURSE IMMEDIATE - LATEST @ \ LATEST points to the word being compiled at the moment + CURRENT @ VOCAB>LATEST LINK> \ get the codeword , \ compile it ; diff --git a/src/lib_7_vocab.4th b/src/lib_7_vocab.4th index 5f13b47..99900a0 100644 --- a/src/lib_7_vocab.4th +++ b/src/lib_7_vocab.4th @@ -10,7 +10,7 @@ >link - DUP @ LATEST ! ( set LATEST to point to the previous word ) + DUP @ CURRENT @ VOCAB>LATEST ! ( set LATEST to point to the previous word ) ; \ Mark word as hidden @@ -70,11 +70,10 @@ vocabulary ROOT ; : PREVIOUS - #context @ 1 > if - 1 #context -! - else - CR ." Cannot empty search order stack!" - then + #context @ + 1 <= abort" Cannot empty search order stack!" + + 1 #context -! ; : ALSO diff --git a/src/lib_8_decompiler.4th b/src/lib_8_decompiler.4th index 90ba109..3db6766 100644 --- a/src/lib_8_decompiler.4th +++ b/src/lib_8_decompiler.4th @@ -1,12 +1,9 @@ \ Decompilation -: VCFA>LATEST - 1+ @ -; : CLOSESTLINK ( addr vcfa -- lfa ) - vcfa>latest dup ( addr link link ) + vocab>latest dup ( addr link link ) rot dup -rot ( link addr link addr ) < if 2drop diff --git a/src/lib_9_misc.4th b/src/lib_9_misc.4th index 9078fc4..77776c8 100644 --- a/src/lib_9_misc.4th +++ b/src/lib_9_misc.4th @@ -24,5 +24,9 @@ then ; +( Stractch pad. ) +: PAD ( -- addr ) + HERE 340 + ; + : UNUSED ( -- cells ) MEMSIZE HERE - ; -- 2.20.1