1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
18
19
20
21
22
23
24
|
bits 64
%include "../arch/x86.lin.64.s"
%include "../arch/x86.cdecl.64.s"
; vim: ft=nasm
global kmem_posix_mmap
kmem_posix_mmap:
; to call mmap, we need to translate the cdecl64
; register arguments to their appropriate syscall64
; registers. these are mostly the same, with one
; obnoxious exception. the NOPs have been written
; in as comments to aid in understanding.
mov sys.reg.1, ccall.reg.0 ;nop - rdi → rdi
................................................................................
mov sys.reg.5, ccall.reg.4 ;nop - r8 → r8
mov sys.reg.6, ccall.reg.5 ;nop - r9 → r9
mov sys.reg.0, sys.mmap
sys.call
mov ccall.reg.ret, sys.reg.ret ; rax → rdi
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
18
19
20
21
22
23
24
25
|
bits 64
%include "../arch/x86.lin.64.s"
%include "../arch/x86.cdecl.64.s"
; vim: ft=nasm
global kmem_platform_mmap
kmem_platform_mmap:
; to call mmap, we need to translate the cdecl64
; register arguments to their appropriate syscall64
; registers. these are mostly the same, with one
; obnoxious exception. the NOPs have been written
; in as comments to aid in understanding.
mov sys.reg.1, ccall.reg.0 ;nop - rdi → rdi
................................................................................
mov sys.reg.5, ccall.reg.4 ;nop - r8 → r8
mov sys.reg.6, ccall.reg.5 ;nop - r9 → r9
mov sys.reg.0, sys.mmap
sys.call
mov ccall.reg.ret, sys.reg.ret ; rax → rdi
ret
|