How a Machine Learned to Follow a Plan: Instructions and the CPU

Planted 02026-08-01

How can a stored pattern become an action?

How can a pattern resting in memory become an action performed by a machine?

How can a row of zeros and ones tell gates to subtract, preserve a result, or return to an earlier step?

Memory gave the machine a past. It could preserve a number after the signals that produced it disappeared. It could also preserve something stranger: a pattern intended to describe what the machine should do.

But memory does not know the difference.

It will store a number and an instruction with equal indifference. It will return either pattern when given an address. Nothing in a bit announces that it is a command.

For a stored plan to unfold, another mechanism must repeatedly perform a transformation:

Silent pattern

Coordinated electrical action

Changed machine state

Next silent pattern

That mechanism is the central processing unit—the CPU.

Its achievement is not that it understands the plan.

It is that it can obey one small instruction, find another, and repeat.

1. Seventeen instructions on a fading screen

On June 21, 1948, the Manchester Small-Scale Experimental Machine—the Baby—successfully ran a program stored in its electronic memory.

Tom Kilburn had written the program to find the highest proper factor of a number. The original version contained only seventeen instructions. The Baby had no hardware divider, so the program performed division indirectly by repeatedly subtracting a possible factor until it could determine whether the number divided evenly.

Each instruction had to be entered into the machine as a pattern of bits. The Baby offered only seven instruction types. A three-bit field identified the operation; other bits identified a location in its thirty-two-word memory.

Three bits could form eight possible patterns:

000
001
010
011
100
101
110
111

To a person, one pattern could be documented as “subtract.” Another could mean “store.” Another could mean “stop.”

To the memory tube, they were only marks.

The difficult question was not how to preserve those marks. Williams, Kilburn, and Geoff Tootill had built the Baby largely to test that problem.

The next question was:

What makes one stored pattern become subtraction while another becomes a jump?

The answer was not hidden inside the pattern.

It was built into the machine around it.

2. The memory that cannot recognize a command

Consider two sixteen-bit patterns:

0000000000000101
1110110000010000

The first might represent the number five.

The second might represent an instruction.

But it could just as easily represent a large unsigned number, a negative number, a pixel pattern, two characters, or part of an address.

Bits do not arrive carrying labels.

A memory location promises only:

Give me an address.
I will return the pattern stored there.

It does not promise to explain what the pattern means.

The distinction between data and instruction comes from use.

Send a pattern into an adder, and the circuitry treats it as a number.

Send part of a pattern into an ALU control input, and the circuitry treats those bits as a choice of operation.

Send part of it into a memory address input, and the circuitry treats those bits as a location.

The physical alphabet remains the same. Meaning changes with the pathway.

This is what makes the stored-program idea so powerful.

A plan does not require a separate material. It can be represented in the same memory and with the same kinds of bits as the values on which it operates.

But sharing an alphabet creates a burden.

The machine needs a fixed agreement about how an instruction is arranged.

3. A command must fit inside a word

A machine instruction is a bit pattern divided into fields.

A simplified instruction might look like this:

┌───────────┬───────────────┬─────────────┐
│ Operation │ Input or addr │ Destination │
└───────────┴───────────────┴─────────────┘

One field answers:

What transformation should happen?

Another answers:

Which value or memory location should participate?

Another might answer:

Where should the result go?

The exact division differs from one computer architecture to another. The Manchester Baby used a three-bit function field and a field associated with a store address. Its tiny instruction vocabulary included loading a negated value, subtracting, storing, changing the current instruction address, conditionally skipping an instruction, and halting.

The instruction format was therefore an agreement between program and hardware.

If a program placed one code in the function field, the hardware would produce one family of control signals.

If it placed another code there, a different family would appear.

The bits did not acquire meaning because a person wrote their definition in a manual.

They acquired operational meaning because engineers connected them to circuits that behaved differently for each pattern.

A three-bit instruction code can be imagined as three questions entering a network of gates:

Bit 2 high or low?
Bit 1 high or low?
Bit 0 high or low?

The combined answers distinguish one operation from another.

That network is the beginning of a decoder.

4. The circuit that turns a code into control

Suppose an instruction contains a code meaning “subtract.”

The machine may need to make several things happen together:

Read a value from memory.
Send that value to the ALU.
Select subtraction.
Preserve the result in a register.
Do not write to main memory.
Advance to the next instruction.

