Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

are you saying "they couldn't use rcx so they use r10, just like everybody else"? Because the quote says r10 and you brought up rcx

in any case, there's a good discussion of registers and syscalls here

https://stackoverflow.com/questions/53290932/what-are-r10-r1...



Here's the full quote:

> Following the System V ABI, which is required on Linux and other Unices for system calls, invoking a system call requires us to put the system call code in the register rax, the parameters to the syscall (up to 6) in the registers rdi, rsi, rdx, rcx, r8, r9, and additional parameters, if any, on the stack (which will not happen in this program so we can forget about it). We then use the instruction syscall and check rax for the return value, 0 usually meaning: no error.

> Note that Linux has a ‘fun’ difference, which is that the fourth parameter of a system call is actually passed using the register r10.

That makes it sound like it's only Linux that uses r10 and every other OS uses rcx as the 4th parameter with syscall, but really no OS uses rcx with syscall.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: