Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: The Basic Principles of Computers
Description: The Basic Principles of Computers for Everyone

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


BUT HOW DO IT KNOW?

The Basic Principles of Computers
For Everyone

By

J
...
Scott, Oldsmar, FL

978-0-615-30376-5

buthowdoitknow
...
Scott
III
artbyalexscott
...
Analog
I Lied – Sort of
Full Disclosure
Philosophy

5

Introduction
The title of this book is the punch line of an old joke
that goes like this:
Joe is a very nice fellow, but has always been a little
slow
...
The salesman
is pitching the miracle new invention, the Thermos
bottle
...
" Joe thinks about this a minute, amazed by
this new invention that is able to make a decision about
which of two different things it is supposed to do
depending on what kind of food you put in it
...
He thought it
must contain a heater and a refrigerator
...
With cold contents,
the outside heat is slowed on its way in, and with hot
contents, the heat is slowed on its way out
...
And eventually, the
contents, hot or cold, do end up at room temperature
...

So the reason for the book title, is that when it comes
to computers, people look at them, see what they can do,
and imagine all sorts of things that must be in these
machines
...
People may assign human qualities to the
machine
...

6

But computers are actually quite easy to understand
...

With the Thermos, the principle is that of the motion of
heat
...
We see
ice cubes melting when they are removed from the
freezer, and we see the hot meal cooling off on the
table when the family is late for dinner
...
If you have observed the fact that
when you turn on a light switch, a light bulb lights up,
and when you turn the switch off, the light goes dark,
then you have observed the principle on which computers
operate
...


7

Just the Facts Ma’am
This book is not primarily intended to be a textbook
...

Its intention is simply to demystify the subject of
computers for anyone who has ever wondered what’s going
on inside of that box
...

But it should be easily understandable by housewives,
senior citizens and children who can read well
...
It requires no previous technical education
...

This book presents the complete essentials that make up
a computer
...
Every part is explained fully, and every
new word is defined thoroughly when it is first used
...

This book is not a ‘dumbed-down’ version of some college
textbook
...
It is a technical book, but so
is a cookbook and so is a driver’s education handbook
...
No matter what
someone already knows about computers, this will fill in
any missing pieces and put them all together into
something that makes sense
...
There are thousands of words and ideas
associated with the field of computers that make the
whole subject seem like a mess
...

In this book, there will not be volumes of trivia about
8

the construction or history of computers, just the
essentials, no more and no less
...

There is nothing to memorize in this book
...
Each idea is
very simple, and one thing leads to the next
...
Each idea is simple and easy
to understand
...

If someone were to write a book about how to build a
house, there could be various levels of detail
...
” That would not be enough
detail for someone who didn’t already have some
experience using a hammer and saw and installing a
faucet and wiring a light switch
...
That would be far too much
information
...

This book attempts to give just enough detail to see
what every computer has in common and how they work, not
how to build the biggest or best computer ever made
...
It is not
about how to use a computer
...
It would not show how to build anything as
complicated as a fancy curved oak staircase
...
It is going to
be a lot simpler than you ever imagined
...
How can they do
what they do? They play games, they draw pictures, they
'know' your credit rating
...
Yet
they are simple
...
And, they can only do one of these simple
things at a time
...
The
result, as in a video game, is very complex in
appearance, but in reality, is very simple, just very
very fast
...
Which simple things are done, and in what
order, determines what sort of task the computer
accomplishes in any given time, but anything the
computer does consists of nothing outside of its limited
capabilities
...

So the secret of computers is not that they are complex,
rather it is their speed
...

Since computers work on electricity, their speed is
related to the speed of electricity
...
That’s pretty darned fast
...
Per the
physicists, electricity has many properties in common
with light, and its speed, when traveling in a wire,
gets slowed down to about half the speed of light
...

As a point of comparison, imagine it is a hot day and
you have an electric fan sitting on the table blowing
11

cool air on you
...
A point on the edge of one
of those blades will only travel about 150 feet in that
second, it will take 35 seconds for that point to travel
just one mile
...
If it did,
that fan would be putting out quite a breeze
...
But electricity
traveling in the same circle would go around about a
hundred million times in one second, that’s two and a
half million times faster than the fan blades
...

A million is a very large number
...
If you then moved the ruler down the page 1/25th
of an inch, and drew another thousand dots, and kept
doing that, you would have to move the ruler down the
page one thousand times, each time drawing one thousand
dots
...
That’s a lot of dots or a lot of anything
...

Now let’s say that the electricity moving around inside
the computer can accomplish some simple task by
traveling one foot
...
Again for
comparison, the fan on the table will spin for 7 hours
to go around just one million times and it will take a
full six months for it to spin around 500 million times
...
And inside these parts are a multitude
more parts that are very close to each other, some just
thousandths of an inch apart
...

There is no point in saying how many things today’s
computers do in a single second, because that would date
this book
...
There is a
theoretical limit to how fast they can go, but engineers
keep finding practical ways to get around the theories
and make machines that go faster and faster
...
They still do the same few
simple things, just faster, cheaper, more reliably and
in a smaller package
...
Each
section has a specific mission, and the combination of
these parts into a machine was a truly marvelous
invention
...


13

Language
In this book, we are going to need to define some words
that are used to describe the parts inside a computer
...

In the world of computers, it seems that the pioneer
inventors were a less formal sort of people
...

Some of the new words are words we already know, used as
a different part of speech, like an existing noun now
used as a verb
...

Each word will be described thoroughly when it is first
used
...
You have
probably heard some of these words before, and figured
out what they meant from how they were used, but now you
will get the proper and full definitions
...


14

Just a Little Bit
What is in a computer? It shows you still pictures,
moving pictures, music, your checkbook, letters you have
written, it plays video games, communicates all around
the world, and much much more
...
There is only one kind of thing
in a computer
...
It
is called a bit
...

The light in your living room (assuming you have a
switch and not a dimmer) can be either on or off
...

What do all of these things have in common? They are all
places that contain a thing that can be in one of two
possible states
...

A bit is some kind of a physical object that has a size
and a location in space, and it has some quality about
itself, that at any given time can be in one of two
possible states, and may be made to change back and
forth between those two states
...
It can be molded into a
ball, a cube, a pancake, a ring, a log, a face or
anything else you can think of
...
If you took that
lump of clay, flattened it out, scratched “yes” on one
side of it, and “no” on the other side, and then put it
in a kiln and fired it until it was hard, then you might
15

be able to call it a bit
...
Then it would only
have two states
...
In a
computer, the bits are not like the coin or the lock,
they are most like the light
...
In a computer, the bits are very, very small and
there are a very large number of bits, but that’s all
that is in there
...
In the living room, there is electricity in the
wall coming into the switch
...
So this bit in the living room
is several feet long, it includes the switch, the wires,
the socket and the light bulb
...
Also, the computer
bit doesn’t have a mechanical switch at one end or a
light bulb at the other
...

Your computer has something resembling switches, like
the keys on the keyboard, and something resembling light
bulbs, like the tiny dots on the screen, but most of the
bits are inside and unseen
...

There are lots and lots of them, and they are arranged
and connected up in various ways, which we will examine
in detail as the book progresses, but this is what is
inside all computers – bits
...

Computer bits aren’t like the coin that has to
physically flip over to change from one state to the
other
...
A computer bit is just a place, if
there is no electricity in that place, then the bit is
16

off
...

If you want to change a coin from showing heads to
showing tails, you have to physically move it to flip it
over, which takes some amount of time
...

As another example, remember the wild American west from
the movies? There were little towns separated by vast
distances
...
In this office was a guy wearing a funny hat who
had a spring-loaded switch called a key, and he would
send messages by pressing this key on and off in certain
patterns that represented the letters of the alphabet
...
The key simply
connected the battery to the wire when it was pressed,
and disconnected the battery when the key was not
pressed
...
The guy in the office
listened to the pattern of the clicking and wrote down
the letters of the message
...

The point of bringing up this subject, is that this
whole telegraph machine, from the key that gets pressed
in one town, through the long wire that travels to
another town many miles away, to the clicker, this whole
apparatus comprises just one single bit
...
And this method of
communication revolutionized the world in many ways
...

So I hope this begins to simplify the subject of
17

computers for you
...
Lots of them to be sure, but when you
understand bits, you understand what’s in there
...
You notice that the
ceiling light is on
...
You look at the
wall next to the door and see a switch plate with two
switches
...
But then you notice that the
switch is already off
...

So then you think “well, maybe someone installed the
switch upside down,” so you decide to flip the switch
anyway
...
So then you decide that it must
be the other switch, and you flip it on, off, on, off
...
You look around, there is no other door,
there are no other switches, no apparent way to turn off
this darned light
...
Then suddenly you notice the ceiling light
flicker off briefly
...
Both
switches say “on”, and the light is now off
...
This is backwards
...
What the
heck? Anyway, you finally figure out how it works
...
If one or the
other or both switches are off, then the ceiling light
is on
...

Now what is the purpose of this little story about the
odd light switches? The answer is, that in this chapter
we are going to present the most basic part that
computers are made of
...

This computer part is a simple device that has three
connections where there may or may not be some
19

electricity
...

Of the three connections, two of them are called
“inputs,” because electricity can be sent to them from
somewhere else
...

This computer part is a device that does something with
bits
...

The way it “decides” is very simple, and is always the
same
...
If
one or both of the inputs are off, then the output will
be on
...

Remember that there is nothing but bits inside the
computer
...
The “decision” that this device makes
is how bits come to be turned on and off in a computer
...
Two
bits come from somewhere else, are examined by the
device, and a new third bit is generated so that it may
go somewhere else
...
how do you get electricity at the
output if both inputs are off?” Well, that is an
excellent question, and the excellent answer is that
every one of these devices is also connected to power
...
This is
where the electricity for the output comes from
...
It is understood that each
part has its power connection, and we don’t worry about
it
...
I wouldn’t
have even mentioned it here except that I figured that
you’d probably ask yourself that question sooner or
later
...
Here is as
complicated as it gets
...
Someone who has an electronics background
could look at what’s in there, and in about 30 seconds
would say “Oh yeah, if both inputs are on, the output
will be off, and for any other combination the output
will be on, just like the book says
...
Someone who
doesn’t know electronics misses out on those few seconds
of understanding, but this book is the same for
everyone
...
In the computer, it takes two switches, and
it’s sort of backwards in that they both have to be on
to turn the light off
...

This type of computer part is in fact the ONLY type of
part required to build a computer
...
So
there you go again, see how simple a computer is? It is
just full of this little type of thing – a lot of them
to be sure, but this is all there is
...
” I can’t find a good reason why it is called a
gate, a gate in a fence lets people through when it is
open, and stops people when it is closed
...

The meaning of this computer term “gate” doesn’t seem to
fit into the common meaning of the word, but sorry, I
didn’t make up the name, that’s just what it is called
...
At least it isn’t some long word
from the ancient Greek
...
We will use drawings like the following
...
The picture on
the left shows a gate complete with its power wires, but
as promised, we won’t be concerned with them for the
rest of this book
...
The two wires on the
left (a and b) are the inputs, and the wire on the right
(c) is the output
...
Each input bit comes
from somewhere else in the computer and is either on or
off depending on what is happening where it came from,
and then this gate sets its output on or off depending
on the states of its two inputs
...

Compare this little chart with the experience with the
odd room with the two light switches
...
The only way to get that light off
is to have both switch ‘a’ and switch ‘b’ on
...
What
we are going to do here is to show two simple things
that are done many times inside any computer
...
Take the gate above, and
take the two input wires, ‘a’ and ‘b,’ and tie them
together
...
They
can still be changed on and off, but ‘a’ and ‘b’ can
never be different
...
Thus the chart of this combination only
has two lines on it, two possibilities:

a

b

c

Off

Off

On

On

On

Off

Actually, since columns ‘a’ and ‘b’ are the same, there
is really only one input and it can be drawn simply like
this with a triangle instead of the ‘D’ shape
...
The ‘a,’
‘b’ and ‘x’ are like the first gate, the ‘x’ and ‘c’ are
like the second gate
...
So to make it simpler to
understand, it is drawn as a single unit like this:

25

The only difference between this picture and the picture
of our original gate is that the little circle after the
big ‘D’ is missing
...

Imagine that this combination of gates was installed in
that room with the two light switches and the ceiling
light
...
So if you walked in there and saw the
light on, and then looked at the switches, you would see
that they were both on
...
You might not notice that if you
turned both off, and then wanted to turn the light back
on, you wouldn’t be able to do it by just flipping one
switch
...

26

This combination gate could be described this way: For
the output to be on, one input AND the other input must
both be on
...

Now to fill in a few details purposely left out above,
the original gate we looked at works like the AND gate
except the output is the opposite, or the negative of
the AND gate
...

