libk  platform.munmap.fn.x86.lin.64.s at [55dc614190]

File legacy/platform.munmap.fn.x86.lin.64.s artifact 7b471fc276 part of check-in 55dc614190


bits 64
%include "../arch/posix/x86.lin.64.s"
%include "../arch/x86.cdecl.64.s"
; vim: ft=nasm

global kmem_platform_munmap
kmem_platform_munmap:
	; to call munmap, we need to translate the cdecl64
	; register arguments to their appropriate syscall64
	; registers. all those that matter are the same.
	  mov sys.reg.1, ccall.reg.0 ;nop - rdi → rdi
	  mov sys.reg.2, ccall.reg.1 ;nop - rsi → rsi

	mov sys.reg.0, sys.munmap
	sys.call

	mov ccall.reg.ret, sys.reg.ret ; rax → rdi
	ret