Fix interactive dodoes, fix multiply, fix tests
[preForth.git] / README.md
1 # Bootstrapping Forth
2
3 ## preForth
4
5 preForth is a minimal non-interactive Forth kernel that can bootstrap itself and can be used as an easy-to-port basis for a full Forth implementation.
6
7 preForth feels like Forth - it's mainly a sublanguage of ANS-Forth - but is significantly reduced in its capabilities.
8
9 ### Features: minimal control structures, no immediate words, strings on stack, few primitives
10
11 just
12
13 - Stack
14 - Returnstack
15 - Only ?exit and recursion as control structures
16 - :-definitions
17 - optional tail call optimization
18 - IO via KEY/EMIT
19 - signed single cell decimal numbers (0-9)+
20 - character constants via 'c'-notation
21 - output single cell decimal numbers
22
23 and
24
25 - no immediate words, i.e.
26 - no control structures IF ELSE THEN BEGIN WHILE REPEAT UNTIL
27 - no defining words
28 - no DOES>
29 - no memory @ ! CMOVE ALLOT ,
30 - no pictured numeric output
31 - no input stream
32 - no state
33 - no base
34 - no dictionary, no EXECUTE, not EVALUATE
35 - no CATCH and THROW
36 - no error handling
37
38 ### Prerequisites:
39
40   Just 13 primitives: emit key dup swap drop 0< ?exit >r r> - nest unnest lit
41
42 ## seedForth
43
44 seedForth is an extended system with random access memory, control structures, compiling and defining words. Its kernel the so called *seedForth bed* is built using preForth. Seed Forth bed has about 30 primitives as well as a compiler and interpreter. 
45
46 seedForth accepts source code in tokenized source code form (.seed files). the seedForth tokenizer reads text source code (.seedsource files) and converts them to token form. 
47
48 You can create applications by writing the appropriate seedForth text source code, tokenize it using the tokenizer (`make xxx.seed`) and then feed the token source code into the seedForth bet (`cat xxx.seed | ./seedForth`) in order to let the application grow.
49
50 On of these applications is seedForth/interactive.
51
52 ## seedForth/interactive
53
54 seedForth/interactive extends seedForth to become a full featured interactive Forth system. For this it defines a searchable dictionary of (text based) headers and a text based interpreter and compiler.
55 On startup seedForth/interactive accepts Forth source code in text form.
56
57 # How to use:
58
59 An i386-Backend (32Bit) indirect threaded code implementation based on [FASM](https://flatassembler.net/) is pre-configured.
60 PreForth initially bootstraps on with [gforth](https://www.gnu.org/software/gforth/) or [swiftForth](https://www.forth.com/swiftforth/). 
61 You'll need one of these for the first bootstrap.
62
63     cd preForth
64     make
65
66 This will successively compile preForth, seedForth then seedForth/interactive.
67
68 If successful issue
69
70     $ ./seed
71     
72 and seedForth/interactive will start up showing
73     
74     ..................................................
75     .
76     seedForth/interactive 2.2.0
77     ---------------------------
78     380005 bytes free
79  
80 and more test output. Tweek `hi.forth` as desired.
81
82 Inspect sources and generated files.
83
84 *Have fun. May the Forth be with you.*
85