The simple gate that had both inputs tied together also
has its own name
...
) If the input is off, the output is not
off (on
...

Notice the difference between the diagrams of the AND
gate and the NAND gate
...
The thing that looks like a large
letter ‘D’ means to do the ‘AND’ function, which means
to take action only if both inputs are on, and the
little circle means switch to the opposite
...
The NOT gate starts with a triangle,
which just means take the input and turn it into an
output
...

The AND gate is used a lot in computers, and it is
probably the easiest to understand, but we looked at the
NAND gate first for two reasons
...
When you have to build a large number of
gates, it will be cheaper and more reliable if you can
use the type of gate that is easiest to build
...
We have already seen that the
NOT gate and the AND gate can be made out of NAND gates,
and we will see a few more interesting combinations as
we go along
...

The problem in this chapter has been that the NAND gate
is the basic building block of computers, but the AND
gate is the first gate that has a name that makes sense
...
Then we built an AND gate,
gave it its name, and went back and named the first two
...
It connects two things,
as in “I like peas and carrots
...
First, it is an adjective, a
word that modifies a noun
...
This is how “AND”
has been used in this chapter
...
” We will
see AND used in this way later in the book
...

And now we see that bits are constructed using gates,
and all gates come down to the NAND gate
...
No kidding! Can you understand
this thing? Then you can understand the whole computer
...
The
second best way is to study it from a book that has a
lot of pictures showing the parts and how they interact
...
It is very boring to watch the inside of a
computer, it doesn’t look like anything is happening at
all
...
The
result is something called a ‘chip,’ which has millions
of electronic parts constructed on its surface
...

The chip is then encased in a piece of plastic that has
pins coming out of it
...
The computer we
are going to ‘build’ in this book could easily fit on
one chip less than a quarter of an inch square
...
The
diagrams we saw in the previous chapter are the best way
to show how a computer works, so we’d better get pretty
good at reading them
...
We will
describe what the new part does, and then give it a name
and its own symbol
...
Before you know it, we will have assembled a
complete computer
...
If this is done faithfully with each
one, you will very shortly see exactly how a computer
works
...

When electricity comes out of the output of a gate, the
electricity travels through the whole wire as fast as it
can go
...
If the output of a gate is off,
the whole wire is off
...

The inputs of gates do not use up the electricity in the
wire, so one output may be connected to the input of one
or many gates
...
When wires cross on a diagram without a dot,
it means that there is no connection between them, they
are not touching, the two bits are separate
...
However,
there will be many exceptions to this, especially later
on in the book
...

Most of the diagrams in the book are very easy to
follow
...
If you have trouble
following a diagram, you can pencil in the ons and offs
right on the page, or place coins on the page and flip
them so that heads means on and tails means off
...


31

Remember When
You have probably heard of computer memory, and now we
are going to see exactly what that is
...
We will now
see how that is accomplished
...

It happens to be one of the neatest tricks you can do
with a few gates
...

It is made of only four NAND gates, but its wiring is
kind of special
...
‘I’ is where we input the bit that we want to
remember, and ‘o’ is the output of the remembered bit
...
There are also three internal wires labeled ‘a’,
‘b’ and ‘c’ that we will have to look at to see how
these parts work together
...

To see how this works, start with ‘s’ on and ‘i’ off
...
Since ‘a’ and ‘s’ go to gate 2, both
32

inputs are on, and therefore ‘b’ will be off
...
Since ‘c’ and ‘a’ are both on, the output of gate
3, ‘o’ will be off
...
The
important thing to note here is that with ‘s’ on, ‘o’
ends up the same as ‘i
...
Since ‘i’
and ‘s’ go into gate 1, ‘a’ will be off
...
‘O’ and ‘b’ both on go into
gate 4 and turn ‘c’ off, which goes back up to gate 3
providing it with a second off input, leaving ‘o’ still
on
...

So far, we have seen that when ‘s’ is on, you can change
‘i’ on and off, and ‘o’ will change with it
...
’ With ‘s’ on, this
combination is no more useful than a wire connecting ‘i’
to ‘o
...
Look at
gate 1
...
’ Now you can switch ‘i’ on and off and
nothing will happen
...
‘A’ may
be on, but ‘s’ is off, so ‘b’ can only be on
...
Now the
only thing left that matters, the big question is, what
will ‘o’ be?
If ‘i’ and ‘o’ were on before ‘s’ got turned off, gate 3
had both inputs off, and gate 4 had both inputs on
...
But the other input is off, so nothing changes, ‘o’
stays on
...

When ‘s’ goes off, ‘b’ comes on, which is one input to
gate 4
...

So the answer to the question of what happens to ‘o’
when ‘s’ is turned off, is that it stays the way it was,
and it is no longer affected by ‘i
...
With ‘s’ off, ‘o’ stays the way it and ‘i’
were, at the last instant just before ‘s’ went off
...
This
combination of gates locks in the way ‘i’ was at an
earlier time
...
” This is only one bit of memory,
but this is the basic building block of all computer
memory
...

I hope you followed the wires and the ons and offs in
this chapter
...

Now that we know how this thing works, we no longer need
to look at that tricky internal wiring of this
combination
...
‘S’ is the
input that allows ‘i’ into the memory bit when ‘s’ is
on, and locks it in place or ‘sets’ it when ‘s’ goes
off
...
‘M’
stands for Memory
...

It had a NAND gate hooked up in it
...
We’ll
connect the left switch to the ‘i’ wire, the right
switch to the ‘s’ wire, and the ceiling light to the ‘o’
wire
...
That would mean that at some point in the past,
both ‘i’ and ‘s’ were on, and ‘s’ got turned off first,
locking the then state of ‘i’ into our memory bit, which
then comes out at ‘o
...
So if we walked in and
decided that we wanted to turn the light off, we would
first try the ‘i’ switch, turn it on and off, and
34

nothing would happen
...

When we turn it on, the light would go off
...
Now the switches are in the same position
as they were when we entered the room, they’re both off,
but now the light is off as well, boy is this confusing
...


35

What Can We Do With A Bit?
Now we have described a bit, we have shown how to build
one, how to remember over time what state a bit was in
at an earlier instant in time, now what? What do we do
with it?
Since a bit is actually nothing more than the
electricity being on or off, the only actual, real thing
we can do with a bit is to turn lights on or off, or
toasters or whatever
...
We can take a bit, and connect it to a red
light, and say that when this bit is on, it means stop,
and when this bit is off, you may go
...

This is the action of using a code
...
When something is supposed to mean something,
somewhere someone has to make a list of all of the
states of the ‘thing,’ and the meanings associated with
each of those states
...
A code for a bit would only need
two meanings, and one of those meanings would be
associated with the bit being off, and the other meaning
would be associated with the bit being on
...
The bit does
not contain any meaning in and of itself; there is no
room in a bit for anything other than the presence or
absence of electricity
...
There is nothing about
traffic or French fries in a bit, we are just saying
that for this bit in this place, connected to a red
light hanging over an intersection, when it is on, you
must stop, when it is off, you may go
...

These are two cases of someone inventing a simple twoitem code
...
These two bits are the same, they
are just used for different purposes, and someone
decides what the meaning of these two bits will be
...
The state of the bit merely tells someone
which line of the code they are supposed to believe is
true at the current moment
...

Like the spies who pass messages by using a secret code,
the message may be seen by other people, but those other
people don’t have the code, so they don’t know what the
message means
...
When the
pot is on the left side of the sill, it means “Meet me
at the train station at 1:30
...
” Every day, the other spy walks down the street
and glances up at that window to see whether he needs to
go to the train station today
...
Then when the two spies do meet, they can pass a
piece of paper that is written in another secret code
...
So if their message is
intercepted by anyone else, it won’t mean anything to
that someone else
...

A computer bit is still, and will always be, nothing
more than a place where there is or is not electricity,
but when we, as a society of human beings, use a bit for
a certain purpose, we give meaning to the bit
...
Red means ‘stop,’ not because the
bit is capable of doing anything to a vehicle traveling
on the road, but because we as people agree that red
means stop, and we, seeing that bit on, will stop our
car in order to avoid being hit by a car traveling on
the cross street, and we hope that everyone else will do
37

the same so that we may be assured that no one will hit
us when it is our turn to cross the intersection
...
It
can indicate true or false, go or stop
...
There can be many examples of yes/no
things in everyday life, but there are many more things
that are not a simple yes or no
...
In
the Morse Code, if the key was pressed for a very short
time, that was called a “dot(
...

Each letter of the alphabet was assigned a unique
combination of dots and or dashes, and both operators
studied the code, memorized it and practiced using it
...
) and the code for the letter ‘C’ was dash dot dash
dot (-
...

You need a longer off time to keep from confusing a ‘C’
with two ‘N’s
...
The telegraph apparatus didn’t have
any memory at all, there was never even one whole letter
on the wire at any one time, the pieces of letters went
down the wire, to be assembled into dots and dashes in
the mind of the operator, then into letters, and then
into words and sentences written on a sheet of paper
...

38

If a computer were built on the principles of the Morse
code, it would just have a light bulb on top of it
flashing the code at us
...

Even in the examples used in this chapter, real traffic
lights actually have three bits, one for red, one for
yellow and one for green
...
But when it was off, you might
wonder whether it was really off, or whether the bulb
had just burned out
...

In the real world, we have already seen that computers
can contain letters, words, sentences, entire books, as
well as numbers, pictures, sounds and more
...

If we want our computer memory to be able to hold more
than an on or off, or yes or no, we will have to have
something more than just one bit
...


39

A Rose by Any Other Name
Before we go on, we are going to introduce a change to
what we call something
...
We call these states, “on” and “off,” and
that is exactly what they are
...
Fortunately, we’re not going to invent
anything tricky, we’re just going to use two symbols you
already know well, the numbers zero and one
...
And
sometimes we will still use on and off
...
Just because we call a bit a zero or one,
that doesn’t mean that suddenly numbers have appeared
and are running around inside the computer
...
We
40

could have called them plus and minus, yes and no, true
and false, heads and tails, something and nothing, north
and south, or even Bert and Ernie
...
This is a just a simple, two item code
...

As a comment here, there seems to be a trend among the
appliance manufacturers of the world to replace the
obsolete and old-fashioned terms of on and off with the
modern 0 and 1
...
The first
place I saw this was on a personal computer, and I
thought that it was a cute novelty, being on a computer,
but now this practice has spread to cell phones, coffee
makers and automobile dashboards
...
Do you understand that the code could just
as easily have been defined as “off means 1 and on means
0?” The computer would work exactly the same way, only
the printing in the technical manuals that describe what
is happening inside the computer would change
...
So why
bother? You don’t want to turn your coffee machine ‘1’,
you want the power ON so you can get your java and wake
up already
...
Nobody would have had any idea of
what it meant
...
Or maybe this trend comes from an altruistic
desire to educate the public into the modern ‘fact’ that
a 1 is the same as on, but it isn’t a fact, it’s an
arbitrary code
...
Here is a diagram of how it is done
...

Thus when the single ‘s’ gets turned on and then off
again, all eight of these ‘M’s will capture the states
of their corresponding ‘i’s at the same time
...


42

This assembly has a name; it is called a byte, thus the
“B” in the diagram
...
Just to show you that computer designers do
have a sense of humor, when they use four bits as a
unit, they call it a nibble
...

When we had a bit, we would just say that its state was
either 0 or 1
...
That
43

shows the contents of each of the eight bits, in this
case they are all zeros
...
The left hand
0 or 1 would correspond to the top bit in our byte, and
the rightmost 0 or 1 would represent the bottom bit
...
If you have two
bits, there are four possible states that those two bits
can be in
...

Notice that the order of the bits does matter – that is,
if you look at two bits and only ask how many bits are
on, there are only three possibilities: no bits on, one
bit on or two bits on
...
For the purpose of
using multiple bits to implement a code, we definitely
care about the order of the bits in a byte
...

How many different possibilities are there when you use
eight bits? If all you have is one bit, it can be in one
of two states
...
So two bits have four states
...
Every time you add a bit, you just
double the number of possible states
...

We are going to take eight bits, and call it a byte
...

The byte, taken as a whole, is a location in space that
can be in any one of 256 states at any given time, and
may be made to change its state over time
...

One of the first things that might fit the bill is
written language
...
Then there are the
numbers 0 through 9, and there are punctuation marks
like periods, commas, quotes, question marks,
parentheses and several others
...

If you add these up, 52 letters, 10 numbers, a few dozen
for punctuation and symbols, you get something like 100
different symbols that may appear printed on the pages
of the average book
...
A character can be either a letter, a number,
a punctuation mark or any other type of symbol
...
Lets see, how do
you put an ‘A’ into a byte? There is nothing inherent in
a byte that would associate it with a character, and
there is nothing inherent in a character that has
anything to do with bits or bytes
...
Dividing a character into eight
parts does not find any bits
...
The letter ‘A’ will be
represented by a particular pattern of 1s and 0s in the
bits of a byte
...
Of course, by the time
45

he gets to the 101st line or so, he’ll run out of
characters, so he can add every type of rarely used
symbol he can think of, or he can just say that the rest
of the combinations will have no meaning as far as
written language is concerned
...
At some point, the different companies
realized that it would be beneficial if they all used
the same code, in case they ever wanted their company’s
computers to be able to communicate with another brand
...

There are several versions of this code designed for
different purposes, and they still hold meetings today
to work out agreements on various esoteric details of
things
...
The basic code they
came up with is still in use today, and I don’t know of
any reason why it would ever need to be changed
...
This is usually abbreviated
to ASCII, pronounced “aass-key
...
These are 20
of the codes that they came up with, the first 10
letters of the alphabet in uppercase and lowercase:
PART OF ASCII CODE TABLE
A

0100 0001

a

0110 0001

B

0100 0010

b

0110 0010

C

0100 0011

c

0110 0011

D

0100 0100

d

0110 0100

E

0100 0101

e

0110 0101

F

0100 0110

f

0110 0110

G

0100 0111

g

0110 0111

H

0100 1000

h

0110 1000

46

I

0100 1001

I

0110 1001

J

0100 1010

j

0110 1010

Each code is unique
...
The third bit from the left is
off for all uppercase letters, and on for all lowercase
letters
...
The
first byte would have the code for uppercase “H”, the
second byte would have the code for lowercase “e”, the
third and fourth bytes would have the code for lowercase
“l”, the fifth byte would have the code for lowercase
“o”, the sixth byte would have the code for a blank
space, and bytes seven, eight and nine would contain the
codes for “J”, “o” and “e
...
) You may wonder why there needs
to be a code for a blank space, but that just goes to
show you how dumb computers are
...
And one of those “symbols,” is the lack of any
symbol, called a space, that we use to separate words
...
The computer only
has bytes, each of which can be in one of its 256
states
...

So let us take a memory byte, and set the bits to 0100
0101
...
We have set the pattern
that appears next to the letter E in the ASCII code
table, but there is nothing inherent in the byte that
has to do with an ‘E
...
But there wasn’t a single person on the face of
the Earth who would have looked at that row of bulbs and
thought of the letter ‘E,’ because ASCII had not yet
been invented
...

The only thing in the byte is the code
...
A computer code is
something that allows you to associate each of the 256
possible patterns in a byte with something else
...
” Sometimes code just refers to one of the
patterns, as in “What code is in that byte?” It will be
pretty obvious from the context which way it is being
used
...
Almost every time that we need to
remember a byte inside a computer, we also need an
additional part that gets connected to the byte’s
output
...

These eight AND gates, together, are called an
“Enabler
...


49

The second input of all eight AND gates are connected
together and given the name ‘enable,’ or ‘e’ for short
...

When ‘e’ is on, the inputs go through the Enabler
unchanged to the outputs, ‘o
...
An Enabler
allows a byte through when the bit ‘e’ is 1 and stops
the byte when it is 0
...

50

We will take our byte, and connect it to an enabler, as
shown in the left hand drawing
...


Now we have a combination that can store eight bits
...
This combination of a Byte and an Enabler, has a
name, it is called a Register, thus the ‘R’ in the
drawing
...
In those cases, we will draw a register that only
has a ‘set’ bit, and no ‘enable’ bit
...

Register simply means a place to record some kind of
information, like a hotel register where all the guests
sign in, or a check register where you write down each
check that is written
...
This
register is very limited though, in that it can only
hold one set of values; in a hotel register there is a
new line for each guest
...
The only thing that is in
there is the most recently saved value
...
Our register,
for example, has eight memory bits, each of which have
an input and an output
...

So our register can look like one of these:

Or, we can simplify, and replace it with one of these:

It’s exactly the same thing, we will just save a lot of
ink in our drawings, and they will be easier to
understand
...
But we will simplify it, and just draw it like the
diagram on the right
...
It is called a bus
...
But there is also an interesting
similarity to the kind of bus that people use for
transportation
...
They start somewhere, and the bus takes
them to some other place they need to be
...
Of course,
eight is the number of wires needed to carry a byte of
information
...

In the following example, we have a bus, and there are
five registers, each of which has both its input and
output connected to the same bus
...
If you want to copy the information from R1 into
R4, first you turn the ‘e’ bit of R1 on
...
If you then briefly turn the ‘s’ bit
53

of R4 on and back off, the data on the bus will be
captured into R4
...
So a
computer bus is a little like the bus that carries
people
...

Notice that we can copy any byte into any other byte
...
The bus works in
either direction
...
You could even
enable one register onto the bus and set it into two or
more other registers at the same time
...

In terms of the sizes of bits, you could look at it this
way: When the ‘e’ bit of R1 gets turned on, the bits in
R1 now get longer, they are a bigger space because they
are now connected to the bus, so those 8 bits now
include R1 and the entire bus
...
If anything in R1 were
to somehow change at this time, the bus and R4 would
immediately change with it
...

So this is a bus
...

One more thing about registers: There are many places
where we are going to connect the input and output of a
register to the same bus, so to simplify even further,
we can just show one bundle of wires labeled ‘i/o,’
meaning input and output
...
The
placement of the wires on the drawing may be adjusted to
make it as uncluttered as possible
...
Sometimes we talk about moving a
byte from here to there
...
The byte only refers to
the location, but sometimes when someone wants to refer
to the current setting of the byte, and they ought to
say “lets copy the contents of R1 into R4,” they
simplify and say “move R1 to R4” or “move this byte over
there
...
Again, the context usually makes
this very clear
...
” Technically, R1 and R4
are the bytes, which do not move, only the contents goes
from place to place
...
When you are done “moving” a byte, the “from”
byte has not changed, it doesn’t lose what it had
...
The old
pattern simply ceases to exist
...
The
byte didn’t move, there are still two bytes in two
locations, but the information in the first byte has
been copied into the second byte
...
So don’t get
discouraged, just a little further and we’ll be half way
home
...
It is just an AND
gate with more than two inputs
...
So this combination can simply be drawn like this
diagram on the right:

And the chart that shows how it operates looks like
this:
a

b

c

d

0

0

0

0

0

0

1

0

0

1

0

0

0

1

1

0

1

0

0

0

1

0

1

0

56

1

1

0

0

1

1

1

1

Imagine replacing input ‘c’ with another AND gate, then
you would have a four input AND gate
...
This can be done as many
times as necessary for what you are doing
...
Every time you add another input, you double the
number of combinations that the inputs can have
...
The three input,
directly above, has eight lines
...
In
all cases though, for an AND gate, only one combination
will result in the output turning on, that being the
line where all inputs are on
...
This combination is different from
anything we have looked at so far, in that it has more
outputs than inputs
...
It is not very complicated, it just
has two NOT gates and four AND gates
...
Both of them are connected to NOT
gates
...
There are four vertical wires going down the
page that come from ‘a’ and ‘b’ and the opposites of ‘a’
and ‘b
...
Now we put four AND gates on the right, and connect
each one to a different pair of the vertical wires such
that each AND gate will turn on for a different one of
the four possible combinations of ‘a’ and ‘b
...
The
next AND gate, “0/1” is connected to the wire that is on
when ‘a’ is off, and ‘b,’ so it turns on when ‘a’ is 0
and ‘b’ is 1, etc
...
None, one or two on
...
The one which is on
is determined by the current states of ‘a’ and ‘b
...
The name means
that if you consider the four possible states of the two
inputs as a code, then the output tells you which of the
codes is currently on the input
...
This decoder has two inputs, which means
that there can be four combinations of the states of the
inputs, and there are four outputs, one corresponding to
each of the possible input combinations
...
If we added a third input, there
would then be eight possible input combinations, and if
we used eight, three input AND gates, we could build a
three input, eight output decoder
...
Decoders are
named by the number of inputs “X” the number of outputs
...


59

Again, we will simplify our drawings, we won’t show any
of the internal parts or wiring, we’ll just have a box
with a name and the inputs and outputs that we are
interested in
...
It is a box full of NAND gates wired up
to do something useful
...

That’s all it does
...

Actually, we can now build fully half of what’s in a
computer
...

You know in a hotel, at the front desk, on the wall
behind the clerk, there are a series of little wooden
cubbyholes, one for each room in the hotel
...
Or you may have seen an old movie where someone
in an old post office was sorting the mail
...
He has a
pile of unsorted mail on the table, picks up one at a
time, reads the address, and puts the letter in the
appropriate cubbyhole
...
Ours will be
three inches square, and there will be sixteen
cubbyholes high and sixteen cubbyholes across
...

Now we’ll add something that they don’t have in the post
office or the hotel
...
The panel will have wheels on the
bottom so it can slide left and right to expose any one
of the vertical columns of sixteen cubbies at a time,
and cover all of the other columns
...
This second panel will be mounted right in front
of the first, in something like a window frame, so it
can slide up and down, exposing just one row of sixteen
cubbies at a time
...
In each of these
cubbies, we will place a single slip of paper on which
we will write one of the possible combinations of eight
zeros and ones
...

At any given time, we can select one and only one of
those places by sliding the wood panels side to side or
up and down
...

Now we will take the gates, registers and decoders that
we have described, and make something out of them that
does pretty much the same thing as our cubbyhole device
...

Referencing the diagram below, we start with a single
register
...
A combination of bits is
placed on the bus and the ‘sa’ (set a) bit goes 1 then
0
...
The first four output bits are connected to one 4X16
decoder, and the other four output bits are connected to
another 4X16 decoder
...
The wires do not touch
each other, but there are 16 by 16, or 256 intersections
here that we will make use of soon
...
Since we have two decoders
here, there will be one horizontal grid wire on, and one
vertical grid wire on
...
Which
intersection that is will change every time the value in
R is changed, but there will always be one where both
wires are on while the other 255 will have only one on
or none on
...
As you can see, they go upwards and into the
grid
...

There is a circle on the diagram above, around one of
the intersections of the grid
...
As we can see, there is an AND gate ‘x,’
connected to the one vertical grid wire and the one
horizontal grid wire at this intersection
...
The
rest of the connections go down to the bus and ‘s’ and
‘e’ bits at the bottom of the diagram
...
Therefore, there are 256 of these ‘x’ gates, but
only one of them has its output on at any given time
...
These two gates control access to the
set and enable inputs of the register at that
intersection
...
That will
be the case for 255 of these registers, the ones where
the ‘x’ gate is off
...


65

The above is the computer’s main memory
...
It is sometimes
called by different names, but the most correct name
comes from the fact that you can select any one of the
256 bytes one moment, and then you can immediately
select any other of the 256 bytes, and it does not
matter where the last one was, or where the next one is,
there is no speed advantage or disadvantage to the order
in which you select the bytes
...
So
this type of memory is called “Random Access Memory,” or
“RAM” for short
...
It uses 257 registers
...
Now that we know
what’s in it, we can make a simplified diagram like
this, and an even simpler bus version:

66

This is fully half of a computer
...
So now you know half
of what is inside a computer
...
That wasn’t very difficult was it?
There is one problem here, and that is that 256 bytes is
a very small size for a computer’s RAM
...

A larger RAM can be built by providing two registers
that are used to select a memory storage location
...

Here’s an idea of what it would look like: (Don’t bother
67

trying to count the grid lines, it was only possible to
fit about half of them on the printed page
...
First, one byte would have to be placed on
the ‘a’ bus and set into R0, then the second byte would
have to be placed onto the ‘a’ bus and set into R1
...

Simplifying again, we have something that looks very
much like our 256 byte RAM, it just has one more input
bit
...
If you want to imagine a
computer with a larger RAM, every time we send a byte to
the Memory Address Register, all you have to do is
imagine sending two bytes instead
...
Previously we looked at a code called ASCII that
is used to represent written language
...
Earlier we saw 20 of
the ASCII codes for part of the alphabet, here are 10
more, the codes for numbers in written language:
0

0011 0000

1

0011 0001

2

0011 0010

3

0011 0011

4

0011 0100

5

0011 0101

6

0011 0110

7

0011 0111

8

0011 1000

9

0011 1001

This is a very useful code, but not everything that
computers do has to do with written language
...
When it comes to numbers, if you use ASCII,
one byte can be any of the 10 digits from 0 to 9
...
In this case, we can use a
different code that doesn’t waste any of its possible
states on letters of the alphabet or anything other than
numbers
...
Since we
want to include zero, this code starts at zero and goes
up to 255
...
This
code did not require any committee meetings to invent
because it is the simplest and most obvious code that
computers use
...

Since this is a long chapter, here is a preview of this
code
...
To use this code, just turn on the bits
that add up to the number you want to represent
...

There are three number systems that you are probably
familiar with that we can analyze
...

Probably the oldest number system around is a simple
thing called Tally Marks
...
” The method for using these symbols is that you
write down a “|” for each of the first four things you
are counting, then for the fifth mark, you write a “/”
across the first four
...
This
system is very good for counting things as they pass by,
say your flock of sheep
...
This system has another
advantage in that there is actually one mark for each
72

thing that has been counted
...

Do you remember Roman numerals? It is a number system
that also consists of two elements
...
The second element is a method that allows you
to represent numbers that don’t have a single symbol
...
So ‘II’ is two (add one and one,) and
‘IV’ is four (subtract one from five
...
1999 was ‘MCMXCIX,’ you have
to do three subtractions in your head just to read that
one
...

The normal number system we use today also consists of
two ideas, but these are two very different ideas that
came to us through Arabia rather than Rome
...
These digits are symbols that
represent a quantity
...
This
method says that if you write down one digit, it means
what it says
...
If you
write down three digits right next to each other, the
one on the right means what it says, the middle one
means ten times what it says and the one on the left
means one hundred times what it says
...
So, if you have ‘246’ apples, that
means that you have two hundred apples plus forty apples
plus six apples
...
When
you go above ninety-nine, you have to use three digits
...
If you are counting upwards, the numbers in any one
of the positions go ‘round and ‘round - zero to nine,
then zero to nine again, on and on, and whenever you go
from nine back to zero, you increase the digit to the
left by 1
...

There is something odd about this in that the system is
based on ten, but there is no single symbol for ten
...
If we also had a single symbol for ten, there
would actually be eleven different symbols
...

One of the new ideas in this Arabic system was to have a
symbol for zero
...
If you
have 50 apples or 107 apples, you need the zeros in the
numbers to know what position each digit is actually in,
so you can multiply by ten the correct number of times
...
They
both have the number ten associated with them
...

In school, when they first teach children about numbers,
they say something about our number system being based
on the number ten, because we have ten fingers
...
They would have
invented a number system with only six digits- 0, 1, 2,
3, 4 and 5
...
The answer is, that since the first idea, the
74

digits, was changed to only have six digits, then the
second idea, the method, would also have to be changed
so that as you add positions to the left, each one would
have to be multiplied by sixes instead of tens
...
As you count your apples, you
would say “0, 1, 2, 3, 4, 5…” and then what? There’s no
‘6’ for the next number
...
OK, “0, 1, 2, 3,
4, 5, 10, 11, 12
...
What would this ‘12’ mean? It would be this
many:

...
Very odd, but it does work out - 1 times six
plus two equals eight apples, it follows the Arabic
method, but it is based on six instead of ten
...
And 55 would be followed by 100
...
Yes, think of the
way we write time, or the kind of clock that shows the
numbers on its face
...
But the left digit of the minutes and seconds only
goes 0-5
...
There are 60 minutes in an hour,
numbered from 00 to 59
...
That position uses the number system based on
six symbols (0-5)
...
And you are so used to this that
you don’t have to think about it
...
Have you ever had to add time? If you add
40 minutes and 40 minutes, you get 80 minutes, but to
write that down in hours and minutes, you have to figure
out how many 60s there are in 80, in this case 1, then
figure out how many minutes there are beyond 60, in this
75

case 20
...
The 1 represents 60 minutes,
add 20 and you have your 80 again
...


The hour positions are even stranger
...
On
a 24 hour clock, it goes from 00-23
...
The point we wanted to make was that you
are already familiar with number systems based on
numbers other than ten
...
But the simplest one would be if you
only had 2 digits, 0 and 1
...
This system is
based on two, so there are only two digits, and as you
add positions to the left, each one is worth two times
more than the previous one
...
When you get down to
only having two possible digits, you don’t have to do
much multiplication to figure out the total value of a
position
...

While we’re at it, let’s imagine a very strange animal
with eight fingers on each hand
...
In their system, they
would be able to write ten through fifteen each with a
76

single symbol
...
To see how this would work, we
need six new symbols, so let’s just use the first six
letters of the alphabet
...
Only after using all sixteen symbols in the
right position will we run out of symbols, and the next
number will be sixteen, written ‘10’ in this system
...
There are 16
ounces in a pound, so you know that 8 ounces is half a
pound
...

Here is a chart that shows five different number
systems
...


77

Our normal 0-9 numbers are called the decimal system,
because ‘dec’ means ten in some ancient language
...
This new
78

system with just 0 and 1 is called the binary system
because ‘bi’ means two, also because of some ancient
language
...

Another method of naming different number systems is to
call them by the number they are based on, such as ‘base
10’ or ‘base 2,’ etc
...

But notice that the number after the word ‘base’ is
written in the decimal system
...
In fact, every number system would be
‘base 10’ if the ‘10’ was written in that system’s
numbers! So we could talk about base 2, base 6, base 10
and base 16 if we wanted to, as long as we remember that
those base numbers are written in decimal
...

Again, in our normal decimal numbers, the rightmost
position is the number of ones
...
Each position is worth
ten times the previous one
...
’ Each position is worth two times the amount to
its right
...

This is the point of this chapter
...
We can use it as a code, with off
representing zero and on representing one, following the
Arabic number method with only two symbols
...
When we use this code, the bit on
the right will be worth 1 when the bit is on, or 0 when
it is off
...
The next to the left is
4, and so on with 8, 16, 32, 64 and 128
...

79

In this code, 0000 0001 means one, 0001 0000 means
sixteen, 0001 0001 means seventeen (sixteen plus one,)
1111 1111 means 255, etc
...
This code is
called the “binary number code
...
Just saying what is in
a byte is a problem
...
In this book
when a number is spelled out, such as ‘twelve,’ it means
12 in our decimal system
...

Actually, in the computer industry, people often use
hexadecimal, (and they just call it ‘hex’
...
If you have
a byte containing 0011 1100, you can translate it to 60
decimal, or just call it “3C hex
...


80

Addresses
Now that we have the binary number code, we can use it
for various purposes in our computer
...
The pattern of bits that we put into this
register will use the binary number code
...
The number in MAR is considered to be
a number somewhere between 0 and 255, and thus each of
the 256 RAM bytes can be considered to have an address
...
In a neighborhood of homes, each house has an
address, like 125 Maple Street
...
” and written on the house
are the numerals “125
...
The point to be made here is that
the houses and streets have numbers or names written on
them
...
It is
simply the byte that gets selected when you put that
number in the Memory Address Register
...
Imagine a
neighborhood of houses that had sixteen streets, and
sixteen houses on each street
...
You would still be able to find any
specific house if you were told, for example, to go to
‘the fourth house on the seventh street
...
So a computer address is just a number that
causes a certain byte to be selected when that address
is placed into the Memory Address Register
...
We will call this half of
the computer the “Central Processing Unit,” or CPU for
short, because it does something with and to the bytes
in RAM
...
The thing that is common
to both sides of the computer is the bus
...
The RAM is shown on
the right, and the bus makes a big loop between the two
bus connections on the RAM
...
These six registers are
all of the places that the CPU will use to “process”
bytes
...
It
controls all of the ‘set’ and ‘enable’ bits in the CPU
and the RAM
...
For now,
we are going to look at where the bytes can go within
the CPU
...
Their
inputs and outputs are connected to the bus
...

The register called ‘TMP’ means temporary
...
TMP has
a ‘set’ bit, but no ‘enable’ bit because we never have a
reason to turn its output off
...
This is a word that comes from the days of the
old mechanical adding machines (pre 1970
...
In a computer, it just
means that it temporarily stores a byte that comes from
that big question marked box
...

The registers in the CPU and RAM are the places where
the contents of bytes come from and go to as the
computer operates
...

Now we will look at what is in those boxes with the
question marks
...
There are
two more combination gates that we need to define
...
Here is the chart for it, showing the
intermediate wires so it is easy to follow
...
So it has another very simple name,
it is called the “OR gate
...
The diagram and chart look like this:

a

b

c

0

0

0

0

1

1
84

1

0

1

1

1

1

Like the AND gate, you can build OR gates with more than
two inputs
...
Also like the AND
gate, every time you add an input, the number of lines
on the chart will double
...

All the rest of the lines will show the output being on
...

Similar to the OR gate, the output is on when either
input is on, but in this version, the output goes back
off if both inputs are on
...
The output is on if
either OR the other input is on, exclusively
...
Another way to look it at it is
the output comes on if one and only one input is on
...


a

b

c

d

e

f

g

0

0

1

1

1

1

0

85

0

1

1

0

0

1

1

1

0

0

1

1

0

1

1

1

0

0

1

1

0

The simplified diagram looks similar to an OR gate, but
it has a double curved line on the input side
...
They are NAND, AND, OR and XOR
...

In spite of the fact that everything in the computer is
made out of NAND gates, we are not going to be using any
NAND gates by themselves in this computer! Now that we
have used them to build AND, OR, XOR and NOT gates, and
the memory bit, we are done with the NAND gate
...
NAND gate, bye bye for now
...
Two bits in, one bit
out
...

And the bus moves a byte at a time
...
We
want some ‘gates’ that affect an entire byte
...
This is
usually referred to as moving a byte
...

First we will see three ways that we can change the
contents of a byte as it moves from one register to
another
...

These are all of the things that computers actually do
to bytes
...


88

The Left and Right Shifters
The shifter is very easy to build
...
It
is done like this:

This shows two registers connected by a right shifter
...

When the ‘e’ bit of R1 is turned on, and the ‘s’ bit of
R2 is turned on and then off, all of the bits in R1 are
copied into R2, but they are shifted over one position
...

A right shifter will change 0100 0010, to 0010 0001
...
The
89

left shifter is wired up like so:

Once again, we have bus versions of these drawings
...
Assume that you are using the binary
number code
...
That
comes out to the decimal number 6
...
R2 will then be 0000 1100
...
What do you know, we have just
90

multiplied the number by 2
...
How you multiply
by something other than 2 will be seen later, but this
is how simple it is, just shift the bits
...
If you
want to multiply something by ten, you just add a zero
to the right side, effectively shifting each digit left
one position
...

So that’s the shifter, no gates at all
...

Each bit will be changed to its opposite
...
This
operation is used for many purposes, the first being in
some arithmetic functions
...
Another
name for a NOT gate is an “inverter,” because it makes
the opposite of what you give it, turns it up side down,
or inverts it
...


92

93

The ANDer
The ANDer takes two input bytes, and ANDs each bit of
those two into a third byte
...
The eight bits of the ‘b’ input
bus are connected to the lower side of the same eight
AND gates
...
With this, we can AND
two bytes together to form a third byte
...
For example, you can make
sure that an ASCII letter code is uppercase
...
All of the bits
that were on in R0 will be copied back to R0 except for
the third bit
...
R0 will now contain 0100
0101, the ASCII code for ‘E
...

Here is a simpler bus type picture for the ANDer
...
As you can see, the eight
bits of the ‘a’ input bus are connected to the upper
side of eight OR gates
...
The outputs of the eight OR gates are the bus
output ‘c’ of this assembly
...


What is the use of this? There are many, but here is one
of them
...
If you want to make this letter be
96

lowercase, you could put the bit pattern 0010 0000 into
R1 and then OR R0 and R1 and put the answer back into
R0
...
R0 will now
be 0110 0101, the ASCII code for ‘e
...

Here is a simpler bus type picture for the ORer
...
As you can see, the eight
bits of the ‘a’ input bus are connected to the upper
side of eight XOR gates
...
The outputs of the eight XOR gates are the
bus output ‘c’ of this assembly
...


What is the use of this? Again, imaginative people have
come up with many of uses
...
Say
you have one code in R1 and another code in R2
...
So you XOR
R1 and R2 into R1
...
It doesn’t
matter what pattern of 0s and 1s was in R1, if R2
contained the same pattern, after an XOR, R1 will be all
zeros
...


99

The Adder
This is a combination of gates that is surprisingly
simple considering what it does
...
If you think about how addition
is done with two of our regular decimal numbers, you
start by adding the two numbers in the right column
...

If the answer is anywhere from 0 to 9, you write it down
below the two numbers
...

2
5
+4
+7
6
12
In the binary number system, it is actually much
simpler
...
Thus the only possible answers for adding the
right column of two binary numbers will be 0, 1 or 10
(zero, one or two)
...

1
1
+0
+1
1
10
The gates we have described can easily do this
...
If one bit is on, and the other one is off, that
is, we are adding a 1 and a 0, the answer for the right
column will be 1
...
The AND gate turns on
only in the case where both input numbers are 1
...
Now we want to
add the next column to the left
...
So it’s not the same, this time we are
really adding three numbers, the two bits in this
column, plus the possible carry from the previous
column
...
) It is more complex,
but not impossible
...
If
they are, and ‘carry in’ is off, or if ‘a’ and ‘b’ are
the same and ‘carry in’ is on, then the right XOR will
generate 1 as the sum for the current column
...

The upper AND gate will turn on ‘carry out’ if
‘carry in’ and one of the inputs are on
...
Notice that every bit has a carry in, even the
first bit (the right column
...


102

And the simplified picture of it with bus inputs and
output:

103

The carry output bit of the leftmost (top) column will
turn on if the sum of the two numbers is greater than
255, and this bit will be used elsewhere in the
computer
...
The
shifters and the adder also generate one extra bit of
output that is related to their output byte
...

The comparator is actually built right into the XORer
because it can make use of the gates that are already
there
...
These two functions
are not really related to each other, it just happens to
be easy to build it this way
...

The equal thing is pretty simple
...

To determine the larger of two binary numbers is a
little trickier
...
If they are the
same, then you have to check the next lower pair of bits
etc
...

But once you do find a pair that are different, you
don’t want to check any more bits
...
) The first
two bits are the same in both bytes
...
Although the rest of the bits
are on in the second byte, their total is less than the
one bit that is on in the first byte
...
Since we
are starting with the XORer, we will add four more gates
to each position as shown in this diagram
...
In
105

the comparator, we have two bits that pass down from the
highest bit position to the lowest
...
You can see the
original XOR gate, labeled ‘1’, connected up to one bit
of each input bus on the left, and generating one bit
for the output bus on the right
...
We add gate 2, which will
turn on when ‘a’ and ‘b’ are equal
...

Gate 4 turns on if three things are true
...
2) Bit ‘a’ is the one that is on
...
When gate
4 turns on, it turns gate 5 on, and that turns on every
other gate 5 below this point, and therefore the ‘a
106

larger’ output of the comparator
...

You stack up eight of these bit comparators like the
following diagram, with a ‘1’ and ‘0’ connected to the
top one to get it started
...


Simplifying again, we will go back to the bus-type XOR
diagram, and just add the two new output bits of the
comparator
...
This
is a simple gate combination that takes a whole byte as
input, and generates only one bit as output
...

In other words, the output bit tells us when the
contents of the byte is all zeros
...
When
any of the inputs to the OR gate are on, its output will
be on, and the output of the NOT gate will be off
...

The simpler bus representation is shown on the right
...
There was a man
in ancient Greece named Aristotle who did a lot of work
in this area
...

One of his ideas was that if you have two facts, you may
be able to derive a third fact from the first two
...
You may
remember questions such as:
If Joe is older than Bill,
And Fred is older than Joe,
Then Fred is older than Bill
...

Jane is a child
...
True or False?
Aristotle called his study of this sort of thing
‘Logic
...
’ Aristotle’s logic
involved two facts making a third fact
...
And so, the things that these gates
do, has come to be known as logic
...

ANDing, ORing and XORing take two bytes to make a third,
so they fit this definition of logic pretty well
...
The ADDer, although it is has two inputs
and is also very logical, somehow is not known to be in
the category of logic, it is in its own category,
arithmetic
...


110

The Arithmetic and Logic Unit
Now we have built seven different devices that can do
arithmetic or logic on bytes of data
...
This is
called the “Arithmetic and Logic Unit,’ or “ALU” for
short
...
’ All seven devices are connected to the inputs at
all times, but each output is attached to one of those
enablers
...
Seven of the
decoder’s outputs enable a single device to continue on
to the common output, ‘c
...
The three input wires to the decoder are labeled
‘op,’ because they choose the desired ‘operation
...
These are used in very similar ways, and
so from here on out we will refer to all of them as
carry bits
...
So the three
carry inputs are connected to a single ALU input, and
one of the three outputs is selected along with the bus
output of its device
...

What do we have here? It is a box that has two bus
inputs, one bus output and four other bits in and four
other bits out
...
Again, now that we know what’s in it and how it
works, we don’t need to show all of its parts
...
Seven of
those combinations select one of the devices described
previously
...

The combination of bits at ‘op’ mean something
...
Yes, here is a three-bit code
that we will make use of soon
...
This is where all of the action
happens
...


114

More of the Processor
There is one more little device we need
...
It is very similar to an enabler
...
The single bit input determines what
happens when a byte tries to pass through this device
...
When
the ‘bus 1’ bit is on, the input byte is ignored and the
output byte will be 0000 0001, which is the number 1 in
binary
...


Now we can put this ‘bus 1’ and the ALU into the CPU
...
The bus inputs come in the
top, the bus output comes out the bottom and all of the
input and output bits are on the right
...
ACC receives,
and temporarily stores, the result of the most recent
ALU operation
...

When we want to do a one input ALU operation, we have to
set the three ‘op’ bits of the ALU to the desired
operation, enable the register we want onto the bus, and
set the answer into ACC
...

First we enable one of the registers onto the bus and
set it into TMP
...

As you can see, we can now move bytes of data to and
116

from RAM, to and from the Registers, through the ALU to
ACC, and from there, into a register or RAM if we turn
the appropriate enable and set bits on and off at the
right time
...

That’s not so complicated, is it?
There is only one thing missing here, and that has to do
with all of these control bits on the registers, ALU and
RAM
...
Each of the registers, R0,
R1, R2, R3 and ACC have a set and an enable bit, TMP
only has a set bit, bus 1 has a control bit, and the ALU
has those three ‘op’ bits that select the desired
operation
...
Now it is time to look into
that box labeled ‘Control Section
...
We will look at the
appropriate bits later, first we will look at the
appropriate times
...

It shows how one bit changes over time
...
The line on
the graph has two possible positions, up means the bit
is on, and down means the bit is off
...
There could be a time scale on the bottom to
show how fast this is happening
...
But we
won’t need a time scale in these graphs, as we will only
be concerned with the relative timing between two or
more bits
...

When something repeats some action regularly, one of
those actions, individually, is called a cycle
...
You can say that
from one time the bit turns on to the next time the bit
turns on is a cycle, or you can say that from the middle
of the off time to the middle of the next off time is
the cycle, as long as the cycle starts at one point in
time when the bit is at some stage of its activity, and
continues until the bit gets back to the same stage of
the activity again
...

There was a scientist who lived in Germany in the 1800’s
who did some of the early research that led up to radio
...
Some decades after his death, it was decided to
use his name to describe how fast electricity was going
on and off, or how many cycles occurred per second
...
500 Hz
means 500 times per second
...

Going on and off a million times per second is called a
megahertz, or mHz for short, and a billion times is
called a gigahertz, or gHz for short
...
All other bits in a
computer come from somewhere, they are set on and off by
other bits or switches
...
But there is nothing mysterious
about it, it just goes on and off very regularly and
very quickly
...
Just connect a NOT
gate’s output back to its input? What will this do?
Well, if you start with the output on, the electricity
travels back to the input, where it enters the gate
which turns the output off, which travels back to the
input which turns the output on
...
This will
actually be too fast to be used for anything, and so it
can be slowed down just by lengthening the wire that
makes the loop
...

119

This bit has a name
...
Now we
usually think of a clock as a thing with a dial and
hands, or some numbers on a screen, and we have seen
such clocks in the corner of a computer screen
...
It could
have been called the drumbeat or the pacesetter or the
heart or the rhythm section, but they called it a clock
...
I guess it’s a clock that ticks,
but doesn’t have a dial
...

But the word ‘clock’ will mean this type of bit
...
This is one of the main characteristics that
computer companies tell you about to show you how great
their computers are
...

The faster a computer is, the more expensive it is,
because it can do more things in one second
...

To move data via the bus, we need first to enable the
output of one and only one register, so that its
electricity can travel through the bus to the inputs of
other registers
...
Since the destination register captures the
state of the bus at the instant that the set bit goes
off, we want to make sure that it goes off before we
turn off the enable bit at the first register to make
sure that there are no problems
...
This will delay the electricity slightly
...

120

If we show the original clock output (clk) and the
delayed clock output (clk d) on a graph, they will look
like this:

Now we’re going to do something fairly simple
...
The graph of the inputs and outputs
of the AND and OR gates is shown here
...
The on time of the second is right
in the middle of the on time of the first
...

And what do you know, these two bits have the perfect
timing to move a byte of data from one register, across
the bus, and into another register
...

Here is a single on/off cycle of these two bits
...

Of course, these clock bits cannot just be connected
directly to every register
...
But all enables and sets ultimately come
from these two bits because they have the right timing
...
We have a number in
R0, and there is another number in R1 that we want to
add to the number in R0
...

In the first clock cycle, we can enable R1 onto the bus,
and set it into TMP
...

In the third cycle, we can enable ACC onto the bus, and
set it into R0
...
Perhaps
this doesn’t seem very useful, but it is one of the kind
of small steps that computers do
...

Thus we see that for the processor to do something
useful, it takes several steps
...
We need another piece inside
this ‘Control Section
...

First, we will describe the completed stepper, showing
exactly what it does
...
If you happen to trust your author
enough to believe that such a stepper can be built out
of gates, and you’re in such a hurry that you want to
skip the ‘how it is built’ part of the chapter, you
might still understand the computer
...


It has two inputs
...
The other input is called
‘reset,’ which is used to return the stepper back to
step one
...
The output labeled
‘Step 1’ turns on for one clock cycle, then ‘Step 2’ for
the next clock cycle, etc
...
In the case of this computer that we are
building, seven steps are sufficient
...

Here is a graph of the input ‘clk’ bit, and the outputs
of a seven-step stepper
...
It is done using some
of the same memory bits that we used to make registers,
but they are arranged very differently
...

The stepper consists of several memory bits connected in
a string, with the output of one connected to the input
of the next
...
In this
picture, there are twelve of them connected together,
with the output of one connected to the input of the
next, all the way down the line
...

If you look at the set bits of these ‘M’s, you will see
that the set bits of the even numbered ‘M’s are
connected to clk, and the set bits of the odd numbered
‘M’s are connected to the same clock after it goes
through a NOT gate
...

The first time ‘clk’ comes on, nothing will happen,
because the set bit of the first ‘M’ is connected to
‘not clk,’ which is off when ‘clk’ is on
...
When ‘clk’ comes back on, the second ‘M’ will
now come on
...
Thus two bits come on for each
clock cycle
...
’ Since all ‘M’s start off, step 1 will be on
until the second ‘M’ comes on, at which time step 1 will
be over
...
The AND gates for steps 2-6
have both inputs on when the left ‘M’ is on, and the
right ‘M’ is off
...
Each one comes on when its left
input has come on, but its right input has not yet come
on
...

The only thing missing here is that the ‘M’ bits come on
and stay on
...
So we need
a way to reset them all off so we can start over again
...
When that happens, the ‘off’ at the input to the
first ‘M’ will travel through all of the ‘M’s as fast as
it can go
...


128

When we turn ‘reset’ on, it makes the input to the first
‘M’ bit a zero, and turns on all of the ‘sets’ at the
same time so that the zero can travel down the line of
‘M’s very quickly
...
Now all of the bits
are off, and we have started another sequence
...

To recap, this is a stepper
...
For outputs, it has a number of bits, each
of which will come on for one clock cycle
...
There will be only one stepper in our
computer, we will represent it with this simplified
diagram
...
Step 7 will
not be on for very long, however, because it shuts
129

itself off as soon as the zero can get through the
string of ‘M’s
...
All of the things we want to accomplish
will take place in steps 1 through 6
...
It
has a basic output, and two more that are designed to
facilitate the movement of the contents of registers
from one to another
...

Remember the diagram of the CPU we saw a few chapters
back? It showed the bus, the ALU, six registers and even
the other half of the computer (the RAM) all connected
up pretty neatly
...
But all the registers, the RAM, the Bus 1
and the ALU are controlled by wires that come from that
mysterious box labeled ‘Control Section’ that we know
nothing about yet
...


131

This drawing is the beginning of the control section of
the computer
...

Then all of the control bits from the registers and RAM
have been brought here together in one place, with all
of the ‘enable’ bits on the left, and all of the ‘set’
bits on the right
...
One
input of each AND gate is connected to either ‘clk e’
for the ‘enables’ on the left, or ‘clk s’ for the ‘sets’
on the right
...
Similarly on the right,
the ‘set’ bit of any of those registers will only be
turned on during ‘clk s’ time
...
Everything we need to
132

make the computer do something is right here in one
place
...


133

Doing Something Useful, Revisited
Now that we have the beginning of our control section,
we can just add a few wires, and we will be able to do
the simple addition we postulated earlier, that of
adding R1 to R0
...

Each step causes something to happen to some of the
parts that are shown in the CPU diagram
...
Step four is wired to R1 ‘enable’
134

and TMP ‘set
...
’ The ALU ‘op’ bits do not need any connections
since the ‘op’ code for ADD is 000
...

During step four, R1 is enabled and TMP is set
...

During step five, R0 is enabled and ACC is set
...

During step six, ACC is enabled and R0 is set
...


135

R0 now contains the sum of the original contents of R0
plus R1
...

In step seven, the stepper is reset to step 1, where the
process repeats
...

If the clock in our computer ticks one billion times
every second, otherwise known as one gigahertz, and even
if we use multiple clock cycles to “do something useful”
like this, that means that the computer can do something
like this hundreds of millions of times in one second
...

Perhaps now that we have added R1 to R0, we want to
store that new number to a particular address in RAM,
and R2 happens to have that address in it
...
In step 4, we can move R2 across the bus to
MAR
...

That’s all that is needed, just two clock cycles and
we’re done
...


137

There are many combinations of things that we can do
with the RAM, the six registers and the ALU
...

We need a way for our CPU to do one thing one time, and
a different thing the next time
...


138

What’s Next?
Now here’s a scary idea
...
Walk to the counter, say
“May I take your order?” listen to the answer, press the
“cheeseburger” button on the cash register, etc
...

You could then invent a code that would associate one of
the states of a byte with each of the individual
activities of an employee
...

First we make up a code table
...
Then we decide what we want
those codes to mean, and write those meanings next to
the codes
...

0000 0101 = Press the milk button
0000 0110 = Press the total button
0000 0111 = Collect the money
0000 1000 = Give the customer the change
0000 1001 = Open an empty bag
0000 1010 = Place a cheeseburger in the bag
0000 1011 = Place fries in the bag
0000 1100 = Place a milk container in the bag
0000 1101 = Hand the bag to the customer
1000 0000 = Go to the step number in the right 6 bits
...

0001 0000 = Go home
...

0000 0000 = Walk to the counter
...

0000 0001 = Say “May I take your order?”
3
...

4
...

5
...

6
...

7
...

8
...

9
...

10
...

11
...

12
...

13
...

14
...

15
...

16
...

17
...

18
...

19
...

21
...

22
...

23
...

24
...

25
...

26
...

27
...

I hope nobody ever tries to make the employees of a fast
food restaurant learn a code like this
...
But maybe someone will
try to staff one of these restaurants with robots
someday
...

And our computer might be able to ‘understand’ a code
like this
...
How could we have it
wired up one way for one sequence, and then a different
way for the next sequence? The answer, of course, is to
use more gates
...
And there could
be a third and fourth possibility or more
...
Now we have several different
operations that can be done, but how do you select which
one will be done?
The title of this chapter is “The First Great
Invention,” so what is the invention? The invention is
that we will have a series of instructions in RAM that
will tell the CPU what to do
...

The first part of the invention is, that we are going to
add another register to the CPU
...

The bits from this register will “instruct” the CPU what
to do
...

The second part of the invention is another register in
the CPU called the “Instruction Address Register,” or
“IAR” for short
...
If the IAR contains 0000
1010 (10 decimal,) then the next instruction that will
be moved to the IR is the byte residing at RAM address
ten
...
When that
instruction is complete, the stepper starts over again,
but now the IAR has had 1 added to it, so when it gets
that instruction from RAM, it will be a different
instruction that was located at the following RAM
address
...

This is what allows us to make the computer do many
different things
...
The contents of the IR will
determine what registers are sent to where, and what
kind of arithmetic or logic will be done upon them
...

This series of bytes residing in RAM that the CPU is
going to make use of is called a “program
...
Then it fetches the next one and
executes it
...
This is the
simplicity of what a computer does
...

The stepper in this computer has seven steps
...
So there are six steps during which the CPU does
small things
...
The
six steps taken as a whole is called an “Instruction
Cycle
...

If we assume that our clock ticks at one gigahertz, then
our computer will be able to execute 166,666,666
instructions every second
...
There they are under the Control
Section, connected to the bus
...

142

Below is the wiring within the Control Section that does
the ‘fetch’ part of the instruction cycle
...


143

The stepper’s first three steps are shown here, and
result in ‘fetching’ the next ‘instruction’ from RAM
...

Exactly what will be done in steps 4, 5 and 6, is
determined by the contents of the instruction that was
fetched
...

The bottom of this diagram includes the Instruction
Register
...
We will be referring to the individual bits
soon
...
The main thing
we want to do is to get the address in IAR over to MAR
...
If you look at the wire coming out of
step 1 of the stepper, you can see that two of the
places it is connected to are the ‘enable’ of IAR and
the ‘set’ of MAR
...
’ Sometime during the instruction cycle, we need
to add 1 to the value in IAR, and since IAR is already
on the bus, we might as well do it now
...
One input comes from the
bus, which has IAR on it during this time
...
If
we turn on the ‘set’ of ACC during ‘clk s,’ we will
capture the sum of IAR plus 1 in ACC
...
This is the instruction
that we will ‘execute’ in steps 4, 5 and 6 of this
instruction cycle
...

In step 3, we need to finish updating IAR
...
It needs
to be moved to IAR before the beginning of the next
instruction cycle
...

By the time we get to step 4, the instruction has
already been moved from RAM to IR, and now steps 4, 5
and 6 can then do whatever is called for by the contents
of IR
...

This idea of putting a series of instructions in RAM and
145

having the CPU execute them is a great invention
...
The patterns that are
put into this register have a meaning
...
This code will be
called the “Instruction Code
...
We will take the 256
different codes that can be put in the Instruction
Register, and decide what they will mean
...

Do you remember the binary number code? We said that it
was the closest thing to a ‘natural’ computer code
because it was based on the same method we use for our
normal number system
...
There is nothing natural about ASCII at all, it
was just what those people decided it would be
...
Many
different instruction codes have been invented for many
different types of computers
...
But all Instruction
Codes are similar, in that they are what make the
computer work
...
The
most important thing in inventing our Instruction Code,
will be how simple we can make the wiring that will make
the code work
...
Fortunately, we will
only have nine types of instructions, and all 256
combinations will fall into one of these categories
...

All instructions involve moving bytes across the bus
...
In
the following chapters, for each type of instruction, we
will look at the bits of that instruction, the gates and
wiring necessary to make it work, and another handy code
we can use to make writing programs easier
...
As you recall, the
ALU has eight things it can do, and for some of those
things it uses two bytes of input, for other things it
only uses one byte of input
...

This type of instruction will choose one of the ALU
operations, and two registers
...
It
actually has 128 variations, since there are eight
operations, and four registers, and you get to choose
twice from the four registers
...
Thus this is not just one instruction, but
rather it is a whole class of instructions that all use
the same wiring to get the job done
...
If
the first bit in the Instruction Register is a 1, then
this is an ALU instruction
...

If the first bit is on, then the next three bits in the
instruction get sent to the ALU to tell it what to do,
the next two bits choose one of the registers that will
be used, and the last two bits choose the other register
that will be used
...
If you placed
this code (1000 1011) in RAM at address 10, and set the
IAR to 10, and started the computer, it would fetch the
1000 1011 from address 10, place it in IR, and then the
wiring in the control section would do the addition of
R2 and R3
...
You can
choose to go from one register to another such as R1 to
R3, or choose to go from one register back into the same
one, such as R2 to R2
...

For two input operations, Reg A and Reg B will be sent
150

to the ALU, and the answer will be sent to Reg B
...
You can
also specify the same register for both inputs
...
No matter what is in R1
to begin with, all bit comparisons will be the same,
which makes the output of all bits zeros, which gets
placed back into R1
...
But the CMP operation does not store its output
byte
...

The wiring in the Control unit for the ALU instruction
is pretty simple, but there is one extra thing that will
be used by many types of instructions that we need to
look at first
...
In
“Doing Something Useful Revisited,” we used two
registers
...

This was fine, but in the ALU instruction, and many
others, there are bits in the instruction register that
specify which register to use
...
Here
is the Control Section wiring that does it:

151

Look at the right side first
...
’ As you can see,
‘clk s’ is connected to all four AND gates
...
But these four AND
gates each have three inputs
...
You remember that one
and only one output of a decoder is on at any given
time, so only one register will actually be selected to
have its ‘set’ bit turned on
...
’ If you look back at the chart of the
152

bits of the ALU Instruction Code, it shows that the last
two bits of the instruction are what determine which
register you want to use for Reg B
...
Remember
that in an ALU instruction such as ADD, we need to
enable two registers, one at a time, for the inputs to
the ALU
...
Bits 4 and 5 of the IR
are used to enable ‘Reg A’ during its proper step, using
a separate decoder and a wire called ‘Reg A
...
We will never
select ‘Reg A’ and ‘Reg B’ at the same time
...
First we
want to move ‘Reg B’ to TMP
...
Then we want to move
ACC to ‘Reg B
...
When Bit 0 is on, the things that Bit 0
is wired up to make all of the steps of an ALU
instruction occur
...

In the diagram below, just above and to the left of the
IR, there are three AND gates
...
Each of these three AND gates has
three inputs
...
A second input of each gate is wired to step
5 from the stepper
...

Therefore, the three wires that go to the ALU will be
000 at all times except during step 5 when IR bit 0
happens to be a 1
...


IR bit 0 continues up the diagram, turns right and is
connected to one side of three more AND gates
...

The output of the first gate comes on during step 4, and
you can see it going to two places
...
This step is actually not necessary
for the SHL, SHR and NOT operations, but it doesn’t harm
anything, and it would be fairly complicated to get rid
of, so for simplicity’s sake we’ll just leave it this
way
...
The ALU now
has one input in TMP, the other input on the bus, and
its operation specified by those three ‘op’ wires, so on
the right is a wire that sets the answer into ACC
...
The wire going to
the left enables ACC onto the bus, and the wire going to
the right sets the bus into ‘Reg B
...
For a compare operation, we do not want to store
any results back into ‘Reg B
...
So when the operation is 111, the first AND
will come on, the NOT will go off, and the output of the
Step 6 AND gate will not turn on
...
Step 7 resets the
stepper, which then goes through its steps again,
fetching the next instruction, etc, etc
...
In the Instruction Code, 1000 1011 means “Add
R2 to R3,” but it takes a lot of practice for a person
to look at 1000 1011 and immediately think of addition
and registers
...

This idea of using a shorthand has a name, and it is
called a computer language
...
The ALU
instruction results in the first eight words of our new
language
...
Of course, if you write a program in
a computer language, it will have to be translated into
the actual instruction code before it can be placed in
RAM and executed
...
They
move a byte between RAM and a register
...

We’ll get to the details of these instructions in a
moment, but first we need to have something that tells
us when we have a Load or Store instruction in the
Instruction Register
...
The code for every
other type of instruction begins with bit 0 off, so if
we connect a NOT gate to bit 0, when that NOT gate turns
on, that tells us that we have some other type of
instruction
...

The three bits that went to the ALU in an ALU
instruction also go to a 3x8 decoder here in the Control
Section
...
But when it is
not an ALU instruction, the one output of the decoder
that is on, will get through its AND gate, and in turn
will be connected to some more gates that make the
appropriate instruction work
...
IR bit 0 has a NOT gate which goes to the other
side of those eight AND gates
...


157

158

This chapter is about the instructions that use the
first two outputs of the decoder, the ones that come on
when the IR starts with 0000 or 0001
...
The
other one does the same in reverse, it moves a byte from
a register to RAM, and is called the “Store”
instruction
...
The remaining
four bits in both cases specify two registers, just like
the ALU instruction did, but in this case, one register
will be used to select one of the locations in RAM, and
the other register will either be loaded from, or stored
to, that RAM location
...
One of the
159

registers is selected by IR bits 4 and 5 and is enabled
onto bus
...

In step five, IR bits 6 and 7 select another one of the
CPU registers
...
For the Store instruction, the selected
register is enabled onto the bus and the bus is set into
RAM
...

Here are two new words for our computer language:
Language
Meaning
LD
RA,RB Load RB from RAM address in RA
ST
RA,RB Store RB to RAM address in RA

160

The Data Instruction
Now here is an interesting instruction
...
The thing that is different about it
though, is where in RAM it will get that byte
...
So you could consider that
this instruction is actually two bytes long! The first
byte is the instruction, and the next byte is some data
that will be placed into a register
...

Here is the Instruction Code for the Data instruction
...
Bits 4 and 5 are not used
...


All this instruction needs to do is, in step 4, send IAR
to MAR, and in step 5, send RAM to the desired CPU
161

register
...
Since the second byte of the instruction is just
data that could be anything, we do not want to execute
this second byte as an instruction
...
We will do this the same
way that it is done in steps 1 and 3
...
Step 5 still moves the data to a Register, and
in step 6 we can move ACC to IAR
...
But our clock is very fast, and the
amount of RAM we have is limited
...
Because of the versatile arrangement of
our CPU and its Control Section, it is an extremely
simple thing to make this work, but its importance
should not be lost because of this simplicity
...

The exact type of Jump instruction described in this
chapter is called a “Jump Register” instruction
...
Here is
the Instruction Code for it:

165

The computer is executing a series of instructions in
RAM, one after the other, and suddenly one of those
instructions changes the contents of the IAR
...
It will
be the one that is at whatever RAM address was loaded
into the IAR
...
until it executes another jump
instruction
...
In step 4, the selected register is enabled
onto the bus, and set into the IAR, and that is all
...
But to keep our diagram simple, we
won’t bother with that
...


166

Here is another new word for our computer language:
Language
Meaning
Jump to the address in RB
JMPR
RB

167

Another Way to Jump
This is another type of Jump instruction
...
It
replaces the IAR with the byte that is in RAM
immediately following the instruction byte, thus
changing where in RAM the next and subsequent
instructions will come from
...
Bits 4, 5, 6 and 7 are not used in this
instruction:

This exact type of Jump instruction is just called a
“Jump
...
The Jump Register Instruction is more useful
when the address you are going to want to jump to is
calculated as the program in running, and may not always
be the same
...
You can have a series of fifty instructions
in RAM, and the last instruction “Jumps” back to the
first one
...
Unlike the Data Instruction, we don’t need
to add 1 to the IAR a second time because we are going
to replace it anyway
...
In step
4, we send IAR to MAR
...
Step 6 will do nothing
...

This is just like the Jump Instruction, but sometimes it
jumps, and sometimes it doesn’t
...
Mostly what we
are going to introduce in this chapter is where that one
bit comes from
...
If you add two
numbers that result in an amount that is greater than
255, the carry bit will come on
...

There is also a bit that tells us if the two inputs to
the ALU are equal, another one that tells us if the A
input is larger, and one more bit that tells us if the
output of the ALU is all zeros
...
These four bits will be
called the “Flag” bits, and they will be used to make
the decision for a “Jump If” instruction as to whether
it will execute the next instruction in RAM or jump to
some other address
...
The “Jump If” will jump or
not depending on something that happened during the ALU
instruction
...
If you go
back and look at the details of the ALU instruction, it
is only during step 5 that all of the proper inputs are
going into the ALU and the desired answer is coming out
...
The
timing is the same for all four Flag bits, they are only
172

valid during step 5 of the ALU instruction
...


Here is the last register that we are going to add to
the CPU
...

The Flag bits from the ALU are connected to the input of
this register, and it will be set during step 5 of the
ALU instruction just like ACC and it will stay set that
way until the next time an ALU instruction is executed
...

Every instruction cycle uses the ALU in step 1 to add 1
173

to the address for the next instruction, but only step 5
of the ALU instruction has a connection that sets the
Flags
...
)
This combination of Flag bits, and the Jump IF
instruction, is the third and last great invention that
makes computers as we know them today, work
...
The second four bits of the instruction
tell the CPU which flag or flags should be checked
...
If any one of the
Flags that you test is on, the jump will happen
...
There is a second byte that contains
the address to jump to, if the jump is taken
...


174

175

Step 4 moves IAR to MAR so we are prepared to get the
‘Jump to Address’ that we will use IF we jump
...
And so step 4
also turns on Bus 1 and sets the answer in ACC
...

Step 6 is where the “decision” is made
...
That third input
comes from an OR gate with four inputs
...
If, for instance, there is a ‘1’ in the ‘Equal’ bit
of the instruction, and the ‘Equal’ Flag bit is on, then
the jump will occur
...
‘J’ means
Jump, ‘C’ means Carry, ‘A’ means A is larger, ‘E’ means
A Equals B and ‘Z’ means that the answer is all Zeros
...

Actually since there are four bits, there are 16
possible combinations, but the one with all four bits
off is not useful because it will never jump
...

When you do addition or shifting, you have the
possibility of getting the carry flag turned on by the
operation
...

The Carry Flag is also used as an input to the addition
and shift operations
...

The problem that arises is that if you are just adding
two single-byte numbers, you don’t care about any
previous Carry, but the Carry Flag may still be set from
a previous operation
...

Here is the Instruction Code for this instruction
...


The wiring for this is very simple and a bit tricky
...
We will turn on ‘Bus 1’
178

so the ‘B’ input is 0000 0001
...
The
ALU, therefore, will be adding 0 and 1, and there may be
a carry input
...
But there will be no carry output, the
answer is not zero and B is larger than A so ‘equal’ and
‘A larger’ will both be off
...


179

Here is another word for our language
...
As
a result, we can place a series of instructions in RAM,
and the Clock, Stepper, Instruction Register and wiring
will fetch and execute those instructions
...
The only thing we had to
add were some OR gates because most of the ‘enables’ and
‘sets’ need multiple connections
...
Most of the mess here is just getting the
wires from one place to another
...
Each possible
pattern causes a different activity
...

As mentioned, this is called the Instruction Code
...
” You “tell” the machine what to do by
giving it a list of orders you want it to carry out
...
” If you feed it the right byte-sized
patterns of ons and offs, you can make it do something
that will be useful
...

Language
Instruction Code
Meaning
Add
1000
rarb
ADD
RA,RB
1001
1010
1011
1100
1101
1110
1111
0000
0001
0010
0011
0100

rarb
rarb
rarb
rarb
rarb
rarb
rarb
rarb
rarb
00rb xxxxxxxx
00rb
0000 xxxxxxxx

SHR
SHL
NOT
AND
OR
XOR
CMP
LD
ST
DATA
JMPR
JMP
183

RA,RB
RA,RB
RA,RB
RA,RB
RA,RB
RA,RB
RA,RB
RA,RB
RA,RB
RB,Data
RB
Addr

Shift Right
Shift Left
Not
And
Or
Exclusive OR
Compare
Load RB from
Store RB to
Load these 8
Jump to the
Jump to the

0101
0110

Caez xxxxxxxx
0000

JCAEZ
CLF

Addr

Jump if any
Clear all Fl

Believe it or not, everything you have ever seen a
computer do, is simply the result of a CPU executing a
long series of instructions such as the ones above
...
Not to
teach you how to act like a computer, but just to prove
to you that it works
...
It is done with the
adder and the NOT gates
...
Then you add 1 to
R1, then you Add R0 to R1
...
But a single register cannot hold a
number larger than 255
...

Why does NOTting and ADDing result in subtraction? Why
do you have to add 1 after NOTting? Why do you ignore
186

the carry bit? We are not going to attempt to answer any
of these questions in this book
...
These brave people study these problems
and design ways for ordinary people to not have to
understand it
...
When we do
multiplication with a pencil and paper in the decimal
system, you have to remember your multiplication tables,
you know, 3 times 8 equals 24, 6 times 9 equals 54, etc
...
1 times 1 equals 1, and for every other
combination, the answer is 0! It just couldn’t get much
simpler than that! Here’s an example of multiplying 5
times 5 with pencil and paper in binary
...
Then, for every digit to the left of that,
shift the top number left, and if the bottom digit is a
1, add the shifted top number to the answer
...

So multiplication is accomplished with the adder and the
shifters
...
You can write a simple
program like this:
R0 contains the bottom number, R1 contains the top
number and R2 will contain the answer
...

RAM Addr
Instruction
Comments
50
DATA
R3,0000 * Put ‘1’ into R3
0001
52
XOR
R2,R2
* Put ‘0’ in R2
53
CLF
* Clear Flags
54
SHR
R0
* One bit to Carry Flag
55
JC
59
* Do the ADD
57
JMP
61
* Skip the ADD
59
CLF
* Clear Flags
60
ADD
R1,R2
* ADD this line
61
CLF
* Clear Flags
62
SHL
R1
* Mult top by 2
63
SHL
R3
* Shift counter
64
JC
68
* Out if done
66
JMP
53
* Do next step
68
(Next instruction in program)
See what happens with the Registers as this program goes
through its loop the first three times
...
It happened on the first
time through, when R1 contained 0000 0101, and on the
third time through, after R1 had been shifted left twice
and therefore contained 0001 0100
...
The loop will
repeat 5 more times until the bit in R3 gets shifted out
to the Carry Flag, but the total won’t increase because
there are no more 1s in R0
...
We start with
0000 0001 in R3
...
The first seven times through, there will
be no carry, so the program will get to the ‘JMP 53’ and
go back up to the third instruction of the program
...

Therefore, the ‘JC 68’ will jump over the ‘JMP 53’ and
carry on with whatever instructions come after this
...
The byte in R1 gets shifted left to multiply it by
two
...
And
that’s all there is to it
...
If a multiplication program multiplies two one-byte
numbers, it ought to be able to handle a two-byte
answer
...
This would be accomplished with the
carry flag and some more Jump If instructions
...

Reading a program like the one above is an entirely
different skill than reading the diagrams and graphs we
have seen so far in the book
...

Division also can be done by our computer
...
Just imagine the
following simple method
...
If you repeatedly subtract three from
fifteen, and count the number of subtractions you can
accomplish before the fifteen is all gone, that count
will be the answer
...
This is easily
turned into a program
...
The details are very
tedious, and studying them would not enhance our
understanding of how computers work
...
Our simple computer
could do all of these things with programs
...
It
has two parts, the RAM and the CPU
...

These simple operations are the most complicated things
that a computer can do
...
This is what a computer is
able to do
...

These two parts make it a computer, but if all the
computer could do is run a program and rearrange bytes
in RAM, no one would ever know what it was doing
...

Dealing with anything outside of the computer is called
‘Input/Output’ or ‘I/O’ for short
...
Some things are input only, such as a
keyboard, some things are output only, like a display
screen, some things do both input and output, like a
disk
...

For the wires, all we are going to do is to extend the
CPU bus outside of the computer and add four more wires
to go with it
...
Everything that is connected to the
computer is attached to this one I/O bus
...
)
More than one thing can be attached to the I/O bus, but
the computer controls the process, and only one of these
things is active at a time
...
This is not the same as the
addresses of the bytes in RAM, it is just some ‘number’
that the peripheral will recognize when placed on the
bus
...


In the diagram below are the wires of the I/O Bus
...
The ‘Input/Output’ wire determines
which direction data will be moving on the CPU bus,
either in or out
...
‘I/O Clk e’ and ‘I/O
Clk s’ are used to enable and set registers so that
bytes can be moved back and forth
...
This shows where
the four new wires for the I/O bus come from
...
They were also shown
on the full control section diagram a few chapters back
...


193

IR bits 4 and 5 are placed on the I/O bus at all times
...
For Output, Reg B is enabled, and I/O Clk s is
turned on and off during step 4
...
For Input, I/O Clk e is enabled, and Reg B is
set during step 5
...

Here is the Instruction Code for the I/O instruction:

This one instruction can be used in four different ways
depending on IR bits 4 and 5, and therefore there are
four new words for our language
...
The collection of parts that connects the
device to the bus is called a “device adapter
...

The adapter does nothing unless its address appears on
the bus
...

With an ‘OUT Addr’ instruction, the computer turns on
the address wire, and puts the address of the device it
wants to talk to, on the CPU bus
...
Every other
peripheral has some other address, so they won’t
respond
...
By this time, you should believe that bytes of
information can be transferred over a bus with a few
control wires
...
The CPU and the RAM are
the computer
...
The
adapters for different devices have different
capabilities, different numbers of registers, and
different requirements as far as what the program
running in the CPU must do to operate the device
properly
...

The computer controls the process with a very few simple
I/O commands that are executed by the CPU
...
It is an input only device, and just
presents one byte at a time to the CPU
...
When you press a key, it simply
connects electricity to the wires necessary to create
the ASCII code corresponding to the key that was
pressed
...


197

After pressing a key, there will be an ASCII code
waiting in the Keycode Register
...

AND gate #1 has eight inputs
...
Thus this AND
gate will turn on any time the bus contains 0000 1111
...

AND gate #2 comes on only during ‘clk s’ time of an OUT
Addr instruction
...
If the bus contains 0000 1111 at this time,
the ‘i’ input will be on, and the Memory bit will turn
198

on
...

AND gate #3 comes on during ‘clk e’ time of an IN Data
instruction
...

Every adapter that is connected to the I/O bus needs to
have the type of circuitry we see in gates #1 and #2 and
the memory bit above
...

Here is a little program that moves the current keypress
into Reg 3 in the CPU
...

The program running in the CPU will check the keyboard
adapter on a regular basis, and if the byte that it
receives is all zeros, then no key has been pressed
...

Again, we are not going to go through every gate in the
Keyboard adapter
...
But it is no more complicated
than that
...


199

The Display Screen
Television and computer display screens work the same
way, the main difference between them is only what they
display
...

Television appears to give you moving pictures with
sound
...

The first thing to know is that although the picture
appears to be moving, it is actually a series of still
pictures presented so quickly that the eye doesn’t
notice it
...
You have seen motion picture film
...
To watch a movie, you put the film
in a projector, which shines light through one picture,
then moves the film to the next picture, shines light
through it, etc
...

Television goes a bit faster, about 30 pictures per
second, but there is another, much bigger difference
between film and television
...
Each picture is
complete, when you shine the light through it, every
part of the picture appears on the screen
simultaneously
...

It does not have a whole picture to put on the screen
all at once
...
It lights up
one dot, then another dot, then another, very quickly
until one whole picture’s worth of dots has been lit
...
until it has placed 30
picture’s worth of dots on the screen in one second
...

Usually, the top left dot is lit first, then the one to
its right, and so on across the top of the screen to the
top right corner
...
until it has scanned the entire screen
...

At any one instant in time, the television is only
dealing with one single solitary dot on the screen
...
This second illusion
is aided by what the screen in made of, each dot only
gets lit up for a tiny fraction of a second, and it
starts to fade away immediately
...

To the eye, you just see a moving picture, but there are
a lot of things going on to make it appear that way
...

Computer screens work just like televisions
...
Even if the content of the screen is not
changing, something in the computer has to scan that
unchanging image onto the screen 30 times every second
...

We’re not going to go into the same amount of detail
here that we did with the CPU and the RAM, those two are
what make it a computer, but if we want to know how our
computer is able to put something on the screen that we
can read, we need to have the basic idea of how it
201

works
...
This
type of screen can display characters and the type of
pictures that are made of line drawings
...

The major parts are three
...
It has an I/O Bus that can
move bytes to and from things outside of the computer
...
The screen is just a large grid of
pixels, each of which can be selected, one at a time,
and while selected, can either be turned on, or not
...
’ The display adapter
is connected to the I/O Bus on one side, and to the
screen on the other side
...
The display
adapter needs its own RAM so it can “remember” which
pixels should be on, and which pixels should be off
...

In order to make the screen scan every pixel 30 times
every second, the Display Adapter needs its own clock
that ticks at a speed that is 30 times the number of
pixels on the screen
...

As an example, lets use an old type of screen
...
That comes out to 64,000
individual pixels on the screen
...

The address of the top left pixel is 0,0 and the bottom
right pixel is 319,199
64,000 pixels times 30 pictures per second means that
this Display Adapter’s clock needs to tick 1,920,000
times per second
...

The display adapter has a register that sets the
horizontal position of the current pixel
...
It starts at zero, and when the number in it gets
to 319, the next step resets it back to zero
...
There is also a
register that sets the vertical position of the current
pixel
...
When the vertical register reaches 199, the
next step will reset it to zero
...

The currently selected screen pixel is controlled by
these registers, so as the horizontal register goes from
0 to 319, the current pixel goes across the screen once
...

Thus, the clock and the horizontal and vertical
registers select each pixel on the screen, one at a
time, going left to right in one row, then selecting
each pixel in the next row down, then the next, etc
...
Then it starts all over again
...
This register also gets
stepped through, although we only need one new byte for
every eight pixels
...
After every eight pixels, the
RAM address register has 1 added to it
...
When the horizontal and vertical
registers have both reached their maximums, and are
reset to zero, the RAM address is also reset to zero
...
The only other thing it has to do is to accept
commands from the I/O Bus that will change the contents
of the display adapter RAM
...
Then as the
adapter continues to repaint the screen, the new data
will appear on the screen at the appropriate spot
...
It keeps the input and output
functions separate
...
Then
there are two separate memory address registers, one for
input and one for output
...

With this setup, the screen and the display RAM can both
be continuously scanned using only the output MAR and
204

the enable bit
...

This is how the display adapter creates an image on the
screen
...
As
it scans the first eight pixels of the top line, it uses
the individual bits of byte 0 of its RAM to turn the
pixels on or off
...

It takes 40 bytes of RAM to draw the first line, and so
the last eight pixels, which are numbered 312 through
319, come from RAM byte 39
...

If you want to write letters and numbers on the screen,
how do you do it? If you put the ASCII code for ‘A’ into
a byte in the display RAM, you will just get eight
pixels in a row where one is off, then one is on, then
five are off and the last one is on
...

There is a solution for this, and it involves…

205

Another Code
When you want to print or display written language, you
need to translate the ASCII code into something that is
readable by a live person
...
’ But how does the computer turn 0100 0101 into a
readable ‘E’?
We have a display screen, but the screen is a just a
grid of pixels, there are no human readable ‘E’s in
anything we have described so far
...

Therefore, we need another code
...
For each
character that we want to be able to draw on the screen,
we need a little picture of that character
...
If there are 100 different
characters that you want to be able to display on the
screen, then you’d need 100 different little pictures
like this, and it would require 800 bytes of RAM to
store it
...

These 800 bytes are a type of code known as a “font
...

If the pictures in our font are arranged in the same
order as the ASCII code table, then we can use the
numeric value of an ASCII code to find the corresponding
picture within the font
...
If you apply the binary number code to the same
pattern of ones and zeros, you get the decimal number
69
...

Since there are eight bytes in each picture, you
multiply the 69 by 8, and that tells you that the
picture for ‘E’ will be the eight bytes starting at
address 552
...
Lets say that we want to display an ‘E’ at
the very top left of the screen
...
So we use a series of OUT
instructions to copy RAM address 552 to display RAM
address 0
...
That means that
it uses 40 bytes on each row, so the top row uses bytes
0-39
...
Similarly, the third through eighth
bytes get written at bytes 80, 120, 160, 200, 240 and
280
...
If you wanted to write an
‘X’ on the screen right next to the ‘E’, you would
locate the eight bytes in the font for ‘X’ and copy them
into display RAM bytes 1, 41, 81, 121, 161, 201, 241 and
281
...


Of course, this seems like a lot of work just to make a
single letter appear on the screen
...
Then the loop would
repeat, updating both addresses each time, until all
eight bytes had been copied to the appropriate places
...
That means that
it could take 400 instruction cycles just to put one
character on the screen! If you drew 1000 characters on
the screen, that might take 400,000 instruction cycles
...

This just goes to show you why computers need to be so
fast
...


208

The Final Word on Codes
We have seen several codes used in our computer
...
Individual
coded messages are put in bytes, and moved around and
used to get things done
...
There is nothing in the
byte itself that tells you which code it is supposed to
be
...
In the ALU, the adder and comparator are
built to treat bytes as though they contain values
encoded with the binary number code
...

The Instruction Register is built to treat its contents
as though it contains values encoded with the
Instruction Code
...
Pictures and fonts are strings of
bytes that will result in something that can be
recognized by a person when it is organized, and the
brightnesses are set, by the wiring of a display adapter
and screen
...

The only places where ASCII gets converted between
characters and the code for the character, are in the
peripherals
...
’ When you send the ASCII code
for an ‘E’ to a printer, it prints the letter ‘E
...

An ‘E’ is the fifth letter of an alphabet used by people
to represent sounds and words in the process of writing
209

down their spoken language
...
All the ‘E’s that are in bytes are
just the code that appears next to the ‘E’ on an ASCII
code table
...
Even if you put a picture of an ‘E’
in a computer, it isn’t actually an ‘E’ until it is
displayed on the screen
...

Bytes are dumb
...
If a byte contains 0100 0101, and you send it to
the printer, it will print the letter ‘E
...
If you send it to the Memory
Address Register, it will select byte number 69 of the
RAM
...
If
you send it to the display screen, it will set three
pixels on and five pixels off
...
It just does what it was designed
to do
...
Programmers invent new codes all the
time
...


210

The Disk
Most computers have a disk
...
The disk’s
mission is very simple; it can do two things
...

There are two reasons that most computers have a disk
...
The
CPU can only execute programs that are in RAM, it can
only manipulate bytes that are in RAM
...
And so a disk will hold
everything, and when you want to do one thing, the bytes
on the disk for that one thing will be copied into RAM
and used
...

The second reason that computers have disks, is that the
bytes stored on the disk do not disappear when you turn
the power off
...

A computer bit has been defined so far as a place where
there is or is not some electricity
...
On a disk, the electric bits are
transformed into places on the surface of the disk that
have been magnetized one way or the other
...
One
direction would represent a zero, and the other
direction, a one
...
Turning the power off has no effect on the
magnetized spots
...
It is coated with a material that
211

can be magnetized easily
...
That piece of metal turns into a
magnet when electricity moves through the wire
...
The arm holds the head very close to the surface of
the spinning disk, and the arm can swing back and forth,
so that the head can reach any point on the surface of
the disk
...
Also, it works
the other way around; when the head passes over a
magnetized area, it makes electricity appear in the
wires wrapped around the head
...
The bits of the bytes are written
one after another on the disk surface
...
The head
can move across the surface and stop on any one of the
tracks
...
Since a disk has two sides,
usually both sides are coated with the magnetic material
and there is a head on each side
...
On a disk, there
is also a way to locate bytes, but it is very different
...
That is the
type of “address” that the data on a disk has, like
“Head 0, Track 57, Sector 15
...
For the examples in our
book, since our RAM is so small, we will talk about a
disk that stores blocks of 100 bytes
...
The
whole block has to be transferred to RAM, worked on in
RAM, and then the whole block has to be written back to
the disk
...
That’s pretty fast, but
compared to the CPU, it is still pretty slow
...

The disk, like every peripheral, is connected to its own
adapter, which in turn is connected to the I/O bus
...
It accepts commands to
select a head, select a track and select a sector
...

There will also probably be a command where the CPU can
check the current position of the arm and the disk
...
When
it gets a command to select a sector, it has to wait for
that sector to spin around to where the head is, which
also takes a long time in terms of instruction cycles
...
A program
that reads or writes a block of bytes has to continue
the process until the whole block of bytes is complete
...
The program that is
running has to move these bytes to or from RAM, usually
in consecutive locations
...
You have probably used a
computer that had a disk, and didn’t need to know
anything about heads, tracks and sectors
...
We will look
at how a disk is normally used later in the book
...

If you want to send someone a letter, first you write it
on a piece of paper, then when the recipient gets the
letter, he reads it
...
Then you would record some music on the
tape
...

When it comes to computer disks, putting something on
the disk is called writing
...

Putting something into RAM is called writing or storing
...

Putting something into a CPU register is usually called
loading
...
Listening to a disk is still usually
called playing, but if you are copying it onto your
computer, then it is called ripping
...
Reading, retrieving,
playing and ripping are also very similar
...


215

Excuse Me Ma’am
There is one other thing that most computers have as
part of their Input/Output system
...
But it is
a very common thing, so we will describe how it works
...
The soup stirring was interrupted by getting a
glass of milk, and then the soup stirring resumed
...

An interrupt starts with one more wire added to the I/O
Bus
...
When a device adapter turns the Interrupt
bit on, the next time the stepper gets back to step 1,
the next instruction cycle will not do the usual fetch
and execute, but rather it will do of the following:
Step 1
move binary 0 to MAR
Step 2
move IAR to RAM
Step 3
move binary 1 to MAR
Step 4
move Flags to RAM
Step 5
move binary 2 to MAR
Step 6
move RAM to IAR
Step 7
move binary 3 to MAR
Step 8
move RAM to Flags
The result of this sequence is that the current IAR and
Flags are saved to RAM addresses 0 and 1, and they are
replaced with the contents of RAM bytes addresses 2 and
3
...
But the IAR has been replaced! So the next
instruction will be fetched from whatever address was in
RAM byte 2
...
If at the
end of this new activity, the program puts RAM bytes 0
and 1 back into the IAR and Flags, the CPU will pick up
from exactly where it left off, before it was
interrupted
...
Without interrupts, the program running in
the CPU would have to make sure to check all of the
devices on the I/O Bus on a regular basis
...

We have not included this in our CPU because it would
just make our Control Section wiring diagram too big
...

And that is an Interrupt system
...


217

That’s All Folks
Yes, this is the end of our description of a computer
...
Everything you see a computer do
is a long concatenation of these very simple operations,
the ADDing, NOTting, Shifting, ANDing, ORing, XORing of
bytes, Storing, Loading, Jumping and I/O operations,
via the execution of the instruction code from RAM
...
This is the sum
total of the smarts in a computer
...
It is a machine
that does exactly what it is designed to do, and nothing
more
...
It does its task exactly as
designed
...

The variety of things the computer can be made do is
limited only by the imagination and cleverness of the
people who create the programs for them to run
...

When we think of a computer, we probably think of that
box that sits on a desk and has a keyboard, mouse,
screen and printer attached to it
...
There is a computer in your car
that controls the engine
...
There is a computer in most cable or
satellite television boxes
...
The
differences are all in the peripherals
...
Your car has
various sensors and controls on the engine, and the
dials of the dashboard for peripherals
...

There are computers in some traffic lights that change
the lights based on the time of day and the amount of
traffic that crosses the sensors embedded in the
roadway
...

218

For the rest of the book we will look at miscellaneous
subjects related to understanding how computers are
used, a few interesting words that are related to
computers, some of their frailties and a few other loose
ends
...
That word has been around for
a long time
...
I think that a hardware store
originally sold things that were hard, like pots and
pans, screwdrivers, shovels, hammers, nails, plows, etc
...
Today, some hardware stores no longer sell pots
and pans, but they sell huge variety of hard things,
like bolts and lawnmowers, also lumber and a lot of soft
things too, like carpet, wallpaper, paint, etc
...

The word ‘software’ was invented somewhere in the early
days of the computer industry to differentiate the
computer itself from the state of the bits within it
...
Remember
that bits can be either on or off
...
The bit is hardware
...
This thing
is called software
...
Then record a movie on it
...
That surface is coated with
very fine particles that can be magnetized
...
After recording the movie on the
tape, some little places on the tape are magnetized in
one direction and other little places are magnetized in
the other direction
...
When you put the tape into a VCR it
plays a movie
...

220

In a computer, there are a great many bits
...
The bits
in the computer are always there
...
This pattern is called
software
...

So the difference between hardware and software isn’t
like metal versus rubber
...

Hardware is something you can pick up, see, handle
...
When you buy
software, it is recorded on something, usually some kind
of disk
...
Another disk may look
just like it, but have completely different software
written on it
...

If you have a vase that you want to send to your aunt
Millie for her birthday, you have to pack the vase in a
box and have a truck take it from your house to her
house
...
In that case, the music will get to her house
without a truck having to go there
...

Another way to see the difference between hardware and
software is how easy it is to make a copy of the item
...
You
could photograph the lawnmower, but you’d only have a
flat photograph of a lawnmower
...
To get a real second lawnmower,
you’d have to go back to the lawnmower factory and build
another one out of iron and plastic and rope and
whatever else lawnmowers are made out of
...

221

Software can be copied easily by machine
...
The new one will be just like the original, it
will do all the same things
...
If the original is a program that will prepare
your tax papers, so will the copy
...

By far the most commonly used definition of ‘software’
is to refer to a package of computer instruction code
...
But
when there are no instructions in it, it can’t do
anything
...
It is a
vital part of the total machine, yet it isn’t like any
other part in the machine
...
So it is part of
the ‘ware,’ but it isn’t hardware
...


222

Programs
As mentioned earlier, a series of instructions in RAM
are called a program
...
Generally, a program is a
piece of software that has everything needed to do a
specific task
...
A program might be made up of
several smaller parts known as ‘routines
...

There are no hard and fast definitions that
differentiate between system, program, routine and subroutine
...

There is another distinction between two types of
programs that is not related to their size
...
Most of these programs are used to do
something that the owner wants to do
...
There
is one program on most computers that is not an
application
...
This one program
that is not an application is called the Operating
System
...

Its first job is to get the computer up and running when
you first turn the computer on
...
It is the ‘boss’
of every other program on that computer
...
It lets one program run for a
small fraction of a second, then another program, then
another program
...
It
would appear that all ten programs were running
simultaneously because each one gets to do something,
faster than the eye can see
...
When an application program needs
to read from, or write to the disk, or draw letters on
the screen, it does not have to do all of the
complicated I/O instructions necessary to accomplish the
task
...

All an application needs to do to use one of these
routines is to load up some information in the
registers, and then jump to the address of the proper OS
routine
...
Lets
say you want to draw a character on the screen
...

Then put row and column numbers of where you want it to
appear on the screen into R1 and R2
...
Now just jump to
the OS routine
...
Thus, these
routines can be ‘called’ from any application, and when
done, the routine will jump back to the next instruction
224

in the application that called it
...
One is that it makes it easier to
write application programs, the programmer does not even
need to know how the peripherals actually work
...

One of the most important reasons is that the OS can
check to see whether the program should be allowed to do
what it is asking to do
...

The heart of the OS is basically a loop of instructions
that asks the following questions: Do I need to input
anything? Do I need to output anything? Do I need to let
any program run? Then it starts over again
...
When there is something to
do, it jumps to the beginning of the program that takes
care of it, and when that is done, it jumps back to this
loop where the OS ‘waits’ for something else to do
...


225

226

Within each program’s RAM, there is all of the
instruction code that makes the program work
...
As mentioned, the OS also has routines
that can be called by other programs
...
The calculator, for
example, needs to have a few bytes where it stores the
numbers that the user enters into it
...
The word processor needs some RAM for all of
the ASCII codes that make up the document you are
working on
...

And so this is what goes on inside your average
computer
...
The OS jumps to a program, the program
jumps to a routine, the routine jumps to a sub-routine
...
As each one finishes, it jumps
back to where it came from
...

If our computer had included an ‘interrupt system’ like
we described a few chapters back, every time someone
pressed a key on the keyboard or moved the mouse, there
would be an interrupt that would call a part of the OS
that determines which I/O device caused the interrupt,
and then calls the proper routine to take care of
whatever it was
...

This can all seem very complex, with so many millions
and billions of instructions being executed in the blink
of an eye
...
A study of these would simplify software
in the same manner that I hope this book has simplified
227

the hardware
...


228

Languages
Writing programs is very hard to do when you’re just
writing ones and zeros, but that is the only code that
the CPU ‘understands
...
A written language is a way to represent the
sounds of a spoken language with symbols on paper
...
We just can’t get away from these things!
Do you remember that shorthand we used when we were
looking at the CPU instruction code and the wiring in
the Control Section? Well, that is actually something
more than just a handy tool that was invented for this
book
...
Here are a few lines of
it:
Instruction
Language
Meaning
Code
1000
rarb
ADD
RA,RB Add
1001
rarb
SHR
RA,RB Shift Right
1010
rarb
SHL
RA,RB Shift Left
1011
rarb
NOT
RA,RB Not
A computer language is a way to represent the
instruction code
...

In order to use this language, you write the program you
want with ASCII characters, and save it into a file
...
The compiler will
read the ASCII file, translate each line into the
Instruction Code that it represents, and write all of
the Instruction Code bytes into a second file
...

Of course, when computers were first invented, all
229

programs had to be written directly in ones and zeros
...
Then
ever after, programs were written in this easier
language, and then translated into Instruction Code by
the compiler
...

So in order for a computer language to exist, you need
two things, a set of words that make up the language
(another code,) and a compiler that compiles the written
language into computer instruction code
...
Each word correlates directly to
one of the instructions of which this computer is
capable
...
When you write an 87 line program in this
language, the instruction code file that the compiler
generates will have 87 instructions in it
...
For example, our computer does
not have an instruction that does subtraction
...
If you can
figure out how to do something fancy with 47
instructions, you can have a word in your language that
means that fancy thing
...
The compiler has
a lot more work to do, but still generates instruction
code that does the things that the words in that
language mean
...
034
Print “Hello Joe, your interest this year is: $”
Print Balance X Interest Rate
The compiler for this language would read this four-line
program, and generate a file that could easily contain
230

hundreds of bytes of instruction code
...

There are many computer languages
...

Lower level languages are still the best for certain
purposes
...

To make things easier, someone invented an idea called a
“file
...
A paper file is
a sheet of cardboard folded in half and placed in a file
cabinet
...

A computer file is a string of bytes that can be any
length, from one byte up to all of the bytes available
on the disk
...
A disk may have
many files on it, each with its own name
...
To make a file
system work, the operating system provides a bunch of
software that makes the disk appear to be like a filing
cabinet instead of having heads, tracks, sectors and
blocks of bytes
...
Applications can ask the OS to
create, read, write or erase something called a file
...
You open it, request bytes, send it bytes, make it
bigger or smaller, close the file
...
If the file is smaller than a disk sector, that’s
all you need, but if the file is larger than one sector,
then there is also a list which contains as many disktype addresses as needed to hold the file
...
” Then the user types the letter to Jane
and saves it
...

232

To use the file system, there will be some sort of rules
that the application program needs to follow
...
Typically, you would put all of this information
in a series of bytes somewhere in RAM, and then put the
RAM address of the first byte of this information in one
of the registers, and then execute a Jump instruction
that jumps to a routine within the Operating System that
writes files to the disk
...

If you ask the OS to look at your disk, it will show you
a list of all the file names, and usually their sizes
and the date and time when they were last written to
...
Files
usually have names that are made up of two parts
separated by a period like “xxxx
...
” The part before
the period is some sort of a name like “letter to Jane,”
and the part after the dot is some sort of a type like
“doc” which is short for “document
...

The part after the dot tells you what type of data is
contained in this file, in other words, what code it
uses
...
In one popular operating
system “
...
A “
...
A “
...

If you ask the OS what programs are available to
execute, it will show you a list of the files that end
with “
...
If you ask for a list of pictures that you
can look at, it will show you a list of files that end
with “
...

There are many possible file types, any program can
invent its own type, and use any code or combination of
codes
...

What sorts of things could go wrong here?
In the early days of computing, when each gate in the
computer was relatively expensive to build, sometimes
there were components that actually had moving parts to
make electrical connections
...
Sometimes when the machine stopped
working correctly, the fixit guy would look inside to
find out what was wrong, and he would find that a spider
had crawled inside the machine and had gotten itself
wedged in between two of these pieces of metal that were
supposed to touch each other
...
So the electricity wouldn’t
get to where it needed to go, and the machine would not
operate correctly anymore
...
” And he literally meant a bug
...
There are two main classes of computer bugs:
hardware and software
...
This could be as serious as you turn the
computer on, and it catches fire, to there is one byte
in the RAM where one bit is always off
...
If the byte where that bit is
located somehow never gets used, then the computer will
work just fine
...
” If that byte has some program instructions in
it, you may get an XOR instruction changed to a JMP
instruction
...
The contents of those
bytes will determine what happens next, but it will
almost certainly be as wrong as a train falling off its
track
...
It would still be able
to fetch instructions in steps 1, 2 and 3, but every
instruction would execute incorrectly
...

Software bugs can take many forms, but they are all
ultimately programmer mistakes
...

Some errors just create some kind of incorrect results,
and other errors cause the computer to “crash
...
He got a coupon book
with the loan, one coupon to be sent in with each
payment
...
A few weeks later, he received a
computer-generated letter from the loan company saying,
“Thank you for paying off your loan in full, next time
you need a loan please use us again
...
It should have at
least checked the balance remaining on the loan before
deciding that it was paid off
...
The computer did
exactly what it was told to do, and most of the time it
was adequate, but the program was not written to
anticipate all of the situations that sometimes occur in
the real world
...
The program executes a series of instructions, and
then jumps back to the beginning of the series and
executes it over and over again
...

235

It may repeat until 50 bytes have been moved somewhere,
or keep checking for the user to press a key on the
keyboard
...
But if there is
some sort of programming error where there is a loop
that has no way out, the computer will appear to be
completely stuck
...

There are all sorts of errors that end up with the CPU
trying to execute something other than instruction code
...
If the
program is written incorrectly so that under certain
conditions it will jump to address 180, it will just
continue fetching and executing the bytes starting at
address 180
...
It may put itself into
a loop, or jump back somewhere into the program, or
issue the command to erase the disk drive
...
If you looked
at the patterns in the bytes, you could see what it
would do, but it could be just about anything
...
Since it is not designed
to be useful, most likely it will just keep making a
bigger mess out of what is in memory until the computer
will have to be powered off to get it to stop
...
In that case, every letter “E” that got
drawn on the screen thereafter would look like this: ‘

...
Therefore, the subject of programming computers in
a manner that will be completely ‘bug free’ is something
236

that gets a lot of attention
...
Still, compilers can have errors, and they
will never be able to spot an error like the one above
with the car loan
...
Every gate has to work every time, and
every instruction that gets executed has to be correct
...


237

Computer Diseases?
Another place where human characteristics get assigned
to computers is something called a computer virus
...
Are they going to start coughing and sneezing?
Will they catch a cold or the chicken pox? What exactly
is a computer virus?
A computer virus is a program written by someone who
wants to do something bad to you and your computer
...
The motivation of people who
write virus programs ranges from the simple technical
challenge of seeing whether one is capable of doing it,
to a desire to bring down the economy of the whole
world
...

How does a computer ‘catch’ a virus? A virus program has
to be placed in your RAM, and your computer has to jump
to the virus program and run it
...

After the virus program locates this file, it copies the
virus program to the end of this file, and inserts a
jump instruction at the beginning of the file that
causes a jump to where the virus program is
...

When a computer with a virus is running, it does all of
the things it is supposed to do, but whenever it runs
the program that contains the virus, the inserted jump
instruction causes the virus program to be run instead
...

Thus, your computer will appear totally normal, there
are just a few extra instructions being executed during
its regular operations
...
But when that date arrives, and the virus
238

‘decides’ to do whatever is in the rest of its program,
it can be anything
...
It can erase files on your disk, or send
them somewhere else via the internet
...

Here’s an example of how to catch a virus
...
It makes him laugh, and he thinks that you
will enjoy it too, so he emails the movie file to you
...

There are two different things that could have occurred
here
...
mov,”
and your OS includes a program that plays ‘
...
mov” file
and display them on your screen
...
The “funny
...

But if your friend sent you a file named “funny
...
exe” into RAM and jump to its first instruction
...
If it is a virus program, it
will probably play the movie for you so that you don’t
suspect anything, but it can do anything else that it
wants, to the files on your disk while you are watching
the movie
...
’ But sooner or later it
will come alive and do whatever damage it was designed
to do
...
A real virus is a thing that is
smaller than a one celled animal
...
They do reproduce, however, by
239

invading a cell of something that is alive
...

The computer virus also cannot reproduce or do anything
else by itself
...
When
it runs that first time, it inserts itself somewhere
into the operating system so that it will thereafter get
executed on a regular basis
...


240

Firmware
Of course, RAM is an essential part of any computer
...

But in some computers, there are sections of the RAM
that only get written to when the computer starts up,
and thereafter these sections remain unchanged as the
computer operates
...
Perhaps half of the
RAM is used to contain the program, and the other half
of the RAM is used to contain the data that the program
is working on
...

When you have this sort of situation, you can build half
of your computer’s RAM the normal way, and with the
other half, you skip the NAND gates, and just wire each
bit directly to an on or an off in the pattern of your
program
...
This type of RAM was
given the name Read Only Memory, or ROM for short
...

There are two advantages to ROM
...

The other advantage is that you no longer have to load
the program into RAM when you first turn the computer
on
...

The point here is a new word
...
You can’t write into a ROM, you can’t
change the bits
...
’ It is software that is permanently
written into hardware
...
The ROM described
above had to be built that way at the factory
...

The next advance was when someone had the bright idea of
making ROM where every bit was set on at the factory,
but there was a way of writing to it with a lot of power
that could burn out individual connections, changing
individual bits to an off
...
This was called
‘Programmable ROM’ or ‘PROM’ for short
...
This
was called an ‘Erasable PROM’, or ‘EPROM’ for short
...
This was called ‘Electrically
Erasable PROM’, or ‘EEPROM’ for short
...

So there is RAM, ROM, PROM, EPROM, EEPROM and Flash
...
The thing they
have in common is that they all allow random access
...
The big
difference is that RAM loses its settings when the power
goes off
...
The rest of them all still have their data
after power off and back on
...
” The answer is that it takes much
longer to write into EEPROM than RAM
...
If someone figures out how
to make an EEPROM that is as fast and as cheap and uses
the same or less power as RAM, I’m sure it will be done
...


242

Boots
What do boots have to do with computers? Well, there is
an old phrase that goes “pull yourself up by your own
bootstraps
...
The joke is
that if you are wearing such a pair of boots, and want
to get up off the ground, instead of getting a ladder or
climbing a rope, you can get yourself off the ground by
simply pulling hard enough on those bootstraps
...

In a computer, there is a problem that is similar to
needing to get off the ground and having no tools
available to accomplish it
...
Now that
program is running
...
But when you turn the computer on, every byte
in memory is all zeros
...
This is the impossible situation, you
need a program in memory to get a program in memory, but
there is nothing there
...
It has to pull itself up by its
bootstraps!
A long time ago, in the early days of computers, the
machine had switches and push buttons on the front panel
that allowed the operator to enter bytes of data
243

directly into the registers, and from there, into RAM
...
This program, called a “bootstrap
loader,” would be the smallest possible program you
could write that would instruct the computer to read
bytes from a peripheral, store them in RAM, and then
jump to the first instruction
...

Nowadays, there are much easier ways of loading the
first program into the computer, in fact it happens
automatically immediately after the computer gets turned
on
...

The most common solution to this problem has three
parts
...
Thus for our little computer, the
first instruction to be fetched will be at address 1111
1110
...
The third part
then, had better be that there is a program written on
that first sector of the disk
...

This word ‘boot’ has become a verb in computer talk
...
Sometimes people use it to mean loading any
program into RAM, but its original meaning only applied
to loading the first program into an otherwise blank
RAM
...
Analog
You’ve no doubt heard these terms bandied about
...
But that’s not
quite close enough to the truth
...

The word ‘digital’ comes from digit, which means fingers
and toes in some ancient language, and since fingers and
toes have been used for counting, digital means having
to do with numbers
...
) are called
digits
...
One of the qualities of bits and bytes is
their unambiguous nature
...
A byte is always in
one of its 256 states; there is no state between two
numbers like 123 and 124
...

