NOTE
Registers
Registers are storage units inside the CPU that hold data, instructions, and intermediate results, with faster access than main memory.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is a Register?
A register is a storage unit inside the CPU. It holds data read from memory (including instructions) and intermediate results of CPU operations. Cache
2. Why Are Registers Needed?
The CPU reads and writes registers much faster than it reads and writes memory.
3. Register Categories
CPUs with different architectures have different numbers, types, and names of internal registers. AMD64 is used here as an example.
3.1. General-Purpose Registers
rax,rbx,rcx,rdx,rsi,rdi,rbp,rsp,r8,r9,r10,r11,r12,r13,r14, andr15rspandrbpare both related to the function call stack.rspgenerally holds the address of the top of the function call stack.- When a frame pointer is used,
rbpis commonly used as a reference point for the function’s stack frame. - For an example, see Process
- Mainly used to temporarily hold data.
- 64 bit; lower-width 32/16/8-bit register names can also be used.

3.2. Program Counter Register (PC Register)
rip- Holds the instruction pointer, i.e. the address of the next instruction to execute.
- 64 bit
3.3. Segment Registers
fsandgs- On x86-64 systems, operating systems commonly use them for facilities such as thread-local storage (TLS).
- The FS/GS segment selectors themselves are 16 bit; on x86-64, the FS/GS base used for address calculation can be 64 bit.
4. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub