Computer architecture
Registers
Also called: register file · general-purpose registers · accumulator · special-function register
Definition
Registers are a small number of very fast storage locations inside the processor that hold the values it is working on right now.
Picture it
Registers are the processor's hands; memory is the shelf across the room. Arithmetic happens between registers, so programs load values from memory, work on them, and store results back. Microcontrollers also have special-function registers that control peripherals.
The maths
register file size = number of registers × word size
| Quantity | Unit | Symbol |
|---|---|---|
| information | bit | bit |
| information | byte (8 bits) | B |
Worked example
A processor has 32 general-purpose registers of 32 bits each. How many bytes is the register file, and how many bits does an instruction need to name one register?
- 32 × 32 bits = 1024 bits = 128 bytes
- 2^5 = 32, so 5 bits per register field
Answer128 bytes; 5 bits to name a register.
✓ The 2 numbers in this answer are recomputed from scratch by an automated test.
Common misconceptions
- Misconception: Registers are not the same as RAM; there are only a handful of them.
- Misconception: Writing a microcontroller's control register can change hardware behaviour immediately.