AQA 7517, section 4.7.2.1
The stored program concept is the idea that a computer's program is stored in main memory, as binary, in the same way as data. It underlies almost every modern computer.
The idea
- Machine code instructions are stored in main memory.
- The processor fetches them from memory and executes them one after another (serially).
- The processor performs arithmetic and logical operations as the instructions tell it to.
The processor starts at the first instruction, executes it, then moves on to the next, and so on, unless an instruction (such as a branch) tells it to jump somewhere else.
Because both the instructions and the data are just binary patterns in memory, the processor treats instructions as data when it fetches them, and only treats them as instructions when it decodes and executes them.
Before the stored program
The earliest computers had their programs set up by rewiring circuits or by setting switches, so changing the task could take days. Each machine was fixed to one job.
Consequences
- General-purpose machines. The same hardware can do any job. To change what the computer does, you just load a different program into memory.
- Programs can be loaded and replaced easily from storage, so you can install and run new software.
- Programs can be treated as data, so one program can create, change or translate another. A compiler is a program whose output is another program. An operating system loads programs into memory.
- Instructions are executed in sequence, controlled by the program counter, with jumps and branches giving selection and iteration.
- The von Neumann architecture (4.7.1.1) is built on this idea.
Instructions and data in memory
Since both are stored in binary, the same bits can be an instruction or a number. What decides it is how the processor uses it at the time. A program could accidentally treat data as instructions, which can cause crashes, and this is why memory is protected by the operating system.
Worked example
Task: explain why a games console can play many different games without changing any hardware.
The console's processor is general-purpose and follows the stored program concept. Each game is a program (machine code instructions and data) stored on a disc or in storage. To play a game, the console loads that program into main memory. The processor then fetches and executes its instructions. A different game is just a different set of binary in memory. The hardware stays the same.
Exam tip: include all the key parts of the description: instructions in main memory, fetched and executed serially by the processor, which performs arithmetic and logical operations. Mention that instructions and data are both stored in memory.
Check yourself
Describe the stored program concept
Machine code instructions are stored in main memory, and are fetched and executed one after another by a processor that performs arithmetic and logical operations.
Give one consequence of the stored program concept
Any one of: the computer is general-purpose and can run any program just by loading it into memory; programs can be loaded, replaced and updated easily; programs can be treated as data (so a compiler can produce another program).
What did early computers do instead of storing programs?
The programs were set up by rewiring circuits or setting switches, so changing the task was slow and difficult.