A stored program is a program that is stored in the computer's memory along with the data it operates on. Instead of being hardwired into the hardware (as in earlier computers), the instructions that make up the program are represented as binary code and stored in memory. The CPU then fetches these instructions from memory and executes them.
The stored program concept is fundamental to the Von Neumann architecture. The shared memory space allows the program instructions to be treated as data. The CPU's instruction fetch cycle involves fetching instructions from memory, which are then interpreted and executed. This eliminates the need for physical rewiring of the computer to change its behavior – a major advancement over earlier mechanical computers.
Example: Addition Program
Consider a simple program to add two numbers stored in memory. The program might be represented in assembly language as follows (simplified):
LOAD A, 10 ; Load the value 10 into register A
LOAD B, 5 ; Load the value 5 into register B
ADD A, B ; Add the value in register B to register A
STORE A, Result ; Store the result in memory location 'Result'
These instructions are stored in memory as binary code. When the program is executed, the CPU fetches each instruction from memory, decodes it, and performs the corresponding operation. The program's instructions are not fixed; they can be changed simply by modifying the binary code stored in memory.