-
Notifications
You must be signed in to change notification settings - Fork 51
/
howcomputerswork.tex
71 lines (53 loc) · 4.91 KB
/
howcomputerswork.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
\chapter{How Computers Work}
Did you know that many computer experts and programmers learned how to
use computers when they were still small children?
Home computers only became common in the early 1980s. They were so new,
that people would often write programs to do
what they wanted to do, because no software existed to do the job for them.
It was also quite common for people working in all
sorts of office jobs to learn how to program the computers they used for
their jobs. For example, the people processing payroll
for a company would often learn how to program the computer to calculate
everyone's pay!
Things have changed a lot since then, though.
Now most people choose existing programs or apps to do what they need,
and think that programming is a specialised skill that only some people
have the ability to learn.
But this isn't true. Of course, like every other field of pursuit
everyone will be better at some things than others,
whether it be sports, knitting, maths or writing. But almost
everyone is able to learn enough to help them in their life.
We created the MEGA65, because we believe that YOU can learn to
program, so that computers can be more useful to you, and as with
learning any new skill, that you can have the satisfaction, enjoyment,
and new adventures that this brings!
\phantomsection
\section{Computers are stupid. Really stupid}
How can this be so? Computers are able to do so many different things, often thousands of times faster than a person can.
So how can we say that computers are stupid? The answer is that no computer can do anything that it hasn't been instructed
by a person to do. Even the latest Artificial Intelligence systems were instructed how to learn (or how to learn, how to learn).
To understand why this is so, it is helpful to understand how computers really work.
\subsection{Making an Egg Cup Computer}
The heart of a computer is its Central Processing Unit, or CPU for short. Many modern computers have more than one CPU, but let's keep
things simple to begin with. The CPU has a set of simple instructions that it understands, like, ``get the thing from cup \#21,'' ``put this thing into cup \#403,'' ``add these things together,'' or ``do the following instruction, but only if the thing in cup \#712 is the number 3.''
But what do we mean with all of these ``things'' and ``cups''? Let's start by thinking about how we could pretend to be a computer using
just an empty egg carton, some small pieces of paper and a pencil or pen. Start by writing numbers, beginning with one, in each of the
little egg cups in the egg carton. Then write the number zero on a little scrap of paper and put it in the first cup. Do the same for the other cups. You should now have an egg carton with numbered cups, and with every cup having a scrap of paper with the number zero written on it. Now we just need to decide on a few simple rules that will explain how our egg-cup computer will work:
\begin{itemize}
\item First, each cup is allowed to hold exactly one thing at a time. Never more. Never less. This is so that when we ask the question ``what is in box such-and-such,'' that there is a single clear answer. It's also how computer memory works: Each piece of memory can hold only one thing at a time.
\item Second, we need a way for the computer to know what to do next. On most computers this is called the Program Counter, or PC, for short (not to be confused with PC when people are talking about a Personal Computer). The PC is just the number of the next memory location (or in our case, egg-cup), that the computer will examine, when deciding what to do next. You might like to have another piece of paper that you can use to write the PC number on as you go along.
\item Third, we need to have a list of things that the egg-cup computer will do, based on what number is in the egg-cup indicated by the
PC.
\end{itemize}
So let's come up with the set of things that the computer can do, based on the number in the egg-cup indicated by the PC. We'll keep things simple with just the following:
\begin{center}
\begin{longtable}{|R{2.2cm}|p{8cm}|}
\hline
{\textbf{Number in the egg-cup}} & {\textbf{Action}} \\ \hhline{|=|=|}
0 & {i) Add one to the PC, and do nothing else.} \\ \hline
1 & {i) Add one to the PC. \hfill\break ii) Set the PC to be the number stored in that egg-cup.} \\ \hline
2 & {i) Add one to the PC. \hfill\break ii) Add the number in the egg-cup indicated by the PC to the number in the egg-cup indicated by the number in the egg-cup following that. \hfill\break iii) Put the answer in the egg-cup indicated by the egg-cup following that. \hfill\break iv) Finally, add two more to the PC, to skip over the egg-cups that we made use of.} \\ \hline
\end{longtable}
\end{center}
Don't worry if that sounds a bit confusing for now, especially that last one -- we will go through it in detail very soon!
The best way to explain it is to go through some examples.