In the previous chapter, we learned how logic gates combine together to build the physical circuitry that processes binary signals inside a computer. Registers are one of the most important results of combining these gates together in a specific pattern, since they form small, extremely fast storage locations built directly inside the CPU itself.
While main memory, which we will study in more detail in a later chapter, can hold large amounts of data, it is comparatively slow to access from the CPU's perspective. Registers solve this speed problem by providing a very small number of storage locations that sit directly inside the processor, allowing data to be read from and written to them almost instantly, without the delay involved in reaching out to main memory.
In this tutorial, you will learn what a register actually is, how registers are built from simpler storage elements, and explore the most important individual registers found in a typical CPU, including the Program Counter, Instruction Register, Memory Address Register, Memory Buffer Register, and Accumulator, along with the specific role each one plays during instruction execution.
A register is a small storage location built directly inside the CPU, typically capable of holding just one data value, one memory address, or one instruction at a time. Registers are usually measured in bits, describing how many binary digits they can store simultaneously, such as a 32-bit register or a 64-bit register.
Registers are built using flip-flops, which are simple digital circuits constructed entirely from logic gates that are capable of holding a single bit of data steadily over time. A group of flip-flops connected together forms a register capable of holding multiple bits at once, giving it the capacity to store an entire binary value, address, or instruction.
Every single instruction a CPU executes needs somewhere extremely fast to temporarily hold data while that instruction is being processed. If the CPU had to constantly fetch every small piece of data directly from main memory during every single step of every instruction, overall performance would be severely limited by memory access delays.
Registers solve this by acting as the CPU's own private, high-speed workspace. Because registers are built directly into the processor itself, using the same high-speed technology as the rest of the CPU's circuitry, reading from or writing to a register happens dramatically faster than accessing main memory ever could.
The Program Counter, often abbreviated as PC, is a special register that keeps track of the memory address of the next instruction the CPU is going to execute. After each instruction finishes executing, the Program Counter is automatically updated to point to the address of the following instruction in sequence.
CS Engineering Gyan's simulated CPU is running a program PC currently holds: 2000 CPU fetches the instruction stored at address 2000 PC automatically updates to: 2001 CPU is now ready to fetch the next instruction from address 2001
The Program Counter essentially acts as a bookmark, always pointing to exactly where the CPU should look next in order to continue executing a program's instructions in the correct order.
The Instruction Register, abbreviated as IR, temporarily holds the actual instruction that has just been fetched from memory, right before the CPU decodes and executes it. While the Program Counter tracks where the next instruction is located, the Instruction Register holds the instruction itself once it has already been retrieved.
Instruction stored at memory address 2000: ADD R1, R2 CPU fetches this instruction and loads it into the Instruction Register (IR) IR now holds: ADD R1, R2 The CPU's control unit reads this value from IR to determine exactly what operation needs to be decoded and executed next
The Memory Address Register, abbreviated as MAR, holds the memory address that the CPU is about to access, whether it is reading data from that location or writing data into it. Essentially, the MAR specifies exactly where in memory the CPU intends to look.
CPU wants to read the value stored at memory address 3050 Step 1: CPU places the address 3050 into MAR MAR now holds: 3050 Step 2: Memory receives this address from MAR and prepares to return the value stored there
The Memory Buffer Register, abbreviated as MBR and sometimes also called the Memory Data Register, temporarily holds the actual data being transferred between the CPU and main memory, whether that data is being read from memory or written into it.
Continuing from the previous MAR example: Step 3: Memory returns the value stored at address 3050, which happens to be 75 Step 4: This value is placed into MBR MBR now holds: 75 Step 5: The CPU can now use this value from MBR for further processing
Working together, MAR and MBR handle every single data transfer between the CPU and main memory: MAR specifies exactly where in memory to look, while MBR temporarily holds whatever data is actually being sent or received at that address.
The Accumulator, often abbreviated as ACC, is a general-purpose register commonly used to hold the intermediate results of arithmetic and logical operations while a program is running. In many simpler CPU designs, the accumulator serves as the default location where calculation results are automatically stored.
CS Engineering Gyan's simulated CPU calculates total watch time by adding two stored values Value 1 (from register R1): 45 Value 2 (from register R2): 30 CPU performs: ACC = R1 + R2 Accumulator (ACC) now holds: 75
Once a calculation like this is complete, the value sitting in the accumulator can either be used immediately for the next step of a calculation, or transferred elsewhere, such as back into main memory for longer-term storage.
In addition to these specialized registers, most modern CPUs also provide a set of general purpose registers, often labeled simply as R0, R1, R2, and so on, which programs can use flexibly to temporarily hold values during processing, without being tied to one single predefined purpose the way the Program Counter or Instruction Register are.
A program temporarily stores two values it is about to add R1 = 45 (loaded from memory) R2 = 30 (loaded from memory) These general purpose registers hold the values ready for the CPU to use in an upcoming arithmetic instruction
| Register | Full Name | Primary Purpose |
|---|---|---|
| PC | Program Counter | Holds the address of the next instruction to be executed |
| IR | Instruction Register | Holds the instruction currently being decoded and executed |
| MAR | Memory Address Register | Holds the memory address currently being accessed |
| MBR | Memory Buffer Register | Holds data being transferred to or from memory |
| ACC | Accumulator | Holds intermediate results of arithmetic and logical operations |
| R0, R1, R2... | General Purpose Registers | Flexibly hold values during general program execution |
While each register has its own specific role, they rarely work in isolation. During a single instruction's execution, several registers typically cooperate closely together, passing values between one another as the instruction moves through its various stages.
Step 1: PC holds the address of the next instruction, 4000 Step 2: This address is copied into MAR Step 3: The instruction stored at that address is fetched into MBR Step 4: The instruction is then moved from MBR into IR for decoding Step 5: PC is updated to 4001, ready for the next fetch Step 6: If the instruction involves a calculation, its result is placed into ACC
This simplified walkthrough shows how PC, MAR, MBR, IR, and ACC each play a distinct but coordinated role, working together in sequence to move an instruction from memory all the way through to being fully executed.
| Advantages | Limitations |
|---|---|
| Provide extremely fast data access compared to main memory. | Registers can only hold a very small amount of data at any given time. |
| Allow the CPU to temporarily hold values needed during instruction execution. | The limited number of registers means data must frequently be moved in and out of them. |
| Specialized registers like PC and IR simplify how instruction execution is organized. | Understanding the interaction between multiple registers can be confusing for beginners at first. |
| Mistake | Correct Practice |
|---|---|
| Confusing MAR with MBR. | Remember that MAR holds an address, while MBR holds the actual data found at that address. |
| Assuming the Program Counter holds the currently executing instruction. | Remember that PC holds the address of the next instruction, while IR holds the instruction currently being processed. |
| Thinking registers can store large amounts of data like main memory. | Remember that registers are intentionally small and fast, designed to hold only one value or address at a time. |
| Assuming every CPU design uses the exact same register names. | Understand that while PC, IR, MAR, MBR, and ACC are common concepts, exact naming can vary slightly between different CPU architectures. |
Registers provide the small, extremely fast storage locations that a CPU relies on constantly while executing instructions, avoiding the delays that would come from accessing main memory for every single step. We looked closely at the Program Counter, which tracks the next instruction, the Instruction Register, which holds the instruction currently being processed, and MAR and MBR, which work together to manage every data transfer between the CPU and memory.
We also examined the accumulator, which holds intermediate calculation results, along with general purpose registers that flexibly support a program's ongoing execution. The simplified walkthrough demonstrated how all of these registers cooperate closely together, passing values between each other as a single instruction moves from being fetched all the way through to being fully executed.
With registers covered, you are now ready to explore the instruction cycle in detail, where the fetch, decode, and execute stages we touched on briefly here are examined step by step as the complete process every single CPU instruction goes through.