This is an old revision of the document!


Instruction Execution Process

As we already mentioned, instructions are executed by the processor in a few steps. You can find in the literature descriptions that there are three, four, or five stages of instruction execution. Everything depends on the level of detail one considers. The three stages description says that there are fetch, decode and execute steps. The four-stage model says that there are fetch, decode, data read and execute steps. The five stages version adds another final step for writing the result back and sometimes reverses the steps of data read and execution.

It is worth remembering that even a simple fetch step can be divided into a set of smaller actions which must be performed by the processor. The real execution of instructions depends on the processor's architecture, implementation and complexity. Considering the five-stage model we can describe the general model of instruction execution:

  1. Fetching the instruction:
    • The processor addresses the instruction by sending the content of the IP register by the address bus.
    • The processor reads the code of the instruction from program memory by data bus.
    • The processor stores the code of the instruction in the instruction register.
    • The processor prepares the IP (possibly increments) to point to the next instruction in a stream.
  2. Instruction decoding:
  • A simple instruction can be interpreted directly by instruction decoder logic.
  • More complex instructions are processed in some steps by microcodes.
  • Results are provided to the execution unit.
  1. Instruction execution:
  • The execution unit performs actions as encoded in the instruction.
  • In modern processors there are more execution units, they can execute different instructions simultaneously.
  • Some instructions require reading the data so the data fetch step can be present here:
  1. Data reading:
  • The processor calculates the address of the data in the data memory.
  • The processor sends this address by address bus to the memory.
  • The processor reads the data from memory and stores it in the accumulator or general-purpose register.
  1. Writing back the result:
  • The processor writes the result of calculations into the register or memory.

As you can see from this description execution of a single instruction requires many activities which must be performed by the processor. We can notice that each stage, or even sub-stage can be done by a separate logic unit. This feature is used by designers of modern processors to create the pipeline. The pipeline is the set of logic units which execute many instructions at the same time - each of them at a different stage of execution. If the instructions are coming in an undisrupted stream the pipeline makes it possible to execute the program faster than a non-pipelined processor.

Instruction encoding constant size

en/multiasm/cs/chapter_3_8.1736180739.txt.gz · Last modified: 2025/01/06 16:25 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0