; -----------------------------------------------------------------------------
;    ~     RetroForth for Linux
;   . .    http://www.retroforth.org
;   /V\    
;  // \\   Release 6.20 (Final) for FASM
; /(   )\  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".
; -----------------------------------------------------------------------------

; conditional compilation macros:
macro define name { name fix defined }
macro ifdef name,condmacro,elsemacro 
{ 
   macro ifdef#name _m elsemacro m_ 
   macro ifdef#defined _m condmacro m_ 
   ifdef#name 
   purge ifdef#defined 
   purge ifdef#name 
} 
_m fix { 
m_ fix }

; vim: ft=fasm :
format ELF executable
entry start	; entry point of the executable
;--------------------------------------------------------------------
include "macros"

section executable readable writeable
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

	call driver_init
	mov esi, sp0

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"
;---------------------------------------------------------------------
startup:
file "../forth.f"
file "drivers.f"
file "user.f"
db '" RetroForth 6.20" type cr'
startup.1:
;---------------------------------------------------------------------
tib  rb   200h  ; was 'resb' 
sp0  rb   300h
d0   rb 10000h
h0   rb 80000h
;---------------------------------------------------------------------
