Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #10331

A short history of the stages of development and status of RP's Forth interpreter.

From "Rod Pemberton" <do_not_have@noavailemail.cmm>
Newsgroups comp.lang.forth
Subject A short history of the stages of development and status of RP's Forth interpreter.
Date 2012-03-22 19:16 -0400
Organization Aioe.org NNTP Server
Message-ID <jkgbte$3f7$1@speranza.aioe.org> (permalink)

Show all headers | View raw


After a question by "Nomen Nescio", I decided to start a new thread on the
history of the development of my Forth interpreter since it may be useful to
someone else now or in the future.  It'd be nice if others whom are
developing interpreters posted their history for insights or techniques
also.

It's finally what I would consider to be a true Forth interpreter, and not a
C program.  The "to do" list gets shorter, then longer, ad infinitum ...  By
comparison with some modern Forths, it's primitive, fig-Forth like, very
basic, or not as fully developed, but it's coming along nicely now that it
can parse definitions from ASCII text.

My interpreter originally started from a backend of C parser and developed
from there.  At first, it was mostly C, not really any form of Forth.  Then,
it evolved from pure C to pre-compiled Forth words in C, much like assembly.
Then, it transmutated into most high-level words in Forth.

Currently, it's comprised of three basic parts:

a) a bunch of low-level words or primitives as the initial dictionary
b) a bunch of high-level words or definitions as ASCII text
c) a program within a program

The "program within a program" as pre-compiled Forth in C, over time and
many versions, has been (re)written entirely in terms of the primitives
which are coded in C.  So, it's really a program ("the Forth interpreters")
within a program (an ITC interpreter coded in C).  It implements the two
historical Forth interpreters: address/inner and text/outer.  The primitives
are in C, like assembly.  The interpreter program is capable of parsing
high-level words in Forth and building a dictionary.  The high-level words
were once also in terms of C or pre-compiled Forth in C, but are now mostly
as external ASCII text in a file and parsed by the interpreter.  I have a
handful, five or seven or so, that I haven't moved out of C and into ASCII
text.  Mostly, this is because I'm working on other issues with it that seem
to keep cropping up ...

IMO, I have gone through a few very critical development stages.  After
implementing the ITC interpreter core in C, I started with the fig-Forth
definitions in one of the fig-Forth standards I provided a link to.  After
deciding I liked the "Forth in Forth" using Forth primitives concept, I
studied the primitives used by about a half dozen Forths built using them to
determine: 1) what should be a primitive, and 2) a useable starting set.  I
also looked at Philip Koopman's Forth instruction frequencies to help me
decide.  Anton Ertl got similar results to Koopman for some of his work.  At
a different point in development, I modified Peter Sovietov's Forth stack
optimizer for personal use.  It's written in Javascript and IMO (almost like
C programming) is easily modified.  I also studied whether or not Rob
Chapman's stack quarks were of use.  The stack optimizer will be needed, if
you're not fluent in Forth, to determine efficient sequences for Forth's
control-flow words.

Rob Chapman's stack quarks
http://clubweb.interbaun.com/~rc/Timbre/ContentPages/Timbre/SQP/StackQuarksPaper.html

Philip Koopman's instruction frequencies
http://www.ece.cmu.edu/~koopman/stack_computers/sec6_3.html

Peter Sovietov's stack optimizer
http://forpost.sourceforge.net/forthwiz.html

My private version of Peter Sovietov's stack optimizer is far more advanced.
It's results are comparable to the RAFTS-like optimizer Bruce McFarland is
using.  For comparison, my updated version's screen looks like this:
(without checkboxes - quoted to delimit it)

"
Forth Wizard 060903, Peter Sovietov
extended by Rod Pemberton - 2008, 2010, 2012
a@ a! b@ b!
a=s[0] a=s[1] s[0]=a s[1]=a
b=s[0] b=s[1] s[0]=b s[1]=b
r> >r r@ r! rdrop
dup drop swap
over rot -rot
nip tuck drip dip nup take
2r@ 2r> 2>r
2dup 2drop 2swap
2over 2rot -2rot
2nip 2tuck
under xor
0 pick 1 pick 2 pick 3 pick 4 pick 5 pick
1 place 2 place 3 place 4 place 5 place
1 roll 2 roll 3 roll 4 roll 5 roll
1 -roll 2 -roll 3 -roll 4 -roll 5 -roll

([   ] -- [   ]) solve more clear
R([    ] -- [    ]) all none flip 30
"

My current WORDS list follows.  A few are incomplete such as CELLS or CHARS
because of needing me to implement * (star/multiply/product) as a primitive,
unimplemented such as (?DO) and ?DO etc, and or are in still in C such as
FIND .  63 words are primitives.  14 words are pre-compiled Forth words
which I'll migrate to ASCII text definitions eventually.  And, I have 5 or
so internal, headerless helper words which are not in the list.  The
definitions file in ASCII text has 117 lines of which 110 are high-level
Forth definitions.  It seems I may have a few more that are not visible
since the counts above and list below don't match exactly ...  I'll check on
that later.  None have been checked for ANS compliance.  I've gone through
115 backups over three years since I started keeping backups of it.  The C
side is currently 1861 lines of C code, including many comments, my "to do"
lists, and well spaced and formatted C.

