What are CPU Registers?-Types of CPU Registers
The register is a small high-speed memory inside the CPU. It is used to store data and instructions temporarily. Data is stored in registers from the main memory for execution. CPU contains different registers. Every register has a predefined function.
How much data a register can store depends on its size. Register sizes are expressed in bytes. One character of data can be stored in one byte. The size of a register can be 1, 2, 4, or 8. The bigger size of the register increases the performance of the CPU.
There are several types of registers, including general purpose registers (GPR), condition codes, floating point status/control registers, and special purpose registers (SPR).
GPRS is used for general-purpose calculations and arithmetic operations. SPRs are used for specific purposes, such as storing values related to floating point operations.
Condition codes are used to determine if certain conditions have been met. Floating point status/control registers are used to control floating point operations.
Special Purpose Registers
Special Purpose Registers Special-purpose registers are normally used by the CPU. There are different type of special purpose registers.
Program Counter (PC)
The program counter is used to store the address of the next instruction to be fetched for execution. When the instruction is fetched, the value of the program counter is incremented. It now refers to the next instruction.
Instruction Register (IR)
The instruction register is used to store the fetched instructions. The instruction is also decoded in this register.
Memory Address Register (MAR)
A memory address register is used to store the memory address being used by the CPU. When the CPU wants to read or write data in memory, it stores the address of that memory location in this register.
Memory Buffer Register (MBR)
The memory buffer register is a special type of memory location that is used to store data temporarily while it is being processed. In general, the MBR is used to hold temporary information until it is ready to be moved to its final destination.
Stack Pointer Register
The stack pointer is a special register in the CPU that holds the current top-of-the-stack address. When a function returns, the return value is placed at the top of the stack, and the stack pointer is decremented by 1. This order is called Last-In-First-Out (LIFO).
General Purpose Registers
General-purpose registers are used in mathematical and logical operations. These registers are part of ALU.
DX The size of these registers can be 1 to 4 bytes. The two-byte data registers AX, BX, and CX, contain two parts of 8-bit size. The lower-order bytes are AL, BL, CL, and DL. The high-order bytes are AH, BH, CH, and DH.
Accumulator Register (AX)
It is used for arithmetic and data operations. It is a general purpose register.
Base Register (BX)
It is used for arithmetic and data movement. It has special addressing capacities.
Counter Register (CX)
It is used for counting purposes. It acts as a counter for repetitions or loops.
Data Register (DX)
It is used for division and multiplication.