Course Content
Part 1: What Does the CPU Really Do?
What Is a CPU and Why Is It So Important? The Difference Between RAM, Storage, and the CPU What Happens When You Click a Button on Your Computer?
0/4
Part 5: How the CPU Talks to Memory and Storage
This part will explain how the CPU and memory are like two people trying to talk across a busy room — and why the CPU needs clever helpers like RAM and cache instead of going straight to the hard drive.
0/4
Part 6: Paths and Highways: How CPUs Talk to Everything
So far, we’ve learned how the CPU works with RAM, cache, and storage. But the CPU doesn’t live alone — it has to talk to memory, graphics cards, USB sticks, and more.
0/4
How Computers Think: Inside the CPU

🧩 Quick Recap from Last Time

In the last lesson, we learned what an instruction is — a tiny command that tells the CPU what to do.
Each instruction is made of 0s and 1s, and the CPU understands only those.

We also learned that instructions are super simple — like “add two numbers” or “move this to that” — but many of them together can do big things.

Now you might be wondering…

“Where do these instructions come from?”
“How does the CPU find them?”
“Who tells the CPU what to do first, and then next?”

Let’s find out.

 

🧠 The CPU’s Reading Trick: One by One by One

Imagine you’re solving a puzzle.

You follow steps:
Step 1 → Step 2 → Step 3…

The CPU does the same thing — it follows instructions from top to bottom, one by one.

But how does it know which instruction to read first?

There’s a special helper inside the CPU that keeps track.

 

🎯 The Program Counter — The CPU’s Finger

Inside the CPU, there’s something called a Program Counter.

Don’t worry — it’s not scary.
It’s just a tiny part that remembers where the next instruction is.

You can think of it like a finger pointing to a page in a book.

  • The CPU opens the book of instructions (stored in memory).

  • The Program Counter points to the first line.

  • The CPU reads that line and does what it says.

  • Then it moves the finger down to the next line.

  • Over and over again!

Every time the CPU finishes one instruction, the Program Counter adds 1 (or 2, or more) and jumps to the next one.

 

🧃 Where Are the Instructions Kept?

Remember how we talked about memory in earlier parts?

The instructions are stored in a special part of RAM (Random Access Memory).
When you open a game or app, its instructions are loaded into RAM.

The CPU reaches into RAM, grabs the next instruction, and gets to work.

 

🚚 Step 1: Fetch

This is called the fetch step.
It means: “Go get the next instruction.”

  • The Program Counter tells the CPU, “Get this one next!”

  • The CPU looks in memory, finds the right spot, and grabs the instruction made of 0s and 1s.

 

🧮 Step 2: Decode

Now the CPU has to decode the instruction.

That means: “Figure out what this instruction is telling me to do.”

  • Is it an “add” instruction?

  • Is it a “move” instruction?

  • Is it a “compare” instruction?

The CPU has a built-in instruction decoder.
It checks the 0s and 1s and says, “Aha! This means add these two numbers.”

 

🧰 Step 3: Execute

This is the exciting part.

The CPU now does the action.

  • If it was “add,” it adds.

  • If it was “move,” it moves.

  • If it was “jump,” it changes where the Program Counter points.

Boom — one instruction done!

 

🔁 Over and Over Again

The CPU repeats this over and over:

  1. Fetch → Get next instruction from memory

  2. Decode → Understand what the instruction is

  3. Execute → Do the thing it says

This happens so fast, it’s like magic.
Modern CPUs do this billions of times per second.

Even blinking your eyes is slow compared to a CPU finishing thousands of instructions.

 

🎮 Example: Pressing the Space Bar

Let’s say you press the space bar in a typing app.

Here’s what might happen:

  • The keyboard tells the computer, “The space bar was pressed!”

  • The CPU gets an instruction: “Put a space on the screen here.”

  • It fetches that instruction from memory.

  • It decodes it: “Oh! This means to show a space character.”

  • It executes it: The space shows up on your screen.

All of this happens in a tiny, tiny fraction of a second.

 

🧠 What If You Want to Do Something Different?

Sometimes, an instruction says:

“If this number is bigger than that one, jump to a different instruction.”

That’s called a conditional jump. It lets your programs change paths like a choose-your-own-adventure story.

The Program Counter then jumps to a new spot in memory instead of just going to the next line.

That’s how games work, how apps make choices, and how programs don’t just go in straight lines.

 

💡 Little Details That Matter

Let’s add some technical truths — explained simply:

  • Instructions have different sizes: Some take up 1 “word,” others take 2 or 3.

  • The Program Counter needs to know how big each instruction is so it can jump to the next one correctly.

  • CPUs don’t just fetch instructions one at a time. Some guess ahead (called prefetching — we’ll learn later).

  • Instructions often use registers, which are the fastest places to store numbers inside the CPU.

Don’t worry if that’s a lot. Just know: fetch → decode → execute is the brain’s loop!

 

🧠 Recap

  • The CPU reads instructions one by one using a Program Counter

  • Instructions live in memory, usually RAM

  • The CPU fetchesdecodesexecutes instructions

  • This loop happens billions of times every second

  • Some instructions tell the CPU to jump to a different spot — that’s how programs make choices

 

0% Complete