How do you tell a computer to do something?
So far we've learned the circuit that calculates, the circuit that remembers, and addresses. So how do we tell these parts "do this"? Let's meet the language a computer understands, the instruction.
An instruction is "what" and "where"
A command you give a computer
is very simple.
"Do what" plus
"to where / which."
These two parts and you're done.
For example,
"add, cell 3 and cell 7."
Just like this.
What (add) + where (cell 3 and cell 7).
In human words,
"add cell 3 and cell 7."
Short and clear.
A computer takes these small commands
one by one and runs them.
Each one is called an instruction.
Instructions are written in 0s and 1s too
But a computer
knows no Korean or English.
Only 0s and 1s.
So instructions too
are written in 0s and 1s.
The front part is "what to do,"
the back part is "where."
In fixed places,
in fixed patterns.
The front 4 bits are the kind of command, the back is the target address.
To our eyes
it's just a string of 0s and 1s,
but to the computer
it's a perfect sentence:
"add cell 3 and cell 7."
Look at the fixed places
and the meaning reads exactly.
It knows only a few words
One surprising fact.
A computer knows fewer commands
than you'd think.
Fetch a value,
store a value,
add,
jump somewhere else.
Just a few basic commands like these.
With this small vocabulary,
it does everything.
Chain these simple commands countless times, and you make games and videos.
A small vocabulary is fine.
Just as you write a long story
with short words,
chain these few commands
millions of times
and nothing is impossible.
This is how a computer reads it
So how does a computer
read these 0s and 1s?
It cuts and looks at fixed places.
Look at the front: "ah, it means add,"
look at the back: "it's cell 3 and cell 7."
Reading it split like this
is called decoding.
Press the button.
Cut at fixed places and read out the meaning.
Fixed places,
fixed meanings.
So a computer,
just from 0s and 1s,
figures out exactly
what to do and where.
It's possible because there's an agreement.
Chain instructions and it's a program
One instruction is small,
but chain them in a row
and they get something done.
"Fetch the value in 5,
fetch the value in 6,
add the two."
Three lines like this
make an addition program.
Press run and follow line by line.
A three-line mini program.
What you just saw
is the very bottom of how a computer works.
Every program we use
is, in the end, made of
millions of instructions like these.
Next time we'll see
where subtraction and comparison,
not just addition, happen.