Worked example 1
An instruction ADD #5 is stored at memory location 102. The Program Counter (PC) currently holds 102 and the Accumulator (ACC) holds the value 12. Describe the steps of the Fetch-Decode-Execute cycle for this instruction, showing the state of the PC, MAR, MDR, CIR, and ACC.
Show solution outline
The instruction means 'add the immediate value 5 to the contents of the Accumulator'.
1. Fetch Phase:
- The contents of the PC (102) are copied to the MAR. MAR ← [PC]
- The address 102 is sent along the address bus to main memory. A 'read' signal is sent on the control bus.
- The instruction at location 102 (ADD #5) is copied from memory to the MDR via the data bus. MDR ← [Memory]
- The PC is incremented to point to the next instruction. PC ← [PC] + 1, so PC is now 103.
2. Decode Phase:
- The contents of the MDR (ADD #5) are copied to the CIR. CIR ← [MDR]
- The Control Unit decodes the instruction in the CIR. It identifies the operation (ADD) and the operand (the immediate value 5).
3. Execute Phase:
- The operand (5) is sent to the ALU.
- The contents of the ACC (12) are also sent to the ALU.
- The ALU performs the addition: 12 + 5.
- The result (17) is stored back into the Accumulator. ACC ← 17.
The cycle is now complete for this instruction and would begin again by fetching the instruction at address 103.