Differences From
Artifact [f9a360108d]:
49 49 %assign i 0
50 50 %rep 6
51 51 handle_arg i
52 52 %assign i i+1
53 53 %endrep
54 54
55 55 ; valency >= 7. this is not valid, so
56 - ; we set our return value to 0 and the
56 + ; we set our return value to -1 and the
57 57 ; error number to its maximum value in
58 58 ; order to indicate that the syscall
59 59 ; was invalid
60 - mov qword [rbx], 0
60 + mov qword [rbx], -1
61 61 mov qword [r12], -1
62 62 ret
63 63
64 64 ; we have a valency match - perform the
65 65 ; requested syscall already store in rax
66 66 .perform_call: sys.call
67 +
68 + ; check for an error - on x86, error is
69 + ; returned as a negative value in %rax
70 + test sys.reg.ret, sys.reg.ret
71 + js .error ; jump if sign flag set
67 72
68 73 ; move our return values into place and
69 74 ; return to the caller (which should
70 75 ; always be k_platform_syscall, btw)
71 - mov [rbx], sys.reg.ret
72 - mov [r12], sys.reg.err
76 + mov [rbx], sys.reg.ret
77 + mov qword [r12], 0 ; no error
73 78 ret
79 +
80 + ; an error was returned - we need to set
81 + ; the errno to its positive equivalent,
82 + ; and store -1 in the return variable
83 + .error: neg sys.reg.ret
84 + mov qword [rbx], -1
85 + mov [r12], sys.reg.ret
86 + ret