Registers
Memory is great, especially as there is (usually) a lot of it. However, memory is also slow. How slow? Well: If one CPU cycle would be 1 second, then a DRAM memory access would take around 6 minutes.
In the lectures about the memory subsystem, you will learn that there are mechanisms to avoid or reduce the impact that memory accesses have on the performance (e.g., through caching). The typical trade-off is: speed vs. size, whereas storage with a lot of space is usually slow but fast storage is very space-limited. The "final" stage of this trade-off is reached with registers. Registers are the smallest but fastest unit of storage available to the CPU. A CPU only has a limited number of registers, some of which are designated to specific functionality. There are also a number of general-purpose registers, which are used, among others, for calculations, storing temporary values, keeping track of the stack, or passing information to and from subroutines.
General-Purpose Registers
Below is a list of the x86-64 general-purpose registers. Note that the list gives the name of the 64-bit version of each register. The "Widths" tab shows the names and sizes (and locations) of the associated smaller registers.
rax
return value,
number of vector registers used for functions with variable arguments, (lower) result of multiplication and division
rbx
optionally used as base pointer
rcx
4th argument,
commonly used as loop counter (see branching instructions)
rdx
3rd argument,
upper 64 bits of 128-bit return value,
(upper) result of multiplication and division
rsi
2nd argument
rdi
1st argument
rsp
stack pointer
rbp
base pointer
r8
5th argument
r9
6th argument
r10
(used for passing a function's static chain pointer)
r11
r12
-r15
Green registers are callee-saved (their value is/has to be preserved during subroutine calls), while orange registers are caller-saved. More on this will be explained on the page about Calling Subroutines.
Last updated