Skip to content

How Does the CPU Execute a Program

Last Updated on 2021-10-20 by Clay

Central Processing Unit is referred to as CPU, its main job is to execute the program using the so-called fetch-decode-execute cycle.

  • Fetch: Fetch the commands from memory
  • Decode: Decode the commands
  • Execute: Execute the commands

The detailed steps as follows:

  1. The Processor checks the Program Counter (PC) to confirm the next instruction to be executed.
  2. The Program Counter gives the memory address of the instruction to be executed.
  3. The processor fetch the instruction value from the memory.
  4. After fetching the instruction, decode it and execute it. For example: take a value into the Arithmetic Logic Unit (ALU), and take a different value from the register and add the two values.
  5. After completing the instruction, the processor returns to the program counter to confirm the next instruction to run
  6. Repeat this cycle until the end of the program

References


Read More

Tags:

Leave a ReplyCancel reply

Exit mobile version