A processor continuously moves information between different parts of a computer while executing a program. It needs to remember the address of the next instruction, hold the instruction currently being decoded, keep temporary operands available for the ALU, and store intermediate results. Registers provide the extremely fast storage needed for these activities.
Unlike main memory, registers are located within the processor's execution environment and are designed for very quick access. Their capacity is small, but their importance is much greater than their size suggests. Almost every instruction execution involves one or more registers directly or indirectly.
Registers are not all used for the same purpose. Some control the flow of instruction execution, some contain memory addresses, some temporarily hold data, and others record information about the result of an operation. The exact collection of registers differs between processor architectures, but the underlying ideas are fundamental to Computer Organization.
In this chapter, we will examine the major types of CPU registers, understand what information each one stores, and follow a simplified instruction from memory into the processor to see how these registers cooperate.
A register is a small, high-speed storage element used by the CPU to temporarily hold binary information. The size of a register indicates how many bits it can contain. For example, a 32-bit register can hold 32 bits at a time, while a 64-bit register can hold 64 bits.
Registers are generally implemented using flip-flops and related digital circuitry. A single flip-flop can represent one binary bit. By combining many such storage elements, a processor can create a register capable of holding a complete binary value.
The important point is that a register is not simply a smaller version of RAM. Registers have specific roles within the processor and are directly involved in operations such as instruction sequencing, arithmetic, memory access, and status tracking.
Suppose a processor has a 32-bit register named R1. R1 can temporarily contain: 10110100101011001100110011001100 This represents one 32-bit pattern. The processor can use the value in R1 as: - an operand for an arithmetic operation - an address - an intermediate result - temporary program data The exact interpretation depends on the instruction using R1.
The number of bits that a register can hold is closely related to the processor architecture. Common register widths include 8, 16, 32, and 64 bits. A larger register can represent a wider range of binary values in a single operation, although register size alone does not determine the complete performance of a processor.
For example, an unsigned 8-bit register can represent values from 0 to 255. A 16-bit register can represent values from 0 to 65,535. The processor architecture determines how these registers are used and what operations can be performed on them.
The CPU repeatedly performs operations on instructions and data. Fetching every intermediate value from main memory would create unnecessary delays. Registers provide locations where frequently needed information can remain immediately available to the processor.
For example, suppose an instruction needs to add two values. The processor may load the operands into registers, perform the addition using the ALU, and keep the result in another register. The values therefore remain close to the execution circuitry throughout the operation.
Memory | | Load operands v R1 = 25 R2 = 17 | | ALU performs addition v R3 = R1 + R2 | v R3 = 42
This illustrates an important relationship between registers and the ALU: registers provide fast locations for operands and results, while the ALU performs the actual arithmetic or logical operation.
The Program Counter, commonly abbreviated as PC, is a control register that contains the address associated with the next instruction to be fetched. It allows the processor to maintain the sequence of instruction execution.
After an instruction is fetched, the PC normally advances so that the processor can locate the following instruction. A branch, jump, function call, interrupt, or other control-flow event can change the PC to a different address.
Assume instructions are stored at: Address 5000 → Instruction A Address 5004 → Instruction B Address 5008 → Instruction C Initially: PC = 5000 After fetching Instruction A: PC = 5004 After fetching Instruction B: PC = 5008
The amount added to the PC is not universally one byte or one fixed number. It depends on the instruction format and architecture. This is an important distinction when studying real processors.
The Instruction Register stores the instruction that the processor has fetched and is currently working with. The control unit examines the instruction in the IR to determine what operation needs to be performed and what operands or resources are required.
Memory location 5000 contains: ADD R1, R2, R3 During instruction fetch: IR = ADD R1, R2, R3 The control unit can now interpret: Operation → ADD Source registers → R1 and R2 Destination register → R3
The PC and IR therefore have different responsibilities. The PC identifies where the next instruction should be obtained, whereas the IR contains the instruction currently being processed.
The Memory Address Register, or MAR, holds the address of the memory location that the processor wants to access. It is concerned with the location of information rather than the information itself.
Suppose the CPU needs data from memory location 7200. MAR = 7200 The memory system uses this address to identify the requested location.
A useful way to remember the MAR is to associate it with the question: "Where is the information?" The answer is represented by the address stored in the MAR.
The Memory Data Register, commonly called MDR, holds data that is being transferred between the processor and memory. In some textbooks and architectures, a similar register is called the Memory Buffer Register (MBR).
CPU wants to read memory location 7200. Step 1: MAR = 7200 Step 2: Memory supplies the contents of location 7200. Suppose the value is: 10101101 Step 3: MDR = 10101101
CPU wants to store: 11001010 at memory location: 8300 MAR = 8300 MDR = 11001010 The memory system receives the address and data and performs the write operation.
The distinction between MAR and MDR is fundamental: MAR identifies the location, while MDR carries the data being transferred.
The accumulator is a register traditionally associated with arithmetic and logical processing. In accumulator-based processor designs, the accumulator is used as an implicit operand or as the destination for intermediate results.
Initial accumulator: ACC = 12 CPU performs: ACC = ACC + 8 After execution: ACC = 20
The accumulator is especially important when studying older or simpler CPU architectures. Modern general-purpose processors commonly provide many general-purpose registers, so an accumulator may not have the same central role.
General purpose registers, often represented by names such as R0, R1, R2, or RAX, RBX and similar architecture-specific names, are designed to hold values needed by programs during execution.
They can contain operands, intermediate results, addresses, counters, or other temporary information depending on the instruction set architecture.
R1 = 18 R2 = 7 Instruction: ADD R1, R2 Possible result: R1 = 25
The exact instruction syntax and whether the original value in R1 is replaced depend on the processor architecture. This is why register names and instruction behavior should always be studied in the context of a particular instruction set.
A processor also needs a way to record information about the result of certain operations. This information is commonly maintained using a status register or flag register.
Individual flags can indicate conditions such as whether an arithmetic result was zero, whether a carry occurred, whether a signed overflow occurred, or whether a comparison produced a particular condition. The exact flags differ among architectures.
Suppose: R1 = 10 R2 = 10 CPU performs: R1 - R2 Result: 0 The processor may set a Zero Flag. Zero Flag = 1
A later conditional branch instruction can examine such a flag to decide whether control flow should change.
Some architectures use registers specifically in address calculations. A base register can contain a starting address, while an index register can contribute an offset used to locate an element within a data structure such as an array.
Base address = 4000 Index offset = 24 Effective address: 4000 + 24 = 4024
This type of register-based addressing allows the processor to calculate memory locations efficiently without requiring the complete address to be written directly into every instruction.
| Category | Typical Role | Example |
|---|---|---|
| Special-purpose register | Performs a defined architectural or control function | Program Counter |
| Special-purpose register | Holds the current instruction | Instruction Register |
| Memory-related register | Contains a memory address | MAR |
| Memory-related register | Contains data moving between CPU and memory | MDR |
| General-purpose register | Stores operands and temporary values | R1, R2, R3 |
| Status register | Records conditions produced by operations | Flag Register |
Registers become easier to understand when we follow a complete instruction cycle. The exact sequence varies between architectures, but a simplified model demonstrates the purpose of the major registers.
PC contains the address of the next instruction. PC → MAR
The address is supplied to the memory system so that the instruction can be retrieved.
Memory → MDR
The fetched instruction temporarily arrives through the memory-data path.
MDR → IR
The instruction is now available to the control unit for decoding.
PC is advanced to the next instruction address.
If the current instruction changes program flow, such as a branch, the PC may instead receive a different target address.
Operands may be obtained from registers. Example: R1 = 35 R2 = 15 ALU operation: R3 = R1 + R2 Result: R3 = 50
This simplified sequence shows that registers are not isolated storage boxes. They form part of the communication path between the control unit, ALU, memory system, and instruction flow.
A register transfer occurs when binary information is moved from one register to another. Register-transfer notation is often used in Computer Organization to describe such operations clearly.
R2 ← R1
This means that the current contents of R1 are transferred into R2. The original value in R1 normally remains unchanged unless another operation modifies it.
Another example is:
MAR ← PC
This represents transferring the address held by the Program Counter into the Memory Address Register.
Register-transfer operations are useful when describing the internal sequence of CPU operations at a more detailed hardware level.
The Arithmetic Logic Unit performs operations such as addition, subtraction, comparison, AND, OR, and other logical functions. Registers provide the ALU with the values required for those operations and provide locations for storing their results.
+----------------+
R1 ---> | |
| ALU | ---> Result
R2 ---> | |
+----------------+
|
v
R3
For example, if R1 contains 20 and R2 contains 6, the ALU can calculate their sum and place the resulting value into a destination register according to the instruction being executed.
| Feature | Registers | Main Memory |
|---|---|---|
| Location | Inside or directly associated with the CPU | Separate memory subsystem |
| Capacity | Very small | Much larger |
| Primary purpose | Immediate CPU operations and temporary storage | Storage of active programs and data |
| Access | Designed for extremely fast processor access | Slower than register access |
| Typical examples | PC, IR, R1, R2, status register | RAM locations |
It is therefore incorrect to think of registers as a replacement for main memory. Registers and memory serve different purposes. Registers provide a small working area for the processor, while main memory provides substantially more storage for programs and data currently in use.
| Register | Question It Answers | Main Information Stored |
|---|---|---|
| PC | Where should the next instruction come from? | Instruction address |
| IR | Which instruction is currently being processed? | Current instruction |
| MAR | Which memory location is being accessed? | Memory address |
| MDR | What data is moving between CPU and memory? | Data or instruction being transferred |
| ACC | Where can an intermediate calculation result be kept? | Arithmetic or logical result |
| General-purpose register | What temporary value does the instruction need? | Operand, address, result, or other program data |
| Status register | What condition resulted from an operation? | Flags and processor status information |
| Incorrect Understanding | Correct Understanding |
|---|---|
| PC stores the instruction itself. | PC stores information used to identify the next instruction address; the instruction itself is placed in the instruction-processing path. |
| MAR contains the data retrieved from memory. | MAR identifies the memory location. Data transferred to or from memory is handled through the memory-data path, commonly represented by MDR. |
| All processors have exactly the same registers. | Register sets and names depend on the processor architecture. |
| Registers can replace RAM. | Registers are very small working storage, while RAM provides much larger storage for active programs and data. |
| The accumulator is mandatory in every modern CPU. | The accumulator is an important concept in certain processor designs, but modern architectures may rely primarily on general-purpose registers. |
| Every register is used for arithmetic. | Many registers serve control, addressing, status, or instruction-management functions rather than arithmetic. |
Registers are essential components of a CPU because they provide fast storage for the information needed during instruction execution. Their capacity is small compared with main memory, but their proximity to the processor makes them extremely important for the execution of instructions.
Different registers have different responsibilities. The Program Counter helps maintain instruction flow, the Instruction Register holds the instruction being processed, and the MAR and MDR are involved in communication with memory. General-purpose registers provide flexible working storage, while status registers record conditions produced by processor operations. The accumulator is particularly important in understanding accumulator-based processor designs.
The most useful way to understand registers is not to memorize their names independently, but to follow how information moves between them during instruction execution. Once this relationship is clear, concepts such as the instruction cycle, register transfer, ALU operations, addressing, and CPU control become much easier to understand.
In the next chapter, we will examine the Instruction Cycle in detail and trace how a processor fetches, decodes, executes, and completes an instruction.