aforth

FORTH for Linux x86-64, written in assembly.
git clone git://henryandlizzy.uk/aforth
Log | Files | Refs | README

commit 41a76cc0db57b42d21467cbe0e10dfed93d9aa96
parent b4d34d17bd62e9cab9862492ea44efc0af74081f
Author: Henry Wilson <m3henry@googlemail.com>
Date:   Tue,  1 Aug 2017 11:58:30 +0100

compiles numbers

Diffstat:
Minput.s | 2+-
Dinput.txt | 7-------
Minterpreter.s | 10+++++++---
Mmacros.i | 2+-
Mmain.s | 2+-
Mmakefile | 4++--
Atest.txt | 8++++++++
7 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/input.s b/input.s @@ -1,7 +1,7 @@ # Input verb forth TIB - scratch 80 + scratch 256 #80 endword verb forth numtib "\#TIB" diff --git a/input.txt b/input.txt @@ -1,7 +0,0 @@ -CR -GREET -5 3 * . CR -8 3 FLAG -: SQUARE DUP * ; -12 SQUARE . CR -CR DICTIONARY CR diff --git a/interpreter.s b/interpreter.s @@ -23,15 +23,19 @@ verb forth INTERPRET do fetch do CONVERT do drop2 - test greater 0 2f - do DROP + test greater 0 5f get HERE escape 91 say "Unknown token: " do PRINT do CR do ABORT - goto 2f + 5: get MODE + unless 2f + const docon + do COMPILE + do COMPILE + goto 2f 1: do DUP const 8 do minus diff --git a/macros.i b/macros.i @@ -86,7 +86,7 @@ .endm .macro unless label - do NOT + do iszero if \label .endm diff --git a/main.s b/main.s @@ -62,7 +62,7 @@ verb forth QUIT do RESETRETURN # was commented out? do modeI 2: do TIB - const 80 + const 256 #80 escape 93 say "➤ " do ACCEPT diff --git a/makefile b/makefile @@ -1,6 +1,6 @@ all: bin/aFORTH @echo Testing... - @bin/aFORTH < input.txt + @bin/aFORTH < test.txt interactive: bin/aFORTH @bin/aFORTH @@ -9,7 +9,7 @@ bin/aFORTH: obj/main.o @echo Linking... @ld -o bin/aFORTH obj/main.o -obj/main.o: main.s +obj/main.o: main.s dictionary.s interpreter.s memory.s boolean.s extras.s macros.i stack.s compiler.s input.s maths.s output.s @echo Compiling... @gcc -c -o obj/main.o main.s diff --git a/test.txt b/test.txt @@ -0,0 +1,8 @@ +CR +GREET +5 3 * . CR +8 3 FLAG +: SQUARE DUP * ; +: STAR 42 EMIT ; +12 DUP DUP . STAR . 61 EMIT SQUARE . CR +CR DICTIONARY CR