The word ‘analog’ comes from the same place as ‘analogy’
and ‘analogous,’ thus it has to do with the similarity
between two things
...
A voice
can be a shout or a whisper or absolutely anywhere in
between
...

Sound and electricity are two very different things, but
the essence of the voice has been duplicated with
electricity
...
Although the meaning of ‘analog’ comes from
this ‘similarity’ factor, when you make an analog, you
are usually making an analog of something that is
continuously variable
...

Something that is analog can be anywhere within the
245

entirety of some range, there are no steps
...
Another way to say it is
that digital means that the elements that make up a
whole come from a finite number of choices, whereas
analog means that a thing is made of parts that can be
selected from an unlimited number of choices
...

If you have a platform that is three feet above the
floor, you can either build stairs for people to climb
up to it, or a ramp
...
The
ramp is analog, the stairs are digital
...
You have a choice of making the walkway out of
concrete or out of bricks
...
If you
make the walk out of concrete, you can pour it to any
width you want
...

If you have an old book and an old oil painting, and you
want to make a copy of each, you will have a much easier
time making a copy of the book
...
With
the oil painting, the original colors may have faded and
are obscured by dirt
...
Each letter in the book comes
from a list of a specific number of possibilities; the
variations of paint colors and their positions on the
canvas are limitless
...

