%macro kernel 1-*
  %if %0 > 1
	push ebx
  %endif
  %rep %0
    %rotate -1
	push dword %1
  %endrep
	pop eax
  %if %0 > 1
	pop ebx
    %if %0 > 2
	pop ecx
      %if %0 > 3
	pop edx
        %if %0 > 4
        %error "Can't do syscall with more than 4 parameters"
        %endif
      %endif
    %endif

  %endif
	int 80h

	mov ecx, eax
	and ecx, 0xfffff000
	cmp ecx, 0xfffff000
	jne %%ok
	mov ecx, eax
	neg ecx
	mov eax, -1
	jmp short %%end
%%ok:
	xor ecx, ecx
%%end:
  %if %0 > 1
	pop ebx
  %endif
%endmacro
