Home | Projects | Notes > Computer Architecture & Organization > The Stored Program Concept
Program execution cycle expressed in pseudocode
xxxxxxxxxx111/* Stored program machine */2
3 Point to the first instruction in memory4
5 REPEAT6 Read the instruction at the memory location pointed at7 Point to the next instruction8 Decode the instruction read from memory9 Execute the instruction10 FOREVER11EndExecute the instruction step in detail (in pseudocode)
xxxxxxxxxx101/* Execute the instruction */2
3 IF the instruction requires data4 THEN fetch the data from memory5 END_IF6 Perform the operation defined by the instruction7 IF the instruction requires data to be stored in memory8 THEN store the data in memory9 END_IF10EndProgram execution cycle expressed in C
xxxxxxxxxx111ProgramCounter = 0; // point to the 1st instruction2
3do4{5 instruction = memory[ProgramCounter]; // read the instruction6 updatepc(ProgramCounter); // pc point to next instruction7 decode(instruction); // decode the instruction8 fetch(operands); // fetch required data9 execute; // execute the instruction10 store(results); // store the result11} while (instruction != terminate);Stored program machines require two memory access per instruction.
One to read the instruction from memory.
The other to either read data from memory that is required by the current instruction or to put data in memory that previously has been created or modified in the CPU by an earlier instruction.
The term von Neumann bottleneck indicates that one of the problems of the stored program computer is the path between the CPU and the memory.
Harvard Architecture solves this issue by using separate storages and buses for data and instructions.
Store program machines are said to operate in a two-phase mode called a fetch/execute cycle.
Format
xxxxxxxxxx21Operation Address1, Address2, Address32(Operation Destination, Source1, Source2)
Operationspecifies the action the instruction is to carry out (e.g., add, subtrace, multiply, etc.) andAddress1,Address2,Address3are the locations of the three operands in memory.There is a standard for the way in which the sequence of operands is written. Different computers may use the different notation.
Equivalent RTL Notation
xxxxxxxxxx21[Address1] ← [Address2] Operation [Address3]2([Destination] ← [Source1] Operation [Source2])Example
xxxxxxxxxx21ADD P, Q, R2[P] ← [Q] + [R] // in RTL notation
ADD P, Q, Ris the symbolic form of the actual instruction that would be stored in memory as a binary sequence of 1s and 0s, meaning "add the contents ofQto the contents ofRand put the result inP".
P,Q, andRare the symbolic names of the addresses of three memory locations.This operation requires four memory accesses (e.g., one to fetch the instruction, two to fetch the two source operands, and one to store the result).
Here
ADDis called an op-code (abbreviated from operation code ). An op-code is the portion of a machine language instruction that specifies the operation to be performed.
Format
xxxxxxxxxx21Operation Address1, Address22(Operation Destination, Source1)
Address2is a source operand andAddress1is both a source and a destination operand.The source operand
Address1is replaced (overwritten) by the result.Practical computers do not generally allow you to use two memory addresses in the same instruction. Most computers specify one address in memory and a second address as a register.
Equivalent RTL Notation
xxxxxxxxxx21[Address1] ← [Address1] Operation [Address2]2([Destination] ← [Destination] Operation [Source])Example
xxxxxxxxxx21ADD P, Q2[P] ← [P] + [Q] // in RTL notation
Format
xxxxxxxxxx11Operation addressExample
xxxxxxxxxx31LOAD Q (Read Q into the accumulator)2ADD R (Add R to the accumulator)3STORE P (Store the accumulator in P)Above instructions simply mean
P = Q + R.Because only one address is provided and at least two addresses are required, the processor has to use an operand that doesn't require an explicit address (
Qin this example). That is, this operand comes from a register once called the accumulator within the CPU.In some cases, accumulator acts as a bottleneck, because all of the data has to flow through it.
Addressing modes are an aspect of the instruction set architecture in most CPU designs.
The various addressing modes that are defined in a given instruction set architecture define how the machine language instructions in that architecture identify the operand(s) of each instruction.
An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction or elsewhere.
Examples
Location of an operand given directly (i.e., it's in location 1000).
Location of an operand given indirectly (i.e., register 6 contains the address of the operand we need).
Computers can be classified by the way in which their instructions act on data.
Memory-to-memory
Instructions can read source operands from memory, perform an operation on the data, and store (return) the result in memory.
These types of computers (CPUs) do not even require the use of registers to execute instructions.
Register-to-register
Computers that perform operations only on the contents of registers.
Also called, load/store computers since LOAD and STORE operations are the only memory access instructions provided.
LOAD instruction must be used to put the data in registers.
STORE instruction must be used to transfer data from a register to memory.
Falls into the class of RISC
e.g., ARM, MIPS
Register-to-memory
Computers that can perform operations on two operands where one is in memory and the other in a register (the result is written to either memory or a register).
Falls into the class of CISC
e.g., Intel IA32 (8086, Pentium, Core i7)