computer ,1 all computing devices, from the abacus to the earliest electronic computing machines, had to be manipulated by an operator or group of
operators who manually entered a particular sequence of commands each
time they wanted to make a particular calculation. In contrast, modern com-
puters store and reuse such command sequences, and as such they have a
level of flexibility and usefulness that sets them apart from everything that
has come before. In the rest of this chapter, you’ll get a first-hand look at the many ways that the stored-program concept affects the design and capabilities of the modern computer.
Refining the File-Clerk Model
Let’s take a closer look at the relationship between the code, data, and
results streams by means of a quick example. In this example, the code
stream consists of a single instruction, an add, which tells the ALU to add
two numbers together.
1 In 1944 J. Presper Eckert, John Mauchly, and John von Neumann proposed the first stored-program computer, the EDVAC (Electronic Discrete Variable Automatic Computer), and in 1949 such a machine, the EDSAC, was built by Maurice Wilkes of Cambridge University.
6
Chapter 1
The add instruction travels from code storage to the ALU. For now, let’s
not concern ourselves with how the instruction gets from code storage to
the ALU; let’s just assume that it shows up at the ALU’s code input port
announcing that there is an addition to be carried out immediately. The
ALU goes through the following sequence of steps:
1.
Obtain the two numbers to be added (the input operands) from data
storage.
2.
Add the numbers.
3.
Place the results back into data storage.
The preceding example probably sounds simple, but it conveys the basic
manner in which computers— all computers—operate. Computers are fed
a sequence of instructions one by one, and in order to execute them, the
computer must first obtain the necessary data, then perform the calculation
specified by the instruction, and finally write the result into a place where the end user can find it. Those three steps are carried out billions of times per
second on a modern CPU, again and again and again. It’s only because the
computer executes these steps so rapidly that it’s able to present the illusion
that something much more conceptually complex is going on.
To return to our file-clerk analogy, a computer is like a file clerk who
sits at his desk all day waiting for messages from his boss. Eventually, the
boss sends him a message telling him to perform a calculation on a pair of
numbers. The message tells him which calculation to perform, and where in
his personal filing cabinet the necessary numbers are located. So the clerk
first retrieves the numbers from his filing cabinet, then performs the calcula-
tion, and finally places the results back into the filing cabinet. It’s a boring, mindless, repetitive task that’s repeated endlessly, day in and day out, which
is precisely why we’ve invented a machine that can do it efficiently and not
complain.
The Register File
Since numbers must first be fetched from storage before they can be added,
we want our data storage space to be as fast as possible so that the operation
can be carried out quickly. Since the ALU is the part of the processor that
does the actual addition, we’d like to place the data storage as close as
possible to the ALU so it can read the operands almost instantaneously.
However, practical considerations, such as a CPU’s limited surface area,
constrain the size of the storage area that we can stick next to the ALU. This
means that in real life, most computers have a relatively small number of very
fast data storage locations attached to the ALU. These storage locations are
called registers , and the first x 86 computers only had eight of them to work with. These registers, which are arrayed in a storage structure called a register file , store only a small subset of