All about CPU

By Matt Wright

What Is a CPU

The CPU (Central processing unit) is the hardware within a computer system which carries out the instructions of a computer program by performing the basic arithmetical, logical, and input/output operations of the system. A CPU has four primary functions: fetch, decode, execute and writeback.


the CPU retrieves the instruction that it needs to run from program memory. Each instruction in a program is stored at a specific address. The CPU has a program counter, which keeps track of the CPU’s position in the program, specifically, the address of the instruction that the CPU is accessing.


A compiler breaks down the code the program is written in and changes it into 'assembly language'. Assembly language is a language that the CPU understands, From there on, an 'assembler’ translates Assembly Language into binary code, which the CPU can manipulate to execute the instructions it is given.


Based on the instructions it is given, the CPU can then do one of three things:

1) Using its Arithmetic Logic Unit (ALU), the CPU can calculate extremely complicated mathematical functions;

2) Move data from one memory location to another;

3) Jump to different addresses in the program based on decisions made by the CPU itself.

The diagram below shows the setup of an extremely simple microprocessor capable of performing these actions.

Big image

Write Back

Typically, each of the actions taken by the CPU produces some sort of output. The CPU takes this output and writes it into the computer’s memory. For example, if a program wanted to execute the first item of the list above on two operands, 3 and 5, the output, 8, would be written back into a specific address. However, for the 3rd bullet, the program counter (which, as stated above, is used to keep track of the CPU’s progress through a program) simply changes to reflect the start of the next set of instructions.

When these four steps have been completed, the Program Counter moves onto the next instruction and repeats the entire process again, until the termination of the program.