The program is stored in the main memory of the computer on contiguous memory locations. The data is also loaded into the computer’s memory before the processing starts and then the control is given to the CPU. The CPU needs storage areas where the data can be stored temporarily.

As these storage areas are used frequently, so for efficiency these special purpose temporary storage area are provided within the CPU for enhancing the performance of the CPU. These special purpose storage areas are called registers. The figure 5.9 given below shows the most commonly used CPU PC (Program Counter):

This register holds the address of the next  instruction to be fetched for execution. As soon this instruction is fetched, its value Is incremented so that it still has the address of next instruction.

CPU Register

Figure 5.9 CPU_Register

IR (Instruction Register): Once the instruction is fetched it is stored in the IR where this instruction is decoded.

MAR (Memory Address Register): When the CPU wants to store some data in the memory or reads the data from the memory, it places the address of the required memory location in the MAR.

MBR (Memory Buffer Register): The CPU uses this register to store data coming from the memory or going to the memory.

Stack Pointer: To understand the purpose of this register it is important to understand a very important data structure (Arrangement of data) called a Stack.

GPR (General Purpose Register): These register are called EAX, EBX, ECX, EDX and can be used for any mathematical or logical operations. These are used for arithmetic and data movement purpose. Each can be divided into an upper case and lower byte called AH, AL, BH, CH, CL, DH, DL respectively. A stand for Accumulator, B for base, C for count and D for data. Each of these registers can alternately be used as one byte, two byte, or four byte registers, AL ( 1 byte ), AH (1 byte), AX (2 byte), EAX (4 byte). We can access 16 bit or 8 bit.

General Purpose Registers

Figure 5.10 General Purpose Registers

AX (Accumulator Register): Used for arithmetic and data operations.

BX (Base Register): Used for arithmetic and data movement and special addressing abilities.

CX (Counter Register): Used for counting purpose. Acts as a counter for repeating or looping.

DX (Data): Has special role in division and multiplication.

Address or Segment Registers: The address or segment register is a group of 4, some times registers named CS, DS, ES,SS. The segment register used as base location for program instruction, data, and the stack.

CS(Code Segment): The CS register holds the base location of all executable instructions (code) in the program.

DS(Data Segment): The DS register is the defaults base location for memory variables. The CPU calculates the offsets of variables using the current value of DS.

ES(Extra Segment): The ES register is an additional base location for the memory variables.

SS(Stack Segment): The SS register contains the base location of the current program stack.

Each has 2-byte. These registers are called segment register and are used in conjunction with either the IP register or two index registers DI and SI to address various areas of computer memory. CS is the primary register or two index register used to fetch instruction in conjunction with the IP register. DS is the primary register, used to point out data in the computer memory along with the DI or SI registers.

Code Segment (CS)

hhhh

Data Segment (DS)

 hhhh

Extra Segment(ES)

  hhhh

Stack Segment (SS)

 hhhh