No single control wire can express the whole event.

The instruction must be translated into many smaller yes-or-no decisions.

This is the work of control logic.

A decoder is a network of gates whose outputs respond to particular input patterns. For a simple two-bit code, the outputs might behave like this:

Code   Active output
 00       Line 0
 01       Line 1
 10       Line 2
 11       Line 3

Only one line becomes active for each code.

That line can then influence other circuits:

Instruction bits

     Decoder

ALU controls
Register load signals
Memory write signal
Program-counter controls

The decoder does not translate in the human sense. It has no internal dictionary and does not know the word subtract.

Its gates merely fulfill their promises.

But when those promises are connected to the ALU, registers, memory, and program counter, a symbolic code becomes coordinated physical behavior.

This is the point where the earlier parts of the machine return.

Logic gates distinguish instruction patterns.

Multiplexers select pathways.

The ALU performs the requested transformation.

Registers preserve selected results.

The clock determines when those results become the machine’s new state.

The CPU is not made from a mysterious new substance.

It is the old machinery arranged into a loop.

5. The values kept close at hand

A machine with memory could, in principle, place every temporary value in main memory.

But the CPU repeatedly needs a small set of values:

  • a number currently being transformed;
  • an address currently being used;
  • an intermediate result;
  • the instruction currently being obeyed;
  • and the location of the instruction that should come next.

Constantly sending every temporary value into the larger memory system would make the machine’s pathways more cumbersome.

Instead, CPUs contain a small number of internal storage elements called registers.

The Manchester Baby used an accumulator for working arithmetic, a control-instruction register associated with the current position, and a present-instruction register holding the instruction being executed.

The Hack CPU built in Nand to Tetris uses two prominent working registers:

  • the A register, which can hold a value or a memory address;
  • the D register, which holds working data.

It also relies on the program counter developed in the memory project. The architecture project combines those registers with the previously constructed ALU to form the Hack CPU.

A useful metaphor is a desk and a filing room.

Main memory is the filing room. It contains many numbered locations.

Registers are the few pages currently open on the desk.

The metaphor is imperfect, but it captures the difference in role. The CPU uses registers as immediate participants in the present operation.

A register still does not know what its bits mean.

The A register may hold the number seven during one instruction and the address seven during another. Its changing role comes from the control signals and pathways around it.

The machine’s meaning remains architectural.

6. Fetch: finding the next silent pattern

The memory essay ended with a special register: the program counter.

Its stored number answers:

Which instruction comes next?

Suppose the program counter contains twelve:

PC = 12

The machine sends twelve to instruction memory as an address.

Instruction memory returns the bit pattern stored at that location:

Program counter = 12

Instruction memory[12]

Current instruction

This step is called fetching.

The word can sound more active than the mechanism. No tiny agent travels into memory and brings the instruction back.

The program counter presents an address. Memory responds with the pattern stored there. Wires carry that pattern toward the CPU.

Yet the effect is consequential.

A passive arrangement of bits has become the machine’s current concern.

The CPU’s world narrows to one instruction.

It does not fetch the entire plan into awareness. It does not inspect the ending or understand how this step contributes to a larger goal.

It receives one pattern from one location.

Then it reacts.

7. Decode: dividing one pattern into several questions

Once fetched, the instruction’s fields travel toward different parts of the CPU.

The operation bits enter the control logic.

Address bits may enter a register or help select a memory location.

Destination bits may determine which registers are permitted to load a result.

Jump bits may combine with the ALU’s status outputs.

What appears to a programmer as one command becomes a set of simultaneous electrical questions:

Which ALU operation?
Which input pathway?
Which register may change?
Should memory accept a value?
Should the program counter advance or jump?

This step is called decoding.

The name can suggest that the machine first possesses a mysterious encrypted sentence and then discovers its meaning.

The reality is more direct.

Each bit is already connected to the circuits it can influence. Decoding is the physical consequence of presenting the instruction pattern to those connections.

A high bit may open one pathway.

A low bit may close another.

Several bits together may activate exactly one control line.

The instruction does not describe the control signals from a distance.

Through the decoder, it becomes them.

8. Execute: letting the selected pathways respond

After the instruction has established the control signals, values flow through the selected pathways.

Suppose the instruction requests an addition using the D register and a value from memory.

The machine may behave like this:

D register ─────────────┐
                        ├──→ ALU ──→ result
Selected memory value ──┘

                         add controls

The ALU’s gates respond.

Some pathways invert inputs. Others select zero or preserve the incoming patterns. The adder produces its output. Multiplexers choose the requested result.

This step is called execution.

But execution is not a separate magical phase added on top of the circuitry.

It is what the circuitry does after the instruction has arranged its conditions.

During the interval before the next clock boundary, signals propagate and settle.

The ALU output may be available to several possible destinations:

A register
D register
Main memory
Nowhere

The instruction’s destination controls determine which storage elements, if any, are allowed to accept it.

At the clock boundary, the selected registers or memory location change.

A proposed result becomes part of the machine’s state.

The instruction has left a consequence behind.

9. The loop that becomes a processor

After executing an ordinary instruction, the program counter advances:

PC = PC + 1

If the current instruction came from location twelve, the machine prepares to fetch from location thirteen.

Then the process begins again:

Fetch an instruction

Decode its fields

Execute the selected operation

Store any result

Choose the next instruction address

This is often called the fetch–decode–execute cycle.

Its apparent simplicity conceals the transformation that has occurred.

Memory contains static patterns.

The CPU repeatedly turns one of those patterns into motion, state change, and a new address.

Then another pattern becomes active.

Then another.

The CPU never needs to hold the program’s whole meaning.

At each cycle, its world is narrow:

This instruction.
These input values.
This result.
This next address.

The plan exists not inside any one cycle, but in the relationship among many cycles.

A melody is not contained in one note.

A journey is not contained in one step.

A program is not contained in one instruction.

10. The instruction that refuses to continue normally

If every instruction merely advanced the program counter, execution would follow a straight line:

0 → 1 → 2 → 3 → 4 → 5

The machine could follow a list, but it could not repeat part of the list. It could not choose between alternatives. It could not continue searching until a condition changed.

A jump gives the program counter another possible future.

Instead of accepting PC + 1, it loads a different address:

Ordinary next address ──┐
                        ├── MUX ──→ Program counter
Jump destination ───────┘

                         Jump control

The multiplexer has returned again.

In the ALU, it selected which calculated result mattered.

In a register, it selected between the old value and a new one.

Here, it selects which part of the program becomes the machine’s future.

An unconditional jump says:

Continue from that address.

A conditional jump says:

Continue from that address only if the latest result has a particular property.

The ALU already reports small facts about its output:

Is the result zero?
Is the result negative?

The CPU can combine those facts with the instruction’s jump controls:

Jump requested?
       +
Condition satisfied?

Load the destination into the program counter

The result of a calculation can now alter which instruction happens next.

This creates branches and loops.

The machine’s future becomes contingent on its own past.

Tom Kilburn’s factor program demonstrates why jumps matter.

The Baby did not contain an instruction meaning:

Find the highest proper factor of this number.

It did not even contain a hardware division operation.

Kilburn had to decompose the mathematical goal into actions the machine possessed.

A simplified version of the procedure is:

Choose a possible factor.
Subtract it from the number repeatedly.
If the remainder reaches zero, it is a factor.
If the remainder passes below zero, try a smaller factor.
Repeat.

The machine’s instruction set supplied only primitive verbs:

Load.
Subtract.
Store.
Skip conditionally.
Jump.
Stop.

The larger procedure lived in their arrangement.

Repeated subtraction became division.

A backward jump became a loop.

A conditional skip became a decision.

Changing the trial value became a search.

The original program needed only seventeen instructions. Within days, the team used a version of the program to test a much larger number. It executed about 2.1 million instructions, made roughly 3.5 million store accesses, and ran for fifty-two minutes before producing the correct answer.

The machine had only a tiny vocabulary.

Repetition gave that vocabulary reach.

This is the CPU’s central pattern:

Complex behavior does not have to exist in the individual instruction. It can emerge from simple instructions arranged in sequence, repetition, and conditional paths.

12. Building the Hack CPU from familiar parts

Nand to Tetris reconstructs this transformation in a deliberately simple architecture.

By the time the Hack CPU is built, its major parts already exist:

  • logic gates;
  • multiplexers;
  • the ALU;
  • registers;
  • memory;
  • and the program counter.

The architecture project combines the ALU and register chips from the earlier projects into the CPU, then connects that CPU with instruction memory and data memory to produce a general-purpose computer capable of running Hack machine-language programs.

The Hack CPU receives:

A sixteen-bit instruction
A value read from data memory
The current clocked state of its registers

It produces:

An ALU output
An address for data memory
A signal saying whether memory should be written
The address of the next instruction

Inside, the instruction controls familiar mechanisms.

One instruction type loads a value into the A register.

Another selects an ALU computation, chooses whether the result should enter the A register, D register, or memory, and specifies whether the program counter should jump.

The exact encoding matters when programming the machine, but the architectural lesson is larger:

Instruction bits

Controlled routing and transformation

New register, memory, and program-counter state

Nothing was added that resembles understanding.

The complete machine emerged from components whose promises had already been established.

13. The conductor who cannot hear the music

The previous essay ended by saying that the machine needed a conductor.

The metaphor is useful, but it can also mislead.

A human conductor knows that the orchestra is playing a symphony. They anticipate transitions, interpret phrases, balance sections, and relate the present sound to the larger work.

The CPU does none of that.

It does not see the whole program.

It does not know why instruction thirteen follows instruction twelve.

It does not recognize that a backward jump forms a loop.

It does not know that the loop is finding a factor, drawing a line, sorting names, or waiting for a key press.

The CPU is better described as a mechanism that repeatedly turns one encoded instruction into coordinated motion.

The intelligence of the plan belongs to the arrangement of instructions.

The reliability of following each step belongs to the processor.

This division is what allows the same CPU to run many programs.

The hardware does not have to understand weather prediction, music synthesis, or word processing. It needs only to execute the small operations from which those activities can be composed.

A different pattern in instruction memory gives the same physical machine a different unfolding behavior.

The machine’s purpose is no longer frozen entirely into its wiring.

Part of its purpose has moved into memory.

14. When the stored program became a service

The Manchester Baby proved that a digital electronic machine could execute a program stored in its electronic memory. But it was built primarily as an experimental machine to test the Williams–Kilburn storage system.

At the University of Cambridge, Maurice Wilkes led the construction of EDSAC—the Electronic Delay Storage Automatic Calculator—with a more practical ambition: to provide researchers with a usable computing service.

On May 6, 1949, EDSAC ran its first logged program. It printed a table of squares from zero through ninety-nine in two minutes and thirty-five seconds. A corrected primes program ran successfully a few days later. Cambridge’s own historical records describe EDSAC as the first machine to provide a regular computing service.

The historical transformation was subtle but important:

A machine built to prove that stored instructions could work

A machine regularly used by other people to solve problems

A stored-program computer was no longer only an experiment in memory and control.

It was becoming shared intellectual infrastructure.

Researchers did not need to rebuild EDSAC’s arithmetic circuits for each new calculation. They supplied a different sequence of instructions.

The same processor could become a different working tool because its plan was replaceable.

But replacing the plan was still painfully human work.

The machine expected numerical instruction codes and addresses. A misplaced bit could select the wrong operation. Adding or moving instructions could change the addresses used elsewhere. Programs had to be inspected in a notation designed for circuitry rather than memory, intention, or collaboration.

The stored-program computer had solved the problem of making a machine follow a plan.

It had not solved the problem of making that plan humane to write.

15. What a CPU really is

A CPU is often described as the brain of the computer.

The metaphor captures centrality but smuggles in too much.

A brain experiences, learns, interprets, and pursues needs. A CPU does none of those things merely by executing instructions.

A CPU is a clocked system for turning encoded patterns into state changes.

Its recurring promise is:

Give me the current instruction and current state.
I will produce the next state.

The instruction is fetched because the program counter supplies an address.

It is decoded because its bits are wired into control logic.

It is executed because those signals select pathways through the ALU and registers.

Its result persists because storage elements accept new values at the clock boundary.

The program continues because the program counter advances or jumps.

Then the promise is fulfilled again.

No gate understands the instruction.

No register understands the value it preserves.

No ALU understands the calculation it performs.

No CPU understands the program.

Yet one instruction can change a value.

A later instruction can inspect that change.

A jump can return to an earlier step.

A condition can eventually end the repetition.

Millions of narrow moments become one extended process.

The program was a row of numbers until the program counter pointed to one.

Then gates decoded its fields, multiplexers opened the required paths, the ALU transformed the selected values, and registers accepted the result when the clock permitted them to change.

The program counter moved.

Another silent pattern became an action.

Then another.

The computer could now obey a language made from numbers.

The next problem belonged to the humans.

How could anyone write in it?