• Black Twitter Icon
  • Facebook

Copyright © 2018 My revision - All Rights Reserved.

See a problem, or notice something we're missing? Please feel free to contact us here.

CPU

CPU (Central Processing Unit) is the 'brains' of the computer where the execution of a sequence of stored instructions called programs take place.

The CPU is responsible for executing a sequence of stored instructions called a program. This program will take inputs from any device, process the input in some way and output the results to an output device.

The CPU carries out the fetch-decode-execute cycle.

The fetch-decode-execute cycle

The main job of the CPU is to execute programs using the fetch-decode-execute cycle. this cycle begins as soon as you turn the computer on.

Executing a program - the program code is copied from secondary storage into the main memory. The CPU's program counter is set to the memory location where the first instruction in the program has been stored.  the program is now running.

Every machine code instruction takes up a memory slot in the main memory. These slots have a unique memory address and tell the CPU in what order they should be carried out.

When a program is executed, the CPU runs the fetch-decode-execute cycle. This cycle repeats until it reaches a STOP instruction.

Step-by-Step of the fetch-decode-execute cycle

  1. The processor checks the program counter to see which instruction to run next.

  2. The program counter gives an address value in the memory of where the next instruction is.

  3. The processor fetches the instruction value from this memory location.

  4. Once the instruction has been fetched, it needs to be decoded and executed. For example, this could involve taking one value, putting it into the ALU, then taking a different value from a register and adding the two together.

  5. Once this is complete, the processor goes back to the program counter to find the next instruction.

  6. This cycle is repeated until the program ends.