%ifdef MODULE
section .data
global kernel_version
  kernel_version db '2.2.20-idepci',0
%endif

SECTION .text
;---------------------------------------------------------------------
; Multiple push/pop
;	push eax,ebx,ecx...
;	pop eax,ebx,ecx...

%macro call 1
%ifndef ALT_CALL_CONVENTION
  call %1
%else
  upsh %1
  call callcomma
%endif
%endmacro

%macro push 1-*.nolist
%rep %0
	push dword %1
%rotate 1
%endrep
%endmacro

%macro pop 1-*.nolist
%rep %0
%rotate -1
	pop dword %1
%endrep
%endmacro
%macro dup 0
        sub esi,byte 4
        mov [esi],eax
%endmacro
%macro drop 0
        lodsd
%endmacro
%macro variable 2
       call dovar
       %1 dd %2
%endmacro
%macro swap 0
       xchg eax,[esi]
%endmacro
%macro nip 0
       add esi,byte 4
%endmacro
%macro rot 0
	xchg eax,[esi]
	xchg eax,[esi+4]
%endmacro

%macro embed 1
   upsh %%e1
   upsh [%%e2]
   call eval	
   jmp short %%e3
%%e1 db %1
%%e2 dd $-%%e1
%%e3
%endmacro


%macro next 0
       ret
%endmacro

%macro upsh 1
        dup
        mov eax,%1
%endmacro
%macro upop 1
        mov %1,eax
        drop
%endmacro

%macro code 1
section .text
global $%1
$%1:
%endmacro

%ifndef MODULE
; =====================================================================
	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

	lea esi, [esp-0x200]	;Initialize data stack
        call main
	call bye		; Make sure this exits
; =====================================================================
%else
global module_init
init_module:
	mov esi, esp
        call main
        ret
%endif
