🟨 Quick Recap
Last time, we met the registers — tiny memory boxes inside the CPU that hold numbers, instructions, and quick results.
But just holding numbers isn’t enough, right?
Computers also need to do things with those numbers — like add, compare, or check if something is true.
For that, the CPU has a very smart helper.
It’s called the ALU — short for Arithmetic and Logic Unit.
Let’s break that down and see how it really works.
🟦 What Is the Arithmetic and Logic Unit (ALU)?
The ALU is like the calculator inside your computer’s brain.
-
“Arithmetic” means math — like adding, subtracting, multiplying.
-
“Logic” means checking things — like asking yes/no questions or comparing numbers.
The ALU is not big. It’s a tiny part of the CPU.
But it’s super powerful because every little decision your computer makes goes through it.
You can think of the ALU as the math and thinking part of the CPU.
🟥 Why Does the CPU Need an ALU?
Let’s say your computer needs to do this:
“If the score is greater than 100, show a message that says ‘You Win!’”
To do that, it must:
-
Compare the score to 100
-
Decide if the score is bigger
-
Send a signal to show the message
All of that happens inside the ALU.
Whether you’re:
-
Adding numbers in a spreadsheet
-
Clicking buttons in a game
-
Sorting photos by date
The ALU is quietly working behind the scenes — fast and nonstop.
🟧 What Does the ALU Do?
The ALU can do two kinds of jobs:
1. Arithmetic (Math):
-
Add numbers
-
Subtract numbers
-
Sometimes even multiply or divide (in fancy CPUs)
2. Logic:
-
Is this number bigger than that one?
-
Are these two numbers the same?
-
Is this number zero?
These might sound simple — but when done millions of times per second, they become super powerful.
🟪 How Does the ALU Work?
Let’s keep it simple.
Everything in a computer is just 1s and 0s — remember?
So, the ALU works by flipping switches in a special way to:
-
Add two sets of 1s and 0s
-
Check if one set is bigger than another
-
Find out if something is true or false
It uses something called logic gates to do this. You already saw a bit of that in the last course on How Computers Work — like:
-
AND gate: Only says “yes” if both things are true
-
OR gate: Says “yes” if at least one is true
-
NOT gate: Flips a “yes” to “no” and vice versa
The ALU is full of these gates, wired up in smart ways.
🟫 Real Example: Adding Two Numbers
Let’s say you want to add 3 + 5.
That looks easy, right?
But the ALU sees it like this:
-
3 is 00000011 (in binary)
-
5 is 00000101
The ALU takes these 1s and 0s and flips its switches to add them — just like you’d add digits on paper.
It checks:
-
What’s the 1st bit of each number?
-
Should it carry over a 1?
-
What’s the total?
It does this bit by bit — and super fast.
The answer comes out: 00001000 — which is 8!
🎮 Logic Example: “Did You Win?”
Now let’s say your score is 120, and the game checks:
“Is score greater than 100?”
Here’s what happens:
-
The score (120) goes into one register
-
The number 100 goes into another
-
The ALU compares them
-
If 120 > 100, the ALU says “Yes” (true)
-
That “yes” goes to another part of the CPU, which shows the winning screen
So every little game check?
That’s the ALU doing its job!
🔁 The ALU + Registers = Fast Thinking
Let’s see how these two work together:
-
Registers hold the numbers
-
The ALU uses those numbers
-
It does math or makes decisions
-
Then puts the result back into a register
And it does all of this again and again, millions of times per second.
🧠 What Makes the ALU So Amazing?
-
It’s tiny but super smart
-
It works only with 1s and 0s — but can solve huge problems
-
It helps the CPU think, compare, and do math
-
Every app or game you use depends on it
-
Without the ALU, the computer can’t make decisions
Even AI, robots, and smart assistants — they all rely on ALUs at their core.
🧠 Super Simple Recap
-
The ALU is the part of the CPU that does math and logic
-
It adds, subtracts, compares numbers, and makes choices
-
It works only with 1s and 0s using logic gates
-
It teams up with registers to solve problems fast
-
Every tiny instruction in a computer needs the ALU’s help