So there you have the difference between analog and
digital
...
Most old
technologies were analog, like the telephone,
246

phonograph, radio, television, tape recorders and
videocassettes
...
Now that digital
technology has become highly developed and inexpensive,
the analog devices are being replaced one by one with
digital versions that accomplish the same things
...
An old fashioned telephone is
an analog machine that converts analog sound into an
electrical pattern that is an analog of the sound, which
then travels through a wire to another phone
...
Then the digital code travels to
another digital phone where the digital code is
converted back into analog sound
...
When an analog electrical
pattern travels over long distances, many things can
happen to it along the way
...
The
farther the sound goes, the more noise and distortion
are introduced
...

Enter digital technology to the rescue
...
However, it doesn’t matter
if a bit is only 97% on instead of 100%
...
As long
as a bit is still more than half way on, the gate that
it goes into will act in exactly the same way as if the
bit had been fully on
...

247

There are advantages and disadvantages to each method,
but in general, the benefits of digital technology far
outweigh its shortcomings
...
When you make a copy of something
like a vinyl record, you could record it to a tape
recorder, or I guess you could even get all of the
equipment to cut a new vinyl record
...
In the first place, all machinery has accuracy
limitations
...
Second, if
there are any scratches or particles of dust on the
original, the copy will then have duplicates of these
defects
...
If you use a tape recorder, there is
always a low level of ‘hiss’ added to the sound
...
the
changes will get larger and larger at each stage
...
You can make a
copy of the copy, and a copy of that, etc
...

