A-Level Computer Science / Unit 4: CPU Operation and Low-Level Processing

4.1.3 Fetch-Execute Cycle and Register Transfer Notation

πŸ”’ Lesson slides are available to signed-in users. Sign in

Fetch-Execute Cycle and Register Transfer Notation

A processor repeatedly fetches an instruction from memory, works out what it means, and carries out its operation. This repeating process is the fetch-execute (F-E) cycle. Register transfer notation (RTN) gives a compact way to describe values moving between registers and memory.

By the end of this page, you should be able to:

  • describe the fetch, decode and execute stages;
  • read RTN and explain what square brackets mean;
  • distinguish a register from its contents, and an address from the contents stored there;
  • trace how an instruction moves from memory into the processor.

1. The processor repeats three stages

The fetch-execute cycle is the repeated process the CPU uses to run a program. Each instruction passes through three main stages.

Stage What happens Key point
Fetch The processor gets the next instruction from main memory. The instruction is brought into the processor.
Decode The Control Unit interprets the instruction. The processor identifies the operation required.
Execute The processor carries out the operation. The action depends on the instruction.

After execution, the processor starts another cycle to process the next instruction. A program therefore runs through many fetch, decode and execute stages.

Fetch does not mean execute

During fetch, the processor obtains an instruction. It works out what the instruction means during decode, then carries out the operation during execute.

2. RTN describes transfers between registers

Register transfer notation (RTN) describes how values move between registers and how an operation uses those values. The left arrow ← means that the value on the right is placed into the register on the left.

RTN Meaning
MAR ← [PC] Copy the contents of PC into MAR.
MDR ← [[MAR]] Use the address in MAR to read memory, then place the memory contents in MDR.
CIR ← [MDR] Copy the contents of MDR into CIR.
Square brackets mean β€œcontents of”. The expression [PC] means the value currently held in PC. In [[MAR]], the inner brackets give the address held in MAR; the outer brackets mean the contents of memory at that address.

Do not confuse the register with the value

MAR is a register. If MAR contains 320, then 320 is its content. In this example, 320 is an address. The instruction stored at memory address 320 is a different value.

3. Fetch the instruction in a clear sequence

The Program Counter (PC) holds the address of the next instruction. The processor copies that address to MAR, reads the instruction from memory, and places it in CIR.

  1. MAR ← [PC]: copy the next instruction address from PC to MAR.
  2. PC ← [PC] + 1: advance PC to the next sequential address.
  3. MDR ← [[MAR]]: read the instruction at the address in MAR into MDR.
  4. CIR ← [MDR]: copy the fetched instruction into CIR.

PC changes after its current address has been copied to MAR. MAR keeps the address being read, while PC now identifies the following instruction address. The instruction itself moves from memory through MDR to CIR.

The sequence on this page increments PC after copying the address to MAR. If a question gives you a particular RTN sequence, follow that sequence and keep each transfer in its stated order.

Trace addresses and instructions separately. Ask β€œWhich address is being accessed?” before asking β€œWhat instruction is stored there?” This prevents the address from being mistaken for the instruction.

4. Decode the instruction, then execute it

Once the fetched instruction is in the Current Instruction Register (CIR), the Control Unit (CU) decodes it. The CU identifies the operation and the information needed to carry it out.

During execute, the processor performs the required operation. It may use the ALU, registers or memory, depending on the instruction. The F-E cycle then continues with the next instruction.

Example: if an instruction says to add a value from memory to the ACC, the CU identifies an addition operation. The processor obtains the value, and the ALU performs the addition. The exact transfers depend on the instruction being processed.

MDR and CIR have different roles

MDR temporarily holds information being transferred to or from memory. CIR holds the current instruction while it is decoded and executed. The CU decodes the instruction; the registers hold values.

Interactive: step through one fetch-execute cycle

Use Next step to follow a small program. The memory table shows an instruction at address 320, another instruction at 321, and a value at address 510. The ACC begins with 12.

FETCH β†’ DECODE β†’ EXECUTE

Ready

Start Β· 0 of 10

Memory

Each row shows an address and the contents stored there.

AddressContents
320Add value at address 510 to ACC
321Next instruction
5108

Processor state

PC320
MARβ€”
MDRβ€”
CIRβ€”
CUβ€”
ALUβ€”
ACC12

Register transfer notation

The PC starts at 320. The ACC starts at 12.

Select β€œNext step” to begin. Use Previous or Reset to review the sequence.

This is a simplified example to show register transfers. It does not show every internal processor operation.

5. Avoid these common mix-ups

Mix-upKeep the ideas separate
Address and instruction The address identifies a memory location; the instruction is stored at that location.
MAR and memory contents MAR holds an address; double brackets in [[MAR]] refer to the contents at that address.
MDR and CIR MDR temporarily holds transferred information; CIR holds the current instruction.
Decode and execute The CU interprets the instruction during decode; execute carries out its operation.
Register and contents A register is a storage location; its contents are the value held there now.

6. Check your understanding

Try each question before opening the suggested response.

  1. PC contains address 700. Write the RTN that copies its contents into MAR.
    Suggested response

    MAR ← [PC]

  2. After the address is copied, PC is increased by one. What does MAR contain, and what does PC contain?
    Suggested response

    MAR still contains 700; PC contains 701.

  3. MAR contains 700. Write the RTN to place the contents of that memory location into MDR.
    Suggested response

    MDR ← [[MAR]]. The double brackets mean the contents of memory at the address held in MAR.

  4. Which register holds the current instruction during decode, and which component decodes it?
    Suggested response

    The CIR holds the current instruction. The CU decodes it.

  5. Put the three F-E stages in order.
    Suggested response

    Fetch, decode, execute. The processor repeats the cycle for the next instruction.

Final check

When tracing RTN, read each line from right to left: identify the source value first, then state which register receives it. Keep the address, the memory contents and the instruction in CIR distinct.