How does a CPU use the registers?
– This is the first part in, I hope, a long series of short articles, which will explain some of the basics about the internal design of CPUs. In this first part we ll look at the registers, or more specifically, how the registers are used. Registers? A CPU usually contains a register file. A register file consists of a number of registers plus status bits, which give information about the registers; for instance whether an overflow occurred. Registers are needed because a CPU cannot directly work with data that is stored in the memory. So if the CPU wants to work with data, it needs to copy this data to the registers and afterwards copy them back. When a CPU executes an instruction this usually takes 5 steps: • Instruction Fetch: the instruction(s) that need to be executed are grabbed from the memory, or more often (instruction) cache. • Instruction Decode: the instruction is translated to the commands that are specific for the CPU. • Instruction Execute: the instruction is executed.