Digital is definitely the way to go if you want to be
able to make an unlimited number of copies and preserve
something for all time
...
And if all we ever wanted to do with
them were digital things such as arithmetic and written
language, we could leave it that way
...


248

I Lied – Sort of
There is one piece of hardware in a computer that is not
made completely out of NAND gates
...
They are used to change
from something that is analog to something that is
digital, or digital to analog
...
Things
that we hear can be loud or soft, things that we see can
be bright or dark and be any of a multitude of colors
...
But each pixel only had one
bit to tell it what to do, to be on or off
...
But we have all seen
photographs on computer screens
...
If you get out a magnifying glass
and look at a color computer or television screen, you
will see that the screen is actually made up of little
dots of three different colors, blue, red, and green
...

When the display adapter scans the screen, it selects
all three colors of each pixel at the same time
...
With three
bits, each color could be fully on or off, and each
pixel would therefore have eight possible states: black,
green, red, blue, green and red (yellow,) green and blue
(cyan,) blue and red (magenta) and green, blue and red
(white
...
To
do that, we need to be able to control the brightness of
each color throughout the range between fully on and
fully off
...
Instead of one bit for each color in each
249

pixel, we could have a whole byte for each color in each
pixel
...

With these bytes, using the binary number code, you
could specify 256 levels of brightness for each color in
each pixel
...
This is enough
variety to display a reasonably good-looking photograph
...
A
DAC has eight digital inputs, and one analog output
...
The output has 256 gradations
between off and on, and it goes to the level that the
input number specifies
...
For a 64 the output will be
one quarter on
...


In order to make this color screen work, the display
adapter needs to access three bytes at a time, connect
them to three DACs, and connect the outputs of the DACs
to the three colors in the current pixel being painted
...

When we defined ‘analog’ in the last chapter, we said
250

that it was something that was continuously variable
from fully off to fully on
...
It’s a lot
closer to being analog than a bit, but it still has
steps
...
When it comes to the eye, 256 different levels
of brightness is sufficient
...
Thus you can present the digital input
with a number anywhere from 0 to 65535
...

When it comes to the ear, it can hear very small
differences, and so a 16 bit DAC is required for high
quality sound
...
They vary in how fast the air
vibrates, and in exactly how it vibrates
...

For any electronic machine to make sounds, there is a
device called a speaker
...
If it
makes the air vibrate in precisely the same way as the
original thing that was recorded, it will sound just
like the original
...

Then a second is divided into 44,100 parts
...
This is enough
information to reproduce sound with very high quality
...
’ This would have two 16 bit DACs
with their analog outputs connected to speakers
...

At each tick, it would get the next two two-byte
numbers, and connect them to the digital side of the
251

DACs
...
Certainly that is fast, but remember that our
computer clock ticks a billion times per second
...

For going the other way, there is an “Analog to Digital
Converter,” or “ADC” for short
...
The input has one wire that can be anywhere from
all the way off to all the way on
...
This number represents
how much the input is on or off
...
This
process is just the reverse of what a DAC does
...
How they do what they
do is not a proper subject for this book
...


253

Full Disclosure
We have built a very small computer here
...

I don’t think that anyone has built such a small
computer since about 1952, and no one has ever built
this exact computer in the real world
...
But again, the goal has been to
illustrate computer principles as simply as possible
...
That means that the
registers in the processor are eight bits, the bus is
eight bits, and in this machine, even the Memory Address
Register is eight bits
...

Our RAM only has 256 bytes, which is ridiculously small,
but that’s all you can have with an eight-bit Memory
Address Register
...

Real computers have things that this one does not, but
they are not capable of doing things that this computer
cannot do
...
In most real computers, they have
shifters that will shift any number of bits in one
instruction
...

In our computer, the adder can add two eight-bit
numbers
...
In most computers, the
adder can add 16 or 32 bit numbers in one instruction
...

The stepper in our computer is a simplification of
something that most computers have, called a ‘state
machine
...
Since all we needed was six
consecutive steps, we built a simpler thing and just
made up the term ‘stepper
...
The things that make a bigger machine
bigger, are designed to get the job done faster, do it
in fewer clock cycles, do the same task with fewer
instructions, operate on several bytes at the same time
...
Every task they can do comes down to shifting,
ANDing, ORing, XORing, ADDing and NOTing bytes
...

In a bigger machine, you can do addition, subtraction,
multiplication and division in a single instruction
...
’ There is no
reason to show you the details of how you construct one
of these, it is a very complicated job for the few
people who need to build one
...
But we have seen how to do all the math
operations there are with just an adder, shifter, NOT
gates and some software
...

Bigger machines have more registers, the registers are
each multiple bytes, they have adders that can add three
numbers at the same time, but still the instructions
come down to the same simple operations
...


255

Philosophy
Why do we have a chapter called “Philosophy” in a book
about computers? The only thing in this book that even
comes close to being a philosophical question is its
title, “But How do it Know?” We will attempt to answer
this question a little later on
...
But what about the future? As computers and
software continue to advance, how soon if ever, will the
day come when there are walking talking computerized
robots that look and act just like people? Will the day
come when we have to decide whether or not to give these
robots the same legal rights as people? Will computers
eventually take over the world and replace people
altogether?
To answer these sorts of questions, people often refer
to a major question that has been outstanding in the
field of philosophy for many years
...

That question is far beyond the scope of this book, and
it remains unconvincingly answered despite many books
arguing each viewpoint
...
There are people in the
humanities who say that it is impossible because you
can’t manufacture a spirit
...

If we define the brain as that funny looking chunk of
gray meat enclosed by the skull, and define the mind as
whatever it is that is responsible for consciousness,
memory, creativity, thinking, and everything else that
we notice going on in our heads, then we can restate the
big philosophic question as: “Are the brain and the mind
one and the same thing?”
Then when it comes to the question about building a
convincing human robot, there would be two
256

possibilities
...

If the brain and the mind are not the same thing, then
building a robot buddy will always be about simulating
humanity, not building something of equal quality and
value
...

Early on, we said that we were going to show how
computers work so that we could see what they were
capable of doing, and also what they were not capable of
doing
...
In
doing so we can look for differences and similarities,
and we may be able to answer a few less controversial
questions
...
A computer can do millions
of additions in a single second
...

The mind seems to have the ability to look at and
consider relatively large amounts of data at the same
time
...
These are some of the
ways that I know my pet
...
Is
257

that thinking? If you ran the bytes of these files one
by one through the ALU, would that be thinking? If you
put the picture on the screen, would that be thinking?
If you played the sounds to the speakers, would that be
thinking?
The sounds and pictures encoded in the computer are just
byte patterns sitting where they are
...

And if they are sent to the screen and speakers, the
computer doesn’t see them or hear them
...

There could be programs that perform mathematical
operations on the picture files in order to discover
patterns, and store the results of these calculations in
other files
...
, creating more files
...

The mind can consider the whole of some thing all at the
same time
...
Its sort of like the difference between the movie
film and the TV screen
...

You could say that your mind works so quickly that you
don’t notice the details, it gets integrated into a
whole just like the pixels get integrated into an entire
picture
...
The
computer moves one byte at a time over the bus
...

Everything else it ‘does’ amounts to nothing more than
the simple warehousing of bytes
...

258

A computer just doesn’t have any facilities that
integrate the elements of a picture into anything else,
nowhere to store that something else, and nothing with
which to look at it
...

Here is another question
...
Where would this program come from?
Although the brain has trillions of cells, the entire
human body starts with one fertilized egg cell
...

Scientists have now decoded the entire DNA sequence of
humans
...
It’s digital! A lot of the
pieces of this string are used for making chemical
reactions take place to make proteins, etc
...
But even if you consider that the
entirety of the DNA is devoted to computer software,
then there could be about a billion instructions in this
program
...

Some have said that the human computer programs itself
...
While it’s true that a program can
accumulate data and modify the way it works based on the
collected data, this is not the same thing as writing a
new program
...

Then there are the kinds of errors that computers make
versus the kind that people make
...

259

Have you ever seen a person walking down the street
suddenly stop working? All functions just cease
...
People do collapse from time to time, but it
is usually because some other part broke, like having a
heart attack, and you can see the person recognize the
pain as it takes them down
...
I have never seen that, but if
the brain operated just like a computer, you would
expect to see it on a fairly regular basis
...
As we have seen, a
simple computer can do a billion things in a second
...
Nerves can also
carry electricity from place to place
...
In the
brain, nerves are connected together by “synapses
...
These chemical reactions are painfully
slow
...
After the
electricity travels quickly through the nerve cell, it
reaches the synapse, where the chemical reaction takes
about one five hundredth of a second to complete
...

Another area where the difference between the mind and
computers is quite obvious, is in the area of
recognizing faces
...
If you
walk into a party with fifty people present, you will
know in a matter of seconds whether you are among a
260

group of friends or of strangers
...

There is also a lot of speculation, and there are many
fascinating theories about the underlying principles and
mechanisms
...

If you give a computer a picture file of a person, and
then give it the same file again, it can compare the two
files byte by byte and see that each byte in one file is
exactly equal to the corresponding byte in the other
file
...
For the computer to determine
that these two files represent the same person is a huge
task
...

The point is that computers have a method of dealing
with pictures based on the principles on which computers
work
...

Voice recognition by computers is another technology
that has come a long way, but has much further to go to
rival what the mind does easily
...
The brain is very slow, there isn’t any
place to get the software to run it, and we don’t see
the types of problems we would expect with computer
software errors
...

Science fiction books and movies are full of machines
that read minds or implant ideas into them, space ships
with built-in talking computers and lifelike robots and
androids
...
These
machines seem to feel less than complete because they
are just machines, and want desperately to become fully
human
...

But would it be possible to build such machines with a
vastly expanded version of the technology that we used
to build our simple computer?
Optimism is a great thing, and it should not be
squashed, but a problem will not be susceptible to
solution if you are using a methodology or technology
that doesn’t measure up to that problem
...
And let’s not even look
into subjects like politics
...

As an example, many visions of the future have included
people traveling around in flying cars
...
But they
are expensive, inefficient, noisy and very dangerous
...

If two flying cars have any sort of a minor accident,
everyone will die when both cars crash to the Earth
...
Unless and until someone
invents a cheap and reliable anti-gravity device, there
will not be a mass market for flying cars and traffic on
the roads will not be relieved
...

When Thomas Edison invented the phonograph, he was
dealing with the subject of sound
...
So he invented an apparatus that captured
the vibrations in the air and transformed them into a
vibrating groove on the surface of a wax cylinder
...
The point
is, that in order to recreate sound, he found out how
sound worked, and then made a machine that worked on the
same principle
...

A lot of research has been done on the subject of what
makes people tick
...
A lot of things have been discovered and a
lot of things have been invented
...

But there are many things that have not yet been
discovered or invented
...
The brain does contain
nerve cells which move electricity from one place to
another
...
But research into the actual operation of
living human brains is necessarily limited
...
Many observations
have been made of changes to behavior after an injury or
disease has disabled certain parts of the brain
...

But no one has discovered a bus, a clock, any registers,
an ALU or RAM
...
It has been shown that nerves
grow new connections over time, and it is assumed that
this is the mechanism of learning, but no one has been
263

able to say that this particular nerve does this exact
function, as we can do with the individual wires in a
computer
...
The keyboard generates one byte of
ASCII per keystroke, a microphone generates 44,100
binary numbers per second, a color camera generates
three binary numbers per pixel, 30 times a second, and
so on
...
They may be there, but they have not been
isolated
...

It is widely assumed that the brain works in some much
more spread out way than a single computer, that there
are thousands or billions of computer elements that
cooperate and share the work
...
In the world of computing, this idea
is called ‘parallel processing’ and computers with
dozens or hundreds of CPUs have been built
...

Think of it all as a puzzle
...
Making computers do things that people do
is the other side of the puzzle
...
The problem is that
as progress is being made on both sides, it looks more
and more like these are two different puzzles, they are
not coming together in the middle
...

The researchers are very aware of these developments
...
In the past century we
conquered electricity, flight, space travel, chemistry,
nuclear energy, etc
...

264

So it appears that whichever way we look at it, neither
the brain nor the mind work on the same principles as
computers as we know them
...
But all of the computers we have today come
under the definition of ‘Stored Program Digital
Computers,’ and all of the principles on which they
operate have been presented in this book
...
Some completely different type of device
that operates on some completely different set of
principles might be able to do it
...

Going back to a simpler question, do you remember Joe
and the Thermos bottle? He thought that the Thermos had
some kind of a temperature sensor, and a heater and
cooler inside
...

A pair of scissors is a device that performs a function
when made to do so
...
The blades at the other end of the
scissors move together and cut some paper or cloth or
whatever it is that you have placed in their way
...

Similarly, NAND gates don’t “know” what they are doing,
they just react to the electricity or lack of it placed
on their inputs
...

We use a lot of words that give human characteristics to
our computers
...
We say it
“remembers” things
...
” Even something as simple as a device
adapter “listens” for its address to appear on the I/O
265

bus, or a jump instruction “decides” what to do
...

Now that we know what is in a computer, and how it
works, I think it is fairly obvious that the answer to
the question “But How do it Know?” is simply “It doesn’t
know anything!”

266


Title: The Basic Principles of Computers
Description: The Basic Principles of Computers for Everyone