Instruction Cycle
The instruction cycle is the sum of the time that the CPU takes out an instruction from memory and executes the instruction, typically consisting of several machine cycles, from the fetch instruction to the analysis command to the time required to complete the execution. Machine Cycle
The machine cycle is also called the CPU cycle, because the CPU spends a long time accessing the memory, so it is defined with the shortest time to read an instruction word from memory. In the computer, in order to facilitate management, the implementation of an instruction is often divided into several stages, each phase of the completion of a work. For example, take instruction, memory read, memory write, etc., each work is called a basic operation. The time required to complete a basic operation is called the machine cycle. Clock Cycle
The clock cycle, also known as the oscillation period, is defined as the reciprocal of the clock pulse (it can be understood that the clock cycle is the reciprocal of the external Crystal of the microcontroller), which is the most basic and minimum unit of time in a computer. A machine cycle consists of several clock cycles. In a clock cycle, the CPU only completes one of the most basic actions. For some kind of MCU, if the clock frequency of 1MHZ is used, the clock period is 1us, and if the clock frequency is 4MHZ, the clock period is 250us.
n Clock cycle = 1 machine cycle
N Machine cycle = 1 instruction Cycle
Different instructions, the number of machine cycles required is also different. For some simple single-byte instructions, only one machine cycle is required. For some more complex instructions, such as transfer instructions, multiplication instructions, two or more than two machine cycles are required.
From the execution speed of the instruction, single-byte and double-byte instructions are generally single-machine cycle and dual-machine cycle, the three-byte instruction is a two-machine cycle, only the multiplication, except the instruction occupies 4 machine cycles.
Therefore, when programming, in the case of the same work, the selection of the use of fewer machine cycle commands will increase the execution rate of the program, especially when writing large programs, the effect is more obvious.