what is Registers - Basic Programming Knowledge

what is Registers

February 23, 2019

Registers
A register is a small high-speed memory inside CPU. The CPU contains a number of
registers. Registers are used to store information being processed. These are temporary
storage areas for instructions or data. The temporary results during processing are also Stored in registers. Each register has a predefined function.


                                                             


Register size determines how much information it can store. The size of registers in
bytes. Each byte can store one character of data. A register can be of 1, 2, 4 or 8 bytes. Bigger size of register increases the performance of CPU. Control unit manages registers for the following purposes:
  • 1.      Input the instructions or data
  • 2.      Store the instructions or data
  • 3.      Transfer the instructions or data
  • 4.  Perform arithmetic or logical operations at high speed.

Different registers are as follows:
1. Memory Address Register (MAR)
Memory address register is used to store memory address being used by the CPU.
When CPU wants to read or write data in memory, it stores the address of that memory
location in this register.
2. Memory Buffer Register (MBR)
Memory buffer register is used to store the data coming from the memory or going to
the memory.
3. Program Counter (PC)
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 program counter is incremented. It
now refers to the next instruction.
4. Instruction Register (IR)
Instruction register is used to store the fetched instructions. The instruction is also
decoded in this register.
5. Accumulative Registers
Accumulative registers are used in mathematical and logical operations. These
registers are part of ALU. Accumulator register is a general-purpose register. There are four
types of accumulative registers called EAX, EBX, ECX and EDX.
The size of these registers can be 1 to 4 bytes. The two-byte data registers AX, BX, CX,
DX contain two parts of 8-bit size. These parts are separately accessible. The lower-order
bytes are AL, BL, CL and DL. The high-order bytes are AH, BH, CH and DH.
6.Address or Segment Registers
Segment is a block of memory. Address or segment registers are used to store the
address of memory blocks of the instruction being executed. There are four segment registers. These are CS, DS, ES and SS. The size of each register is two bytes. These registers are used with IP register or index registers DI and SI.
7.Stack Control Register
A stack is set of memory locations in which data is stored and retrieved in an order.
This order is called Last-In-First-Out (LIFO). The data item stored at the top of stack is
retrieved before retrieving the item below it.
Stack control registers are used to manage stack in computer. Two special registers SP
and BP are used for this purpose. DI, SI, SP & BP can either be used as 2 byte register or 4
byte registers.