SEGMENT .text USE32
[BITS 32]

GLOBAL	gate_wrapper
EXTERN	sys_calls

; in: eax number of system call subroutine
; out: on a current process stack (if needed)

gate_wrapper:

				push	gs
				push	fs
				push	es
				push	ds
				pushad
				
				mov		bx, 0x10
				mov		ds, bx
				mov		es, bx

				mov		ebp, esp
				push	ebp
				push	eax							;number of system call subroutine
				call	sys_calls
				add		esp, 8

				popad
				pop		ds
				pop		es
				pop		fs
				pop		gs
				iretd


