This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:cs:chapter_3_8 [2026/01/10 10:51] – pczekalski | en:multiasm:cs:chapter_3_8 [2026/04/01 14:00] (current) – [Instruction Execution Process] ktokarz | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Instruction Execution Process ====== | ===== Instruction Execution Process ====== | ||
| - | As we already mentioned, instructions are executed by the processor in a few steps. The literature describes three, four, or five stages of instruction execution. | + | As we already mentioned, instructions are executed by the processor in a few steps. The literature describes three((https:// |
| - | <todo @ktokarz> | + | |
| - | Everything depends on the level of detail one considers. The three-stage 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-stage version adds another final step to write the result back, and sometimes reverses the order 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' | 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' | ||
| Line 23: | Line 21: | ||
| - Writing back the result: | - Writing back the result: | ||
| * The processor writes the result of calculations into the register or memory. | * The processor writes the result of calculations into the register or memory. | ||
| + | |||
| + | The 5-stage instruction execution is illustrated in figure {{ref> | ||
| + | <figure instr5stage> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| ===== Instruction encoding ===== | ===== Instruction encoding ===== | ||
| From the processor' | From the processor' | ||
| - | A fixed number of bits makes the construction of the instruction decoder simpler because the choice of some specific behaviour or function of the execution unit is encoded with the bits, which are always at the same position in the instruction. On the opposite side, if the designer plans to expand the instruction set with new instructions in the future, there must be some spare bits in the instruction word reserved for future use. It makes the program' | + | A fixed number of bits makes the construction of the instruction decoder simpler because the choice of some specific behaviour or function of the execution unit is encoded with the bits, which are always at the same position in the instruction. On the opposite side, if the designer plans to expand the instruction set with new instructions in the future, there must be some spare bits in the instruction word reserved for future use. It makes the program' |
| A variable number of bits makes the instruction decoder more complex. Based on the content of the first part of the instruction (usually a byte), it must be able to decide what is the length of the whole instruction. In such an approach, instructions can be as short as one byte or much longer. An example of a processor with variable instruction length is the 8086, and all subsequent processors in the x86 and x64 families. Here, the instructions, | A variable number of bits makes the instruction decoder more complex. Based on the content of the first part of the instruction (usually a byte), it must be able to decide what is the length of the whole instruction. In such an approach, instructions can be as short as one byte or much longer. An example of a processor with variable instruction length is the 8086, and all subsequent processors in the x86 and x64 families. Here, the instructions, | ||