How many general-purpose registers does x86-64 have, and what are their conventional roles?
x86-64 has 16 general-purpose 64-bit registers — the original 8 inherited from IA-32 plus 8 new ones (%r8–%r15) — each with a conventional role under the System V calling convention.
* The System V ABI fixes each register's role: %rdi-%r9 pass the first six args, %rax returns, %rbx/%rbp/%r12-%r15 are callee-saved, %r10/%r11 scratch, %rsp the stack. *
Hardware doesn't force most of these roles; they're conventions the calling convention agrees on so that separately compiled functions interoperate. The original eight keep names from the 8086 era (the letters once meant Accumulator, Base, Counter, Data, etc.).
Original 8 (from IA-32):
%rax— return value (also "accumulator")%rbx— callee-saved, general purpose%rcx— 4th argument%rdx— 3rd argument%rsi— 2nd argument%rdi— 1st argument%rbp— frame/base pointer (now general purpose)%rsp— the stack pointer (reserved)
New 8 (added by x86-64): %r8 and %r9 carry the 5th and 6th arguments; %r10/%r11 are caller-saved temporaries; %r12–%r15 are callee-saved.
Why double them? Eight registers caused constant "register pressure" — values had to be spilled to memory. Sixteen registers let far more of a function's working set stay in fast registers, cutting memory traffic.
Go deeper:
x86 calling conventions (Wikipedia) — the System V role of each of the 16 general-purpose registers.