Skip to content
BetterDL

Stored-program computer

Also called: stored program, stored-program concept, von Neumann architecture, von Neumann, von Neumann machine

A computer whose instructions are binary words kept in memory alongside its data, so changing the program means changing memory, not wiring.

In a stored-program computer, the program is just data: a list of binary words in memory. The CPU fetches those words one at a time and carries them out. To run a different program, you write different words into memory. Nothing gets rewired.

That sounds obvious today, but early machines were programmed by plugging cables and setting switches. Storing the program in memory made computers general-purpose.

Two consequences surprise people:

  • A word has no label. Nothing in 23 says "instruction" or "data". It's an instruction if the program counter points at it and the CPU fetches it. It's data if an instruction reads it.
  • Programs can change themselves. Since instructions are in ordinary memory, a STORE can overwrite one. That's self modifying code.

This design is often called the von Neumann architecture, where one memory holds both program and data and is reached through one path. The alternative, with separate instruction and data memories, is the harvard architecture. The course's teaching CPU, Tiny8, is a stored-program machine with 16 words of shared memory.

Worked example

Example

One word, two meanings

In Tiny8, address 5 holds the word 23. What does it mean?

  1. 1.

    If the PC reaches address 5, the CPU fetches 23 as an instruction: opcode 2 = STORE, address 3. It's STORE 3.

  2. 2.

    If an instruction LOAD 5 runs, it reads the same word as data: 23₁₆ = 2 × 16 + 3 = 35.

  3. 3.

    The bits are identical. Only how the CPU reaches the word decides what it is.

Common mistakes

  • Thinking memory marks some words as code and others as data. Tiny8 memory is just 16 words; the PC decides what runs.

  • Thinking a new program needs new hardware. It only needs new words in memory.

Practice Stored-program computer

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Stored-program computer is taught in Basic CPU / Computer Architecture.