Thursday 10 December 2015

How Registers Work In Cpu

Microprocessors use registers to add numbers.


The Central Processing Unit (CPU), an important part of every computer, is a complex, sophisticated device. Its various parts perform logical comparisons, arithmetic and other operations on data. A CPU has a set of data storage units known as registers; they allow the CPU to execute its various tasks at very high speeds. Depending on the register, it either holds data or points to memory locations that hold data.


CPU


It is in the CPU that most of a computer's real work gets done. The CPU has several subparts, including an Arithmetic and Logic Unit (ALU), a control unit (CU) and registers. The ALU performs basic arithmetic and compares two values to determine if they are equal or if one is larger. The control unit manages the movement of data and instructions in the CPU. The registers come in three main types: data, address and index, which take part in nearly every aspect of the CPU's operation. A register's size depends on the CPU; simple CPUs have registers that hold eight or 16 data bits, more complex ones have 32, 48 or 64-bit registers.


Data Registers


A CPU can operate on data in one of three modes: between two registers, between registers and a Random-Access Memory (RAM) location and between two RAM locations. Because the CPU is wired directly to the registers, operations involving two registers are the fastest; those between RAM locations are the slowest. For example, it adds two registers together, it adds a register to a RAM location or it adds two RAM locations. The CPU must first load data from RAM into registers before it can use them; this takes time, but once done, subsequent register operations run quickly. Simple CPUs have two data registers; more advanced ones have several.


Address Registers


For a CPU to store or retrieve data in RAM, it must have the data's memory address. Those operations involving RAM use memory address registers. The CPU does not perform arithmetic on these registers; rather, it uses them to locate data it needs. For example, a program stores your first name beginning at RAM memory location 100,000. The CPU processes your first name by moving the number 100,000 to an address register, then moving each letter to a data register until it reaches the end of the name.


Index Register


A CPU cannot do math on data registers, although it can do it indirectly with an index register. The index register works with the data registers, allowing a program to process strings of data efficiently. To process your first name, for example, a program moves 100,000 to an address register and zero to the index register. An indexed operation adds the index value to the data register, retrieving the letter at location 100,000. Next, the program increments the index by one and gets the next letter. It repeats this process until it has moved the whole name. By itself, the index register does little; its value is that it gives greater speed and convenience to address registers.

Tags: index register, data registers, first name, your first, your first name, address register, address registers