6.6. The Machine CycleΒΆ

When software is installed onto a modern day personal computer (by downloading it from the Internet or installing off a disk), code comprising the program and any associated files is stored on the hard drive. This code comprises of a series of instructions for performing designated tasks, and data associated with these instructions. The code remains there until the user chooses to execute the program in question, on which point sections of the code are loaded into the computers memory.

Execution

In this tutorial, we are focusing on the step 4 in the diagram above - the process of getting instructions from main memory to the CPU and executing them. This process consists of three stages: fetching the instruction, decoding the instruction, and executing the instruction - these three steps are known as the machine cycle. A processor spends all of its time in this cycle, after executing an instruction it simply fetches the next instruction and gets to work on it.

Instruction Cycle

The animation below demonstrates a simple program running on computer. This imaginary computer shown uses special registers to hold memory address (MAR) and data that just came in from memory (MBR). It also uses registers called AL and BL to hold values temporarily. Don’t worry about the details of those other registers, focus on the fetch/decode/execute cycle and how the PC and IR are used.

Instruction Cycle
Press the green play button to start the animation.
Materials on this page adapted with permission from:
Microprocessor Tutorial by Matthew Eastaugh