	.section	.text
	.intel_syntax
	.global mmap
mmap:
	.ifdef	NetBSD
	mov	%eax, 197		# MMAP system call
	push	0			# Extra double-word
	push	[%esp + 28]		# Offset
	push	0			# Extra double-word
	push	[%esp + 32]		# File descriptor
	push	[%esp + 32]		# Flags
	push	[%esp + 32]		# Protection
	push	[%esp + 32]		# Length
	push	[%esp + 32]		# Address
	push	0			# Extra double-word
	int	128
	add	%esp, 36		# Adjust the stack
	.else
	push	%ebp
	push	%edi
	push	%esi
	push	%ebx
	mov	%eax, 192		# MMAP2 system call
	mov	%ebx, [%esp + 20]	# Address
	mov	%ecx, [%esp + 24]	# Length
	mov	%edx, [%esp + 28]	# Protection
	mov	%esi, [%esp + 32]	# Flags
	mov	%edi, [%esp + 36]	# File descriptor
	mov	%ebp, [%esp + 40]	# %ebp = Offset
	shr	%ebp, 12		# %ebp = %ebp / 4096
	int	128
	pop	%ebx
	pop	%esi
	pop	%edi
	pop	%ebp
	.endif
	ret
