register (processor)
termKept in this browser · My desk
A small, fast storage location inside the processor, named directly by instructions; the number and width of registers, and which ones are special, are part of an instruction set architecture.
Registers are where assembly does its work, and where a calling convention puts arguments and results. Which register carries what is not decided by the processor alone: on the same x86-64 chip, Linux's System V convention passes the first integer argument in RDI and Microsoft's in RCX. Some architectures also give a register a fixed value: RISC-V's x0 always reads as zero.
What it is. A register is a storage location inside the processor that instructions name directly, by a number encoded in the instruction itself. Registers are few because each register number costs bits in every instruction that uses it: x86's ModR/M byte has 3-bit register fields, extended by one bit from the REX prefix to reach 16 registers, while RISC-V's 32-bit instructions carry 5-bit register fields for 32 registers. Everything a program computes passes through them; memory holds what does not fit.
Three modern register files. In 64-bit mode an x86-64 processor has 16 general-purpose registers; the ModR/M byte has 3-bit fields (RAX 000 to RDI 111) and the REX prefix supplies the extra bit for R8 to R15. A 32-bit operation zero-extends its result into the full 64-bit register, which is why xor eax, eax clears RAX. AArch64 has 31 general-purpose registers X0 to X30, X30 being the procedure link register, and register number 31 means either the stack pointer or a zero register depending on the instruction. RISC-V has 32 registers x0 to x31, and x0 "is hardwired with all bits equal to 0".
Eight-bit ancestors. The Z80 has two sets of six general-purpose registers usable as 8-bit registers or 16-bit pairs, plus accumulators and flag registers; the 6502 has an accumulator and two index registers, X and Y, and can add only memory to the accumulator, so a loop counter must pass through memory to be summed.
Beyond the general-purpose set. A processor has more registers than the ones arithmetic names. The program counter (RIP on x86-64, the PC on Arm and RISC-V) holds the address of the next instruction, and the stack pointer the top of the stack, which is why both are the first targets of an exploit. Vector registers hold several values at once: Microsoft's x64 documentation notes that all floating-point operations use the 16 XMM registers and that the old x87 register stack is unused. Control and model-specific registers configure the processor itself; Intel's IA32_EFER, for example, holds the NXE bit (bit 11) that turns on execute-disable page protection, and only the operating system may write it.
Who decides what lives in a register. In compiled code the programmer rarely chooses: the compiler's register allocator does, keeping the busiest values in registers and spilling the rest to the stack. OpenJDK's HotSpot glossary, for example, describes its fast C1 compiler as using "a linear scan register allocation". Hand-written assembly makes the choice explicit, which is where the calling conventions below become rules rather than habits.
Flags and conventions. Status flags such as x86's ZF (bit 6 of EFLAGS, set when a result is zero) live in a flags register; RISC-V has none for integer comparisons. Calling conventions assign roles: System V uses RDI, RSI, RDX, RCX, r8 and r9 for integer arguments and RAX for results; the Arm 64-bit procedure call standard (AAPCS64) uses r0-r7 for both; the RISC-V convention uses a0-a7 (x10-x17), with ra (x1) holding the return address.
Who saves what. A convention also decides which registers a called function may destroy. Microsoft's x64 application binary interface (ABI) is "a four-register, fast-call calling convention": integer arguments go in RCX, RDX, R8 and R9, floating-point arguments in XMM0 to XMM3, and the caller reserves a shadow store on the stack where the callee may save those four; they, together with RAX, R10, R11, XMM4 and XMM5, are volatile, while the others must be preserved. The RISC-V psABI (processor-specific ABI) tabulates the same decision for every register: x2 (sp) is preserved across calls, s0 to s11 (x8, x9 and x18 to x27) are callee-saved, a0 to a7 and the temporaries t0 to t6 are not, and gp (x3) and tp (x4) are "Unallocatable". Assembly that breaks these rules works until a caller relies on a register it thought was safe.
A register is state to protect. On every context switch the operating system saves one program's registers and loads another's, so register contents are as private as memory. Two flaws showed what happens when that boundary leaks. Tavis Ormandy's Zenbleed (Common Vulnerabilities and Exposures identifier CVE-2023-20593) began with the vector registers: x86-64 processors have 128-bit XMM registers extended to 256-bit YMM; on every Zen 2 class processor a mispredicted vzeroupper could be recovered incorrectly, and his variant leaked "about 30 kb per core, per second", fast enough to watch keys and passwords; he reported it to AMD on 15 May 2023, and the National Vulnerability Database (NVD) published it on 24 July 2023. Earlier, CVE-2018-3665 (published 21 June 2018) described how software using the lazy floating-point state restore technique on Intel Core processors "may potentially allow a local process to infer data from another process" through a speculative execution side channel.
Neighbours. Registers are part of the instruction set architecture, the operands of opcodes, the working space of assembly language and the subject of calling conventions in the application binary interface. Brazilian practice says registrador.
Also known as: register, CPU register, general-purpose register, registrador, registrador de uso geral, accumulator, zero register
Sources
- Intel SDM 325462-093: 16 general-purpose registers in 64-bit mode (Vol. 1, p. 3-12); 32-bit results zero-extended to 64 bits (p. 3-13); ZF is bit 6 of EFLAGS (p. 3-16); REX prefixes occupy opcodes 40H to 4FH (Vol. 2A, p. 2-8) (read 2026-11-23)
- Intel SDM 325462-093: REX.W + 01 /r ADD r/m64, r64 (Vol. 2A, p. 3-14); 31 /r XOR (Vol. 2D, p. 6-40); C3 RET (Vol. 2B, p. 4-569); ModR/M Table 2-2 (Vol. 2A, p. 2-6); REX fields 0100WRXB (p. 2-9); /digit and /r notation (p. 3-2) (read 2026-11-23)
- Arm, Arm Architecture Reference Manual for A-profile architecture, DDI 0487 M.d: A64 instructions are 32 bits and always little-endian (p. B2-316); RISC features (p. A1-41); 31 general-purpose registers, X30 the link register (p. A1-44); encodings of MOVZ, ADD, SUBS, CBZ, B.cond and RET (chapter C6) (read 2026-11-23)
- RISC-V International, The RISC-V Instruction Set Manual Volume I: Unprivileged Architecture, version 20250508: designed for research and education (p. 12); instructions stored as 16-bit little-endian parcels (p. 19); x0 hardwired to zero (p. 23); the RV32I listing with opcode, funct3 and funct7 fields (p. 609); the compressed extension's 25-30% code-size reduction (p. 160) (read 2026-11-23)
- Zilog, Z80 Family CPU User Manual UM008005-0205: register set (p. 1); LD r, r' is 01 r r' (p. 81); ADD A, r is 10 000 r (p. 140); DJNZ is 10 followed by e-2, and the assembler adjusts for the incremented PC (p. 253); the XOR page prints OR's codes while the opcode table gives XOR A as AF (pp. 60 and 156) (read 2026-11-23)
- MOS Technology, MCS6500 Microcomputer Family Programming Manual, 6500-50A, January 1976: instruction summary opcodes such as LDA immediate A9, ADC zero page 65, BNE D0 and RTS 60 (pp. B-3 to B-26); branch range of +127 to -128 (p. 42) (read 2026-11-23)
- x86-64 psABI (System V), low-level-sys-info.tex: integer arguments in RDI, RSI, RDX, RCX, r8 and r9; integer results in RAX (read 2026-11-23)
- Arm, Procedure Call Standard for the Arm 64-bit Architecture (AAPCS64): r0-r7 pass arguments and return results (read 2026-11-23)
- Microsoft Learn, x64 calling convention: the x64 ABI uses a four-register, fast-call convention with a shadow store on the stack; integer arguments in RCX, RDX, R8 and R9, floating point in XMM0L to XMM3L; these and RAX, R10, R11, XMM4 and XMM5 are volatile (read 2026-11-23)
- RISC-V International, RISC-V ELF psABI, riscv-cc.adoc, integer register convention: x0 zero; x1 ra not preserved; x2 sp preserved; x3 gp and x4 tp unallocatable; s0-s11 callee-saved; a0-a7 (x10-x17) arguments; t0-t6 temporaries (read 2026-11-23)
- Tavis Ormandy, Zenbleed (lock.cmpxchg8b.com): XMM registers extended to YMM; CVE-2023-20593, an incorrectly recovered mispredicted vzeroupper on all Zen 2 class processors; a variant leaking about 30 kb per core per second; reported to AMD on 15 May 2023 (read 2026-11-23)
- NIST National Vulnerability Database, CVE-2023-20593 (API record): published 24 July 2023; an issue in Zen 2 CPUs that may allow an attacker to access sensitive information under specific microarchitectural circumstances (read 2026-11-23)
- NIST National Vulnerability Database, CVE-2018-3665 (API record): published 21 June 2018; Lazy FP state restore on Intel Core-based microprocessors may allow a local process to infer data from another process through a speculative execution side channel (read 2026-11-23)
- OpenJDK, HotSpot Glossary of Terms: the C1 compiler, fast and lightly optimizing, with a linear scan register allocation; the C2 compiler; deoptimization (read 2026-11-23)
- Intel SDM 325462-093, Vol. 3A, section 6.13 (p. 6-30): IA32_EFER, the Extended Feature Enable MSR, with the execute-disable enable bit NXE at bit 11 (read 2026-11-23)