Index: mod/kcore/syscall.fn.x86.lin.64.s ================================================================== --- mod/kcore/syscall.fn.x86.lin.64.s +++ mod/kcore/syscall.fn.x86.lin.64.s @@ -33,10 +33,17 @@ ; arg 0 = s64* result ; arg 1 = errno ptr ; arg 2 = syscall num ; arg 3 = valency ; arg 4 = args ptr + + ; we use two registers that are supposed + ; to be callee-saved, so we need to + ; push them to the stack and then pop + ; them back off just before the fn rets. + push rbx + push r12 ; store the locals in registers that ; are guaranteed not to be clobbered, ; saving us some cycles pushing to ; and popping back from the stack @@ -84,14 +91,18 @@ ; move our return values into place and ; return to the caller (which should ; always be k_platform_syscall, btw) mov [rbx], sys.reg.ret mov qword [r12], 0 ; no error - ret + jmp .return ; an error was returned - we need to set ; the errno to its positive equivalent, ; and store -1 in the return variable .error: neg sys.reg.ret mov qword [rbx], -1 mov [r12], sys.reg.ret - ret + jmp .return + + .return: pop r12 + pop rbx + ret