The last instruction of the interrupt service routine must be: RETI, which is the interrupt return instruction, and is only used at the end of the interrupt service routine. After the interrupt program is completed, a RETI instruction must be executed. After executing this instruction, the CPU will take out the address saved in the stack and send it back to the PC. Then the program will continue execution from the interruption point of the main program.
The operating environment of this tutorial: Windows 7 system, Dell G3 computer.
The last instruction of the interrupt service routine must be: RETI.
RETI is the interrupt return instruction
The function of this instruction is similar to the RET instruction. The difference between the two instructions is: when this instruction clears the interrupt response, it is set to 1 The MCS-51 internal non-addressable "Priority Valid" flip-flop is cleared.
After the interrupt program is completed, a RETI instruction must be executed. After executing this instruction, the CPU will take out the address saved in the stack and send it back to the PC. Then the program will start from the interruption point of the main program. Continue to execute. The interrupt instruction "RETI" is an interrupt jump-out instruction. In addition to taking out the address saved in the stack and sending it back to the PC, so that the program can continue execution from the interruption point of the main program, it also has the function of "priority taking effect" trigger. Clear function.
For more knowledge about computer programming, please visit: Programming Video! !
The above is the detailed content of What is the last instruction in the interrupt service routine?. For more information, please follow other related articles on the PHP Chinese website!