The man page for syscall says that the first argument is the system call number. On my system (linux x64), arguments are sent in rdi, rsi, rdx, rcx, r8 and r9. So, rdi receives the call number. The syscall in ASM expects the system call number to be in rax, which means by having a generic ASM function syscall(int number, ...arguments), some shifting has to be made, and it's what I've seen when looking at some implementations of the LIBC.
For every system call, take the first argument sent from C code (received in rdi), move it to rax for the system, take the second argument from C code (received in rsi) and move it to rdi (will be first argument for the system).
This makes extra computation, by having an exit(int status) writen straight in ASM, arguments are well placed for the system, and the ASM function just puts 0x3c code in rax and executes syscall.
Are there benefits from having an available generic syscall(int number, ...) in C which has to shift arguments, rather than 312 specific ASM functions ? Other than writing less code.
System calls for my system are here: https://syscalls.w3challs.com/?arch=x86_64
The syscall man page: https://man7.org/linux/man-pages/man2/syscall.2.html
PS: not trying to reinvent the standard, just doing stuff from scratch for fun.
syscall(2)
stand-alone function that takes the call number as the first arg. – Peter Cordes