Microcontroller Firmware Instruction will be executed after programmed into the MCU, and engineer should have the idea about the meaning of it:
MOV: This is an instruction that means conveying data. When it comes to delivery, we all know that it is necessary to transfer things from one person’s hand to another, that is, to have a recipient, a passer and an objective.
From the instructions MOV R7, #250 to analyze, R7 is a receiver, 250 is the number passed, the transmitter is omitted in this instruction (note: not every delivery instruction will be saved, in fact large Some data transfer instructions will have a passer). Its meaning is also obvious: the data 250 is sent to R7, so after executing this instruction, the value in the R7 unit should be 250. There is a # in front of 250. This # is used to indicate that 250 is a thing that is passed.
DJNZ: This is another instruction. Let’s take a look at the two things that follow this instruction. One is R6, the other is D2, and R6 has been introduced and be awared of it from previous discussion. Let’s check what D2 is. D2 is in front of the line, we have already learned, this is called the label. What is the purpose of the label? Just name the line of this instruction.
The execution process of the DJNZ instruction is such that it decrements the value in the first parameter after it, and then looks at whether the value is equal to 0. If it is equal to 0, it is executed downward. If it is not equal to 0, it will be transferred to the place specified by the second parameter. The final result of this directive is that it is rotated 250 times in place.
After executing DJNZ R6, D2 (that is, the value of R6 is equal to 0), it will execute the following line, which is DJNZ R7, D1. Please analyze the result of this sentence. (Go to execute MOV R6, #250, and the value in R7 is decremented by 1). Finally, DJNZ R6, D2 will be executed 250*250=62500 times. How many times do you execute the same instruction? Just for the delay.