Central Processing Unit: Next Section
Central Processing Unit: Next Section
When the CPU executes a program, that program is stored in the computer's main
memory (also called the RAM or random access memory). In addition to the
program, memory can also hold data that is being used or processed by the
program. Main memory consists of a sequence of locations. These locations are
numbered, and the sequence number of a location is called its address. An address
provides a way of picking out one particular piece of information from among the
millions stored in memory. When the CPU needs to access the program instruction
or data in a particular location, it sends the address of that information as a signal
to the memory; the memory responds by sending back the data contained in the
specified 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.
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 instruction. The CPU uses one of these registers -- the program counter,
or PC -- to keep track of where it is in the program it is executing. The PC stores
the 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 instruction it
should fetch. During the course of the fetch-and-execute cycle, the number in the
PC 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.)
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 executes them. 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
understanding of the computer: