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
23says "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.