; FORTH.ASM
; A Forth Interpreter for RETRO-NG
; Common to all x86 implementations
;-------------------------------------------------------------------

tin dd 0                      ; ( >IN, pointer into TIB )
tp  dd tib
var 'h', h, h0
var 'd', d, d0
var 'base', base, 10
var 'source', source, 0

section .text
%include "forth/parser"     ; ( Forth Parser and Special Functions )
%include "forth/compiler"   ; ( Minimal Compiler )
%include "forth/primitives" ; ( Primitives )

; ( Called by platform wrapper, sets up core Forth words )
forth_init: 
	upsh forth_extend
        upsh forth_extend.1 - forth_extend
        call eval
ret

; ( Allocate the dictionary space )
SECTION .data
flast dd forth_link         ; ( Forth words )
mlast dd macro_link         ; ( Macro [inline] words )
last dd flast               ; ( Pointer to last word
section .text

; ( High-level words, initialized by forth_init )
section .data
forth_extend: incbin "forth/extend.f"
.1
section .text
