System call convention
The rules for which registers carry the call number, arguments and return value when a program asks the kernel for something — almost, but not quite, the same as for ordinary function calls.
On x86-64 Linux the number goes in rax and the arguments in rdi, rsi, rdx, r10, r8 and r9. The fourth departs from the function convention's rcx because the syscall instruction itself overwrites rcx with the return address and r11 with the flags. Return values from −4095 to −1 are negated error codes, which the glibc wrapper turns into errno plus −1. Old i386 used int 0x80 with eax, ebx and onwards; ARM64 puts the number in x8 and executes svc #0.
On Linux the interface is stable — the kernel does not break userspace. Windows promises nothing: syscall numbers shift between releases, and the stable boundary is ntdll.dll.