7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
; altogether and access the error value of a
; syscall directly. invoke as:
;
; void k_platform_syscall_raw(s64* result, u64* errno,
; syscall, u8 valency, s64[] args)
bits 64
%include "../arch/posix/x86.lin.64.s"
%include "../arch/x86.cdecl.64.s"
; vim: ft=nasm
%macro handle_arg 1
%assign v %1+1
mov sys.reg. %+ v, [ccall.reg.4 + 8 * %1]
dec ccall.reg.3
jz .perform_call
%endmacro
global k_platform_syscall_raw:function
k_platform_syscall_raw:
; locals: rbx = s64* result
................................................................................
; and popping back from the stack
mov rbx, ccall.reg.0
mov r12, ccall.reg.1
; this needs to go before the loop
; or it'll get clobbered
mov sys.reg.0, ccall.reg.2
; automatically generate the code
; needed to move the arguments into
; their correct registers. see above
%assign i 0
%rep 6
handle_arg i
|
|
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
; altogether and access the error value of a
; syscall directly. invoke as:
;
; void k_platform_syscall_raw(s64* result, u64* errno,
; syscall, u8 valency, s64[] args)
bits 64
%include "arch/posix/x86.lin.64.s"
%include "arch/x86.cdecl.64.s"
; vim: ft=nasm
%macro handle_arg 1
%assign v %1+1
mov sys.reg. %+ v, [r15 + 8 * %1]
dec ccall.reg.3
jz .perform_call
%endmacro
global k_platform_syscall_raw:function
k_platform_syscall_raw:
; locals: rbx = s64* result
................................................................................
; and popping back from the stack
mov rbx, ccall.reg.0
mov r12, ccall.reg.1
; this needs to go before the loop
; or it'll get clobbered
mov sys.reg.0, ccall.reg.2
; the fourth argument is in %r8, which
; is also a syscall register, so we
; need to move it to a safe register
; to keep it from getting clobbered
; before we begin the "loop"
mov r15, ccall.reg.4
; automatically generate the code
; needed to move the arguments into
; their correct registers. see above
%assign i 0
%rep 6
handle_arg i
|