The Fetch–Decode–Execute Cycle
Start here. Follow one ADD instruction from the program counter to the accumulator, one bus transfer at a time.
Skip to the animationA processor has exactly one behaviour: read the instruction at the address in the program counter, work out what it means, carry it out, and repeat — and every feature above it, from loops to operating systems, is built by arranging what that cycle finds next.
The registers the cycle needs
- PC — program counter
- Holds the address of the next instruction. This is the processor's entire notion of where it is; every jump, call, return and interrupt is ultimately a write to it.
- MAR — memory address register
- Drives the address bus. Separate from the PC so the PC can be advanced while a fetch is still in flight.
- MDR — memory data register
- Whatever came back from, or is going to, the data bus.
- IR — instruction register
- Holds the instruction for the duration of its execution, freeing the MDR for operands.
- Accumulator and general registers
- The working data. On the 8085 the accumulator is privileged: most arithmetic has it as an implicit operand and destination.
- Flags
- Zero, carry, sign, parity — set as a side effect of ALU operations, and read by conditional branches. This is the only channel by which a computation influences control flow.
Fetch: identical for every instruction
- 1
MAR ← PC— put the address of the next instruction onto the address bus. - 2
MDR ← M[MAR]— memory answers; the data bus carries the opcode back. - 3
PC ← PC + 1— advance, on the assumption that execution continues to the next address. - 4
IR ← MDR— move it into the instruction register, where it will stay until execution finishes.
Nothing in this sequence depends on which instruction is being fetched. That is exactly what allows fetch to be a fixed hardware sequence, and it is why a processor can execute data as though it were code — the fetch has no way to tell the difference.
The increment happening *during* fetch is the reason a jump instruction must overwrite the PC rather than skip. By the time a jump executes, the PC already points past it. This is also why a subroutine call saves the PC's post-increment value: that is precisely the return address.
Decode: combinational, and free
The instruction decoder maps the opcode bits onto control lines: which register drives the internal bus, which ALU function is selected, whether a memory access is a read or a write. It is a combinational block, so on a simple processor it costs no separate memory cycle.
Decoding also determines the addressing mode — whether the operand is in the instruction itself, in a register, at an address named by the instruction, or at an address held in a register. The mode is what makes the same ADD opcode reach different data.
Execute: the only step that varies
This is where instructions finally differ. An ALU operation presents its operands and writes back a result plus flags; a load or store causes another memory cycle; a jump writes the PC; a call pushes the PC to the stack first.
| Instruction | What execute actually does |
|---|---|
| ADD B | A ← A + B, and update the flags |
| MOV A, B | A ← B; no ALU, no flags |
| LDA 3000 | MAR ← 3000, then A ← M[MAR] — an extra memory cycle |
| JMP 2050 | PC ← 2050; the fetch's increment is simply discarded |
| CALL 2050 | push PC to the stack, then PC ← 2050 |
| HLT | stop the clock — the only way the cycle ever ends |
Machine cycles and T-states
One instruction takes one or more machine cycles, each of which is a single bus transaction (opcode fetch, memory read, memory write, I/O). Each machine cycle takes several clock periods, called T-states.
So an 8085 MOV A, B is one machine cycle of four T-states, while LDA 3000 is four machine cycles — opcode fetch, two operand-address reads, and a memory read — taking thirteen. Instruction timing in this subject is exactly this bookkeeping, and it is why counting T-states is how a delay loop is calibrated.
What the cycle does not do
- It cannot idle. There is no state in which a processor is running but doing nothing.
HLTstops the clock, and a waiting operating system is executing an idle loop. - It cannot decide to stop. Nothing in the hardware evaluates whether to continue. The cycle is unconditional.
- It cannot tell code from data. A fetch reads bytes; whether those bytes were meant as instructions is a convention the programmer maintains, and the reason a stray jump produces nonsense rather than an error.
- It has no notion of a program. Programs, processes and functions are patterns imposed on memory by software; the hardware only ever knows the current PC.
An interrupt is the one thing that alters the cycle from outside, and even that is implemented as a forced write to the PC between two instructions — never in the middle of one.
The numbers you will be asked for
- Fetch, as register transfers
MAR ← PC ; MDR ← M[MAR] ; PC ← PC + 1 ; IR ← MDR
Identical for every instruction in the set.
- Instruction time
T_instruction = Σ (T-states per machine cycle) × T_clock
How a software delay loop is calibrated.
- Address space
locations = 2^(address bus width)
16 address lines give 64 KB — the 8085's entire memory map.
Advantages and disadvantages
Advantages
- One fixed sequence executes every instruction, so the control hardware stays small.
- Fetch being instruction-independent is what makes an instruction set extensible.
- Register transfers are observable, so timing is exactly predictable — which real-time work depends on.
- The same cycle scales unchanged from an 8-bit microcontroller to a desktop processor.
Disadvantages
- Memory is far slower than the processor, so the cycle spends most of its time waiting — the reason caches exist.
- Executing strictly one instruction at a time wastes most of the hardware at any moment, which is what pipelining addresses.
- The cycle cannot distinguish code from data, so a corrupted pointer executes whatever it lands on.
- Every extra memory access in an instruction costs a full machine cycle, which is why addressing modes have such different timings.
Watch it work
Check yourself
question 1 / 5
One question at a time. Pick an answer to see why it is right or wrong, then move on — there is no score to keep and nothing is saved.