2 CHAPTER 1. THE MENTAL LANDSCAPE
location. The CPU can also store information in memory by specifying the information to be
stored and the address of the location where it is to be stored.
On the level of machine language, the operation of the CPU is fairly strai ghtforward (al-
though it is very complicated in detail). The CPU executes a program that is stored as a
sequence of machi ne language instructions in main m emor y. It does this by repeatedly reading,
or fetching, an instructi on from memory and then carrying out, or executing, that instruc-
tion. This process—fetch an instruction, execute it, fetch another instruction, execute it, and so
on forever—is called the fetch-and-execute cycle. With one exception, which will be covered
in the next section, this is all that the CPU ever does.
The details of the fetch-and-execute cycle are not terribly important, but there are a few
basic things you should know. The CPU contains a few internal registers, which are small
memory units capable of holding a single number or machine language inst r uc ti on. The CPU
uses one of these registers—the program counter, or PC—to keep track of where i t is in the
program it is e x ec ut i ng. The PC simply stores the memory address of the next instruction that
the CPU should execute. At the beginning of each fetch-and-execute cycle, the CPU checks the
PC to see which instructi on it should fetch. During the course of the fetch-and-execute cycle,
the number in the P C is updated to indicate the instruction that is to be executed in the next
cycle. (Usually, but not always, this is just the instruction that sequentially follows the current
instruction in the program.)
∗ ∗ ∗
A computer executes machine language programs mechanically—that is without under-
standing them or thinking about them—simply because of the way it is physically pu t together.
This is not an easy concept. A computer is a machin e built of millions of tiny switches calle d
transistors, which have the property that they can be wired together in such a way that an
output from one switch can turn another switch on or off. As a computer compute s, these
switches turn e ach other on or off in a pattern determined both by the way they ar e wired
together and by the program that the computer is executing.
Machine language instructions are expressed as binary numbers. A binary number i s made
up of just two possible digits, zero and one. Each zero or one is called a b it. So, a machine
language instruction is just a sequence of zeros and ones. Each particular sequence encodes
some particular inst r uc ti on. The data that the computer manipulates is also encoded as binary
numbers. In modern computers, each memory location holds a byte, which is a sequence of
eight bits. (A machine language instructi on or a piece of dat a generally consists of several bytes,
stored in consecutive memory locations.)
A compute r can work directly with binary numbers because switches can readily represent
such numbers: Turn the switch on to represent a one; turn it off to repr e se nt a zero. Machine
language instructions are store d in memory as patterns of switches turne d on or off. When a
machine language instruction is loaded into the CPU, all that happens is that certain switches
are turned on or off in the pattern that encodes that instruction. The CPU is built to respond
to this pattern by executing the instruction it encode s; it does this simply because of the way
all the other switches in the CPU are wired toget he r .
So, you should understand this much about how computers work: Main memory holds
machine language programs and data. These are encoded as binary numbers. The CPU fetches
machine language instructions from memory one after another and execute s the m. It does
this mechanically, without thinking about or understanding what it does—and therefore the
program it executes must be perfect, complete in all details, and unambiguous because the CPU
can do nothing but execute it exactly as written. Here is a schematic view of this first-stage