CPU registers and their functions

 CPU registers and their functions

Introduction:

The program is stored in the main memory of the computer network system on contiguous memory locations. The data of any kind is also loaded into the computer's memory before the processing starts and then the control is given to the CPU. the Central Processing Unit needs storage areas where the data of any kind can be stored temporarily.

Definition:

As these storage areas are used frequently so for efficiency this special-purpose temporary storage of data areas is provided within the  CPU (Central Processing Unit) for enhancing the performance of the CPU (Central Processing Unit). These special purposes storage areas of data are called registers.

CPU Register:


CPU

PC (Program Counter):

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

IR (Instruction Register):

Once the instruction is fetched of any type of data it is stored in the IR (Instruction Register) where this instruction is decoded.

MAR (Memory Address Register):

When the CPU (Central Processing Unit) wants to store some data of any type in the memory or reads the data from the memory, it places the address of the required memory location in the MAR to the required data.

MBR(Memory Buffer Register):

The CPU uses this register to store data coming from the memory of going to the memory.

Stack Pointer:

To understand the purpose of this register it is important to understand very important data of any type of structure  (Arrangement of data) known as a stack.

GPR(General Purpose Registers):

These data registers of computers are called EAX  EBX  ECX EDX and can be used for any mathematical or logical operations. These are used for arithmetic and data movement purposes. Each can be divided into an upper case byte and lower case byte called AH, AL, BH, BL, CH, CL, DH, DL, respectively. A stand for Accumulator, B for the base, C for the count, D for data. Each of these data registers of the computer system can alternately be used as one byte, two-byte, or four-byte registers.

General Purpose Register:

AX (Accumalator Register):

It is used for arithmetic and data operations in this register.

BX (Base Register):

It is used for arithmetic and data movement and special addressing abilities in this computer system.

CX (Counter Register):

It is used for counting purposes. Acts as a counter for repeating or looping in its register.

DX (Data):

It has a special role in division and multiplication.

Addresses or Segment Registers:

The addresses or segment register is a group of four (4), sometimes registers named CS, DS, ES, SS. The segment register is used as a 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 of a required document

DS (Data Segment):

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

ES (Extra Segment):

The ES (Extra Segment) register is an additional base location for the memory variables in a computer system.

SS (Stack Segment):

The SS (Stack Segment) register contains the base location of the current program stack of a system.
Each has 2-byte. These data registers of a computer system are called segment register and are used in conjunction with either the IP or Instruction Protocol register or two index data registers DI and SI to address various areas of computer system memory. CS is the primary data register or two index data register used to fetch instruction in conjunction with the IP data register. DS is the primary register, used to point our data in the computer memory along with the DI and SI registers.

Computer Operations and the instruction format

We know the basic arithmetic of the computer, now we will learn about different types of operations performed by the computer.

computer-system

Data Transfer Instructions:

All Central Processing Unit provides different instructions of any type for the transfer of data from and to the memory in a system. A programmer can use these instructions to bring data of any type into the CPU and copy data from the Central Processing Unit to the main memory of the computer system. Instructions have the following format.

Arithmetic and Logical instructions:

Another important category of operations a Central Processing Unit can do is Arithmetic and Logical operations that are addition, subtraction, multiplication, and division, etc. Most Central Processing Unit provides the basic arithmetic operations of add, subtract, multiply and divide for signed numbers and floating-point numbers in a system. Logical operations of comparing two numbers, performing XOR of the number, shifting, and rotating a number are some common forms of logical operations provided by the CPU.

I/O Instructions:

Every CPU if users with the operations of reading data from a peripheral device and writing data to a peripheral device. To use these logical or arithmetic operations a programmer may use input and print commands provided by the Central Processing Unit.

Control Transfer:

In all real-world programs, given to the CPU must be repeated several times. To support such logical operations, All Central Processing Units provide its programmers with control flow operations of logical some examples of these operations are
Jump, Jump (Jump if zero)

Instruction set:

Each CPU provides its users with several instructions so that the users can perform different operations supported by the CPU. In this section, we will take an overview of the instruction set provided by the most modern CPU manufactures and see how these instructions are used to solve different problems. 

Instruction Format:

A computer network system will usually have a variety of instruction code formats. It is the function of the control unit within the CPU to interrupt each instruction code and provide the necessary control functions needed to process the instruction.
Each instruction for the Central Processing Unit is specified by giving.
  • A code for the instruction (opcode)
  • Addresses of the operands
Although other things (like addressing mode) are also specified in most general form the instruction is specified in the format given in below.

Zero-Address Instruction Format:

The name "zero-address" is given to this type of computer network system because of the absence of an address field in the computational instructions. A stack-organized network computer system does not use an address field for the instructions ADD and MUL in the data register. The PUSH and POP instruction of data register, however, it needs an address field to specify the operand that communication with the stack of data register

One-Address Instruction Format:

One-Address instructions use an implied accumulator (AC) register for all types of data manipulation. For multiplication and division in this register, there is a need for a second data register.

Two-Address Instruction Format:

For two addresses instruction of data register, each address field can again specify either a possible data register or a memory address. Two- address instructions are the most common in the commercial computer system. Examples of such data register instructions are MOV, ADD, CMP, AND BIS.

Three Address Instruction:

Computers system with three-address instruction formats can use each address field to specify either a processor data register or memory operand. The advantage of the three-address format is that it results in short programs of data register when evaluating an arithmetic expression in the data register. The disadvantage is that the binary-coded instructions required too many bits to specify three addresses in the data register. The instruction formats in the computer are restricted to either three register address fields or two register address fields and one memory address field.

Fetch-decode-execute cycle:

Now that you know the basic architecture of this life cycle of register let us see how the CPU enacts the instructions, specified in a program in this register.
When we want to execute a sequence of instructions in this register those instructions/data are first of all loaded into the main memory of the computer system by using some I/O device.

Fetch Instruction:

The Central Processing Unit reads the value of the PC and the instruction pointed to by PC into the instruction data register of the computer system.
This fetching of instruction involves the following steps:
  • Copy the contents of PC into the MAR and request a memory read in a computer system,
  • Copy the data read from the memory into MBR and instruction than in the IR. Increment PC so that it points to the next instruction into the computer system.

Decode Instruction:

Once the fetching of instruction is completed the CU decodes the instruction by analyzing the opcode of the instruction. It also reads the value of operands specified in the instruction.

Execute Instruction:

After decoding the instruction in the register, the processor executes the instruction by using the activated circuit on a computer system. Then the results of the execution are written back to register and memory.
The CPU repeatedly does these steps. 

These steps are known as Fetch-Decode-Execute Cycle.

Comments

Popular posts from this blog

Modern scenario of information technology:

Techniques for Device Management in an Operating System

computer organization quiz questions with answers