; -----------------------------------------------------------------------------
;    ~     RetroForth for Linux
;   . .    http://www.retroforth.tk
;   /V\    
;  // \\   Release 6.20 (Final) for NASM
; /(   )\  Text Console
;  ^'~'^
; -----------------------------------------------------------------------------
; This is primarily a wrapper for the other files. It loads the
; macros, sets up memory + stacks, and initializes the Forth
; system. It includes the following files automatically:
;  * macros
;  * forth.asm + forth-ic.asm + forth.f
;  * drivers.asm + drivers.f
;  * user.asm + user.f
; If you're porting RF, you should only need to edit the startup
; code and drivers. The rest should work "out of the box".
; -----------------------------------------------------------------------------
%include "macros"

SECTION .text
	global _start
_start:
	mov eax, 07dh              ;sys mprotect (pinched from IsForth :-)
	mov ebx, 08048000h
	mov ecx, 00100000h
	mov edx, 7
	int 080h                   ;make the entire program space rwx

	mov esi, sp0	;Initialize data stack

MAIN:   upsh startup            ;Load startup code (startup.f)
        upsh startup.1 - startup
        call eval
        call user_init
	call interpret
;---------------------------------------------------------------------
%include "../forth-ic.asm"
%include "drivers.asm"
%include "user.asm"
%include "../forth.asm"
;---------------------------------------------------------------------
section .data
startup: incbin "../forth.f"
         incbin "drivers.f"
         incbin "user.f"
         db '" RetroForth 6.20" type cr'
.1
END