WORDS
WORDS 'LAST TRACE ID. ? LINK> NAME> BODY> >LINK
>NAME >BODY ." S" (S") FILL ] [ [CHAR] CHAR TYPE
SPACES SPACE ALIGN ALIGNED CR VARIABLE CONSTANT
CREATE DOES> ?DUP LEAVE +LOOP (+LOOP) LOOP (LOOP)
?DO (?DO) DO (DO) UNLOOP J I REPEAT WHILE [']
[COMPILE] ' LITERAL UNTIL AGAIN BEGIN ELSE THEN
IF NEGATE INVERT 1- 1+ 2OVER 2R@ 2R> 2>R 2SWAP
2DUP 2DROP 2! 2@ C, ALLOT +! HERE CHARS CELLS
CHAR+ CELL+ TAKE NUP DIP DRIP -ROT TUCK NIP ROT
OVER SWAP DROP DUP R@ NOT TRUE FALSE SMUDGE (
IMMEDIATE B! B@ A! A@ nbSMDG nbPREC nbSIGN COLD
ABORT QUIT INTERPRET ; : (CREATE) WORD QUERY
COMPILE , 0BRANCH BRANCH TOGGLE OK XDUMP COMPARE
COUNT CMOVE C! C@ EMIT KEY 0<> 0> 0< 0= < > <> =
NUMBER - XOR OR AND EXECUTE FIND ENCLOSE TRIM
EXPECT BYE LATEST +ofsPTR +ofsDLS +ofsPFA +ofsCFA
+ofsNFA +ofsLFA szCELL szBYTE TIB NL LF BL STATE
BLK IN RP0 SP0 RP SP DP0 DP LAST B A LIT . +
! @ R> >R DODOES DOVAR ENTER EXIT



Rod Pemberton



Back to comp.lang.forth | Previous | NextNext in thread | Find similar


Thread

A short history of the stages of development and status of RP's Forth interpreter. "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-22 19:16 -0400
  Re: A short history of the stages of development and status of RP's Forth interpreter. jacko <jackokring@gmail.com> - 2012-03-23 00:38 -0700
    Re: A short history of the stages of development and status of RP's Forth interpreter. jacko <jackokring@gmail.com> - 2012-03-23 00:56 -0700
  Re: A short history of the stages of development and status of RP's For  interpreter. Nomen Nescio <nobody@dizum.com> - 2012-03-23 12:53 +0100
    Re: A short history of the stages of development and status of RP's For  interpreter. "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-23 20:44 -0400
      Re: A short history of the stages of development and status of RP's For  interpreter. Nomen Nescio <nobody@dizum.com> - 2012-03-25 10:30 +0200
        Re: A short history of the stages of development and status of RP's For  interpreter. "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-25 06:05 -0400
          Re: A short history of the stages of development and status of RP's Nomen Nescio <nobody@dizum.com> - 2012-03-27 03:03 +0200
            Re: A short history of the stages of development and status of RP's "Elizabeth D. Rather" <erather@forth.com> - 2012-03-26 15:39 -1000
              Re: A short history of the stages of development and status of RP's Fritz Wuehler <fritz@spamexpire-201203.rodent.frell.theremailer.net> - 2012-03-28 11:18 +0200
                Re: A short history of the stages of development and status of RP's "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-30 07:04 -0400
                Re: A short history of the stages of development and status of RP's Fritz Wuehler <fritz@spamexpire-201203.rodent.frell.theremailer.net> - 2012-03-30 19:24 +0200
                Re: A short history of the stages of development and status of RP's Paul Rubin <no.email@nospam.invalid> - 2012-03-30 13:00 -0700
                Re: A short history of the stages of development and status of RP's "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-30 18:06 -0400
                Re: A short history of the stages of development and status of RP's Fritz Wuehler <fritz@spamexpire-201204.rodent.frell.theremailer.net> - 2012-04-02 16:39 +0200
                Re: A short history of the stages of development and status of RP's Paul Rubin <no.email@nospam.invalid> - 2012-04-02 15:37 -0700
                Re: A short history of the stages of development and status of RP's BruceMcF <agila61@netscape.net> - 2012-04-02 16:59 -0700
          Re: A short history of the stages of development and status of RP's Fritz Wuehler <fritz@spamexpire-201203.rodent.frell.theremailer.net> - 2012-03-27 13:08 +0200
      Re: A short history of the stages of development and status of RP's For  interpreter. anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-26 08:58 +0000
  Re: A short history of the stages of development and status of RP's Forth interpreter. Fanzo <cristianof6@gmail.com> - 2012-03-25 15:32 +0200
  Re: A short history of the stages of development and status of RP's Forth interpreter. "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2012-03-30 18:05 -0400
    Re: A short history of the stages of development and status of RP's Forth interpreter. "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-04-02 05:08 -0400

csiph-web