At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
1. Fetch the instruction. Each CPU has a register which contains the current address of execution. This register is usually called the PC for Program Counter. This address is given to the memory with the fetch command to get the instruction to be executed.
2. Decode the instruction. Each instruction contains an operation code, which says what type of instruction it is. This operation code also determines what operands are needed. For instance, an add instruction needs some operands to sum, while a halt instruction needs no operands.
3. Increment the PC. Once the type of the instruction is known, the length of the instruction can be calculated. This length is then added to the Program Counter so that at the beginning of the next instruction, the current memory location will be fetched.
4. Fetch the operands. Operands of an instruction may be in memory or CPU registers. If they are in memory, the memory needs to fetch them at this time, since all work like arithmetic occurs in the CPU. This step is not needed for instructions with no memory operands.
5. Execute the instruction. Once the operands are present in the CPU, the computation may proceed. This is often an arithmetic operation, but could also be a comparison or many other things.