Fetch and Execute

When a program is running, it’s instructions are held in storage location in the memory.  The processor starts with the first instruction and repeats the following stages until the program ends.

  1. Address of instructions are placed on the address bus
  2. Contents of locations (instruction’s) are transferred to a register along the data bus
  3. The instructions are decoded and executed

This is known as the fetch and execute cycle

Example

number=int(input(“Please enter a number”)

Address bus – holds the address in memory where the instructions are stored.

Data bus – transfers the instructions from the memory to the registers within the processor.

Control Unit – executes the instructions by requesting input, receives input value from keyboard and temporary stores value in the register.

Address Bus – holds memory location address of number variable

Data bus – transfers value from registers to memory locations