โจ What is a Register?
- A Register is a small, high-speed memory location inside the CPU.
- It is used to store data, instructions, addresses, or intermediate results temporarily during processing.
๐ Simple Definition:
“Registers are fast memory units inside the CPU that hold data and instructions while a program is running.“
โ They are the fastest type of memory because they are directly connected to the CPU circuits.
๐ ๏ธ Key Characteristics of Registers:
| Feature | Description |
|---|---|
| Speed | Very fast (faster than RAM) |
| Size | Very small (few bytes or bits) |
| Location | Inside the CPU |
| Access | Directly by the Control Unit or ALU |
| Purpose | Temporary storage of important data during execution |
๐ฏ Why are Registers Needed?
- To hold operands for the CPU to perform calculations.
- To store results after computation.
- To hold memory addresses that the CPU needs to access.
- To control the operation of the CPU (using special control registers).
๐ Types of Registers
Registers can be classified based on their purpose:
| Type of Register | Purpose |
|---|---|
| Accumulator (AC) | Stores intermediate arithmetic and logic results |
| Program Counter (PC) | Holds the address of the next instruction to execute |
| Instruction Register (IR) | Holds the current instruction being executed |
| Memory Address Register (MAR) | Holds the address of memory where data needs to be read/written |
| Memory Data Register (MDR) | Holds the data read from or written to memory |
| General Purpose Registers | Used by the programmer for temporary data storage |
| Status Register / Flag Register | Stores flags (zero, carry, overflow, etc.) after operations |
๐๏ธ Diagram: CPU and Registers
+----------------------------------+
| CPU |
| +--------+ +--------+ +--------+ |
| | AC | | PC | | IR | |
| +--------+ +--------+ +--------+ |
| +--------+ +--------+ +--------+ |
| | MAR | | MDR | | FLAGS | |
| +--------+ +--------+ +--------+ |
| ALU + CU |
+----------------------------------+
โ๏ธ Working of Registers (Simple Steps):
- Fetch:
- Program Counter (PC) gives the address of the next instruction.
- Decode:
- Instruction is fetched into the Instruction Register (IR) and decoded.
- Execute:
- Data is fetched into General Purpose Registers or Accumulator (AC).
- ALU uses these registers for calculations.
- Store:
- Result stored back in registers or memory.
๐ Important Registers Explained:
๐ 1. Accumulator (AC)
- Used for temporary storage of intermediate arithmetic results.
- Example: After addition, the sum is stored in AC.
๐ 2. Program Counter (PC)
- Points to the address of the next instruction.
- Automatically increments after each instruction.
๐ 3. Instruction Register (IR)
- Holds the current instruction that is being decoded/executed.
๐ 4. Memory Address Register (MAR)
- Contains the memory address from where data needs to be fetched or written.
๐ 5. Memory Data Register (MDR)
- Temporarily holds the data being transferred to/from memory.
๐ 6. Status / Flag Register
- Stores status flags:
- Zero (Z): Result is zero
- Carry (C): Carry out after addition
- Sign (S): Result is negative
- Overflow (O): Arithmetic overflow
๐ข Important Points to Remember:
โ
Registers are the fastest memory.
โ
Registers are limited in number (few tens only).
โ
Efficient register use = Faster CPU performance.
โ
Registers are hardware-controlled, not usually visible to programmers (except General Purpose Registers).
๐ Summary:
“Registers are tiny, high-speed storage areas inside the CPU that temporarily hold data, instructions, or addresses during processing. They play a key role in speeding up computer operations.“
๐ Quick Memory Trick:
Registers = Fast Memory for CPU's working table!
