1.1 The characteristics of contemporary processors, input, output and storage devices
1.2 Software and Software Development
1.3 Exchanging Data
1.4 Data Structures & Types
1.5 Legal, Moral, Cultural, and Ethical Issues
2.1 Elements of Computational Thinking
2.2 Programming Techniques & Methods
2.3 Algorithms
The Programming Project (NEA)

The Fetch Decode Execute Cycle

The Fetch Decode Execute Cycle, also known as the Fetch Execute Cycle is the foundation of how all computers work.

Purpose of the CPU - fetch decode execute

When computers were first created, basic instructions were provided directly to the computer along with the data to be used. The machine claimed to be the first real computer was the Difference Engine, created by Charles Babbage and programmed by Ada Lovelace.

Today, our machines are far more complex and use a system known as the Stored Program Concept. What this means is that both our instructions and data are stored in the same format…. binary!

In order for the computer to understand what is instruction and what is data, it needs to perform a set of tasks that fetches the required information, understands it, then processes it. This is known as the Fetch, Decode, Execute Cycle (also referred to as the Fetch Execute Cycle).

Fetch

In this stage, the processor gets the next instruction from main memory along with any data needed and holds these in special memory locations called registers.

Decode

Once the required information is obtained from the main memory, the processor has to decode the binary into two parts. The first part is the instruction, and at this stage of the cycle is called the Opcode.

The second part is the data which is referred to as the Operand.

These words should be familiar to you from maths. When you perform a mathematical calculation, the Operator (what we called the Opcode) is the function to be performed. Eg. Add, or subtract. Whereas the data/numbers to be operated upon is called the Operand… the same!

Execute

Finally, the processor knows what to do with the instruction and data and can complete the task. Once the outcome is known, this is stored in the final register called the Accumulator.

Imagine this as the screen of your calculator that is showing you a running total as you perform more operations.

Grab a calculator and have a go – how does that running total work? (hint. It’s the processor!)

Activity:

One of the best ways to understand the Fetch Decode Execute cycle in detail is to write a short low-level language program using the simulation below called The Little Man Computer. This is a digital simulation of the CPU and primary memory that animates how the FDE cycle runs as a low-level language program is run.

Try typing the following program into the simulation below (you can also see this full screen here) and follow the data around:

INP
STA 11
INP
ADD 11
OUT
HLT 

What happened in the simulation to the data and instructions as they were processed?

Try running the simulation again and identify as many registers & busses as you can alongside what they are carrying around the simulation.