FREE CONTRIBUTION CHRONOLOGY · 1945–1949

Instructions live in memory

What changes when instructions and data occupy addressable memory?

The historical question

Once instructions became encoded memory words, changing a program became a data-loading operation. Fast random-access memory and reusable subroutines turned the idea into an operating machine and a new software practice.

Stored control makes behavior revisable because the machine’s next transition is determined by addressable information rather than fixed wiring.

Fetch, decode, and update state

A minimal stored-instruction teaching machine has memory, a program counter PC, and registers. A fetch reads the word at PC; decoding interprets that word as an instruction; execution updates state and chooses the next PC. A default rule increments PC, while a branch replaces it with a target address. Instructions are encoded values, but their interpretation differs from ordinary data because the control unit decodes them.

Take a program that loads 3 into register R, adds 2, and stores R at address 20. After the load, R=3. After the addition, R=5. The store changes memory[20] to 5. If a later instruction loads that address as data, it sees 5. If execution jumps there, the same bits are interpreted according to the instruction encoding, potentially producing an error or unintended behavior.

This flexibility introduces obligations as well as convenience. Instruction and data separation, permissions, and cache coherence can complicate a modern machine even when the conceptual model is simple. Distinguish the stored-program principle, a particular architecture, and historical implementation milestones. A shared idea developed through reports, engineering work, and operating experience should not be assigned to a single report author without examining that context.

What the evidence does not establish

Do not say von Neumann alone invented stored-program computing. Credit collaborative and parallel work and separate publication from implementation.

Reconstruction exercise

Trace load 3, add 2, store 20. Then describe how executing address 20 differs from reading address 20 as data.

Worked solution

The register contains 3, then 5, and memory[20] becomes 5. A data read returns the encoded value 5. An instruction fetch decodes those bits according to the ISA; it does not automatically mean the arithmetic number 5 as an operation. Whether it is valid depends on the instruction encoding and memory permissions. This distinction explains both the flexibility and danger of treating instructions as memory contents.

Test the limits and transfer the idea

1. Machine execution · allow 30 minutes

Trace the control path through a wrapping counter

A toy machine has an eight-bit unsigned register R and memory cell M[10]. Instructions are: 0 LOAD M[10]; 1 SUB 1 modulo 256; 2 STORE M[10]; 3 JNZ 0 if R≠0, otherwise advance; 4 HALT. Start at PC=0 with M[10]=2. Trace executed addresses and final state. Repeat conceptually for M[10]=0 and count instructions through HALT. Explain how a pre-test would change the zero case.

Get a starting hint

This loop decrements before testing; zero wraps to 255 rather than remaining zero.

Compare your reasoning with the worked solution

For initial two, executed addresses are 0,1,2,3,0,1,2,3,4. The first pass stores 1 and branches; the second stores 0 and falls through. It halts with R=0 and M[10]=0 after nine instructions. Starting at zero, the first subtraction produces 255. After 256 passes the stored value returns to zero, so the machine executes 256×4+1=1025 instructions. A test before decrementing can halt immediately for zero, depending on its instruction encoding. Neither behavior is inherently a hardware defect: correctness depends on whether the intended loop is a pre-test or post-test loop and whether the input contract excludes zero. This invented ISA demonstrates stored control and is not an EDSAC instruction trace.

Check your reasoning

  • Traces PC, register and memory consistently.
  • Explains the 256-pass wraparound and 1025-instruction count.
  • Connects the boundary case to the algorithm and input contract.

2. Memory-safety trace · allow 25 minutes

Data writes can corrupt a later control decision

In an invented memory layout, a four-byte input buffer occupies addresses 20–23 and a saved return address occupies 24, initially containing 99. A copy routine writes input byte i to 20+i without checking length. Trace input [1,2,3,4,7] and the later RETURN that jumps to the saved address. Propose a precise bounds check and explain why marking instruction memory read-only alone does not stop this failure.

Get a starting hint

A control decision may depend on writable data even if the instruction bytes themselves never change.

Compare your reasoning with the worked solution

The five writes set M[20..24] to 1,2,3,4,7. The fifth byte replaces 99, so RETURN jumps to 7 instead of 99. To accept the whole input safely, validate length≤4 before copying and ensure index arithmetic cannot wrap; alternatively reject or explicitly truncate under a documented contract, rather than silently overrunning. Read-only instruction memory protects code bytes but does not protect the saved control address stored as data. Additional protections can separate or validate control state, but they must match the machine's actual threat model. The historical stored-program principle does not require unsafe buffers. This modern counterexample concerns a deliberately flawed memory contract, not a claim about an original Manchester or Cambridge exploit.

Check your reasoning

  • Shows the overwritten saved address and resulting jump.
  • Specifies the exact accepted length and arithmetic condition.
  • Distinguishes immutable code from control data integrity.

Check your understanding

What determines whether stored bits act as an instruction?

  • Their visual appearance alone
  • Their decimal printing format
  • The operation that fetches and interprets them
Explanation

The register contains 3, then 5, and memory[20] becomes 5. A data read returns the encoded value 5. An instruction fetch decodes those bits according to the ISA; it does not automatically mean the arithmetic number 5 as an operation. Whether it is valid depends on the instruction encoding and memory permissions. This distinction explains both the flexibility and danger of treating instructions as memory contents.

Sources and further reading