Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
df227c7
Add .gitignore, rationalize make clean, remove a gforth warning in to…
nick-lifx Apr 22, 2022
56c4dcf
Remove .$(UNIXFLAVOUR) extension and file copies in favour of ifeq (G…
nick-lifx Apr 22, 2022
a2e4911
Remove redundant stuff in the preForth-generated asm code
nick-lifx Apr 22, 2022
cb3ba98
Use tabs in preForth-i386-rts.pre and seedForth-i386.pre, improve con…
nick-lifx Apr 22, 2022
fa4f0c2
Rationalize how cr is emitted in generated preForth code, make DB/DD …
nick-lifx Apr 22, 2022
927ca5a
Rationalize the sections in assembly output, make code be compiled in…
nick-lifx Apr 22, 2022
77b48fe
Split seedForth-i386.pre into machine dependent/less machine dependen…
nick-lifx Apr 22, 2022
f843d08
Split seedforth-i386.pre further into header and body portions
nick-lifx Apr 22, 2022
cdd8686
Remove duplicated code in seedForth-i386.pre, take from preForth-i386…
nick-lifx Apr 22, 2022
c962f42
Implement built-in "cat" functionality in preForth/seedForth for read…
nick-lifx Apr 23, 2022
ebf5bfa
Make key? use fdin instead of always STDIN_FILENO, and use poll() not…
nick-lifx Apr 23, 2022
d48d34a
Rationalize seedForth-tokenize.fs so that seedsource no longer has to…
nick-lifx Apr 23, 2022
375ab0f
Move most code from seedForthInteractive.seedsource into seedForthRun…
nick-lifx Apr 23, 2022
8da6c87
Rationalize how echo is handled during the seedForthInteractive loadi…
nick-lifx Apr 23, 2022
62bcae1
Split out control flow words and a few others from hi.forth into runt…
nick-lifx Apr 23, 2022
78426fc
Make ./seedForth-tokenizer self hosting (works, but hangs after token…
nick-lifx Apr 23, 2022
cbfdac8
Remap tokens so that EOT is no longer a seedForth token, detect EOT e…
nick-lifx Apr 24, 2022
caac682
Implement eot token similar to the old bye token (so we can compile b…
nick-lifx Apr 24, 2022
75138c3
Implement a new preForth/seedForth token eemit which is like emit but…
nick-lifx Apr 24, 2022
7115f49
Implement DO/?DO/LOOP, as experimental ?DO didn't have a correct comp…
nick-lifx Apr 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.asm
*.o
*.seed
/preForth/preForth
/preForth/seedForth
/preForth/__temp__.fs
128 changes: 87 additions & 41 deletions preForth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ HOSTFORTH=gforth
# ------------------------------------------------------------------------

.PHONY=all
all: preForth seedForth seedForthDemo.seed seedForthInteractive.seed
all: \
preForth \
seedForth \
seedForthDemo.seed \
seedForthBoot.seed \
seedForthInteractive.seed

.PHONY=test
test: runseedforthdemo runseedforthinteractive

.PHONY=runseedforthdemo
runseedforthdemo: seedForth seedForthDemo.seed
cat seedForthDemo.seed | ./seedForth
./seedForth seedForthDemo.seed

.PHONY=runseedfortinteractive
runseedforthinteractive: seedForth seedForthInteractive.seed
Expand All @@ -25,52 +30,66 @@ runseedforthinteractive: seedForth seedForthInteractive.seed
UNIXFLAVOUR=$(shell uname -s)
EXT=asm

seedForth-i386.asm: seedForth-i386.pre preForth
cat seedForth-i386.pre | ./preForth >seedForth-i386.asm

# preForth connected to stdin - output to preForth.asm
preForth.asm: preForth.pre preForth-i386-backend.pre load-i386-preForth.fs
cat preForth-i386-rts.pre preForth-rts.pre preForth-i386-backend.pre preForth.pre \
| $(HOSTFORTH) load-i386-preForth.fs >preForth.asm

preForth: preForth.$(UNIXFLAVOUR)
cp preForth.$(UNIXFLAVOUR) preForth

%.asm: %.pre preForth preForth-i386-rts.pre preForth-rts.pre
cat preForth-i386-rts.pre preForth-rts.pre $< | ./preForth >$@

%: %.$(UNIXFLAVOUR)
cp $< $@

preForth.asm: \
preForth-i386-rts.pre \
preForth-rts.pre \
preForth-i386-backend.pre \
preForth.pre \
load-i386-preForth.fs
cat \
preForth-i386-rts.pre \
preForth-rts.pre \
preForth-i386-backend.pre \
preForth.pre \
|$(HOSTFORTH) load-i386-preForth.fs >preForth.asm

%.asm: %.pre preForth-i386-rts.pre preForth-rts.pre preForth
./preForth preForth-i386-rts.pre preForth-rts.pre $< >$@

ifeq ($(UNIXFLAVOUR),Linux)
# assemble and link executable on linux
%.Linux: %.asm
%: %.asm
fasm $< $@.o
LDEMULATION=elf_i386 ld -arch i386 -o $@ \
-dynamic-linker /lib32/ld-linux.so.2 \
/usr/lib/i386-linux-gnu/crt1.o /usr/lib/i386-linux-gnu/crti.o \
$@.o \
-lc /usr/lib/i386-linux-gnu/crtn.o
-dynamic-linker /lib32/ld-linux.so.2 \
/usr/lib/i386-linux-gnu/crt1.o /usr/lib/i386-linux-gnu/crti.o \
$@.o \
-lc /usr/lib/i386-linux-gnu/crtn.o
# rm $@.o

else
ifeq ($(UNIXFLAVOUR),Darwin)
# assemble and link executable on MacOS
%.Darwin: %.asm
%: %.asm
fasm $< $@.o
objconv -fmacho32 -nu $@.o $@_m.o
ld -arch i386 -macosx_version_min 10.6 -o $@ \
$@_m.o /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/crt1.o /usr/lib/libc.dylib
$@_m.o /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/crt1.o \
/usr/lib/libc.dylib
# rm $@.o $@_m.o
endif
endif

# run preForth on its own source code to perform a bootstrap
# should produce identical results
bootstrap: preForth preForth-i386-backend.pre preForth.pre preForth.$(EXT)
cat preForth-i386-rts.pre preForth-rts.pre preForth-i386-backend.pre preForth.pre\
| ./preForth >preForth1.$(EXT)
bootstrap: \
preForth-i386-rts.pre \
preForth-rts.pre \
preForth-i386-backend.pre \
preForth.pre \
preForth \
preForth.$(EXT)
./preForth \
preForth-i386-rts.pre \
preForth-rts.pre \
preForth-i386-backend.pre \
preForth.pre \
>preForth1.$(EXT)
cmp preForth.$(EXT) preForth1.$(EXT)

# preForth connected to stdin - output to stdout
.PHONY=visible-bootstrap
visible-bootstrap: preForth preForth-i386-backend.pre preForth.pre
cat preForth-i386-backend.pre preForth.pre | ./preForth
./preForth preForth-i386-backend.pre preForth.pre

# ------------------------------------------------------------------------
# Docker support (for Linux version)
Expand All @@ -89,16 +108,43 @@ rundocker: docker-image
# ------------------------------------------------------------------------
# seedForth
# ------------------------------------------------------------------------
seedForth.$(EXT): seedForth-i386.pre preForth
cat seedForth-i386.pre | ./preForth >seedForth.$(EXT)

seedForth: seedForth.$(UNIXFLAVOUR)
cp seedForth.$(UNIXFLAVOUR) seedForth

%.seed: %.seedsource seedForth-tokenizer.fs
gforth seedForth-tokenizer.fs $<

seedForth.$(EXT): \
seedForth-i386-header.pre \
preForth-i386-rts.pre \
seedForth-i386.pre \
seedForth.pre \
preForth
./preForth \
seedForth-i386-header.pre \
preForth-i386-rts.pre \
seedForth-i386.pre \
seedForth.pre \
>seedForth.$(EXT)

# a little ugly, because gforth insists upon echoing anything read from
# stdin, and also does not allow parsing words to cross a file boundary,
# so we will concatenate the tokenizer and source into a *.fs file first
seedForthDemo.seed: seedForth-tokenizer.fs seedForthDemo.seedsource
cat $^ >__temp__.fs
gforth __temp__.fs -e bye >$@
rm __temp__.fs

seedForthBoot.seed: \
seedForth-tokenizer.fs \
seedForthRuntime.seedsource \
seedForthBoot.seedsource
cat $^ >__temp__.fs
gforth __temp__.fs -e bye >$@
rm __temp__.fs

seedForthInteractive.seed: \
seedForth-tokenizer.fs \
seedForthRuntime.seedsource \
seedForthInteractive.seedsource
cat $^ >__temp__.fs
gforth __temp__.fs -e bye >$@
rm __temp__.fs

.PHONY=clean
clean:
rm -f *.asm *.o *.fas *.s *.c *.Darwin *.Linux preForthdemo preForth forth seedForth seedForthDemo.seed seedForthInteractive.seed
rm -f *.asm *.o *.seed preForthdemo preForth seedForth __temp__.fs
Loading