The function of a CPU is similar to that of a calculator, only much more complex and powerful. The CPU performs arithmetic and logical operations on data obtained from the memory or different input devices. The CPU functions as directed by a set of instructions called a program. A program is usually stored in a storage device such as floppy disk, hard disk, or a CD-ROM drive. The program is passed on to the main memory of the computer, which is known as the RAM or Random Access Memory after being read from the storage device. Here, each instruction is given a unique address in the memory so that, the CPU accesses the data it wants, by specifying the memory address of the data stored.
The data flows from the RAM to the CPU, upon execution, through an interface unit called memory bus, which connects the CPU and the RAM. A processing unit inside the CPU called the instruction decoder then decodes the data, before interpreting and implementing the software instructions. From the instruction decoder the data passes on to the Arithmetic Logic Unit (ALU), which performs the necessary calculations.
Frequently accessed data is stored in temporary memory locations called registers. Registers are special types of memory, which are located inside the CPU for faster access of frequently used data. They are faster than the system RAM. The absence of registers would slow down the CPU operations, as it would repeatedly have to go all the way to the main memory and search for the necessary instruction to carry out the specified operations. Different mathematical operations such as add, subtract, divide, multiply and other conditional tests are performed on the data, after which the results are stored back into the RAM for further use. A unit called the program counter is employed during this process, to keep track of each successive instruction, to make sure that the program instructions are followed by the CPU in the correct order.
Branching Instructions
During the execution of a program, the program counter advances sequentially through the instructions. However, sometimes it is required by the CPU to abruptly shift to an instruction location out of sequence. These branches could either be unconditional or conditional. The difference between unconditional and conditional is that the former branch always accesses an out of order instruction stream.
Source:
Please rate this
Poor
Excellent
Votes: 0 |NaN out of 5