In: Computer Science
At the end of a service routine, suppose we have two RTI instructions one after another. Will something go wrong? Explain.
Yes, it will cause problem.
When a processor receives and interrupt, then it completes the execution of the current instruction (only the current). It then put the contents of the program counter in a stack and then attends the interrupt service routine/subroutine. At the end of the service routine, the return from interrupt (RTI) instruction resets all the flags and the interrupt function is terminated and the regular applications start the execution once again.
If there are two RTI instructions one after another, then the status registers will be restored twice from the stack. This method is generally performed using the pop () operation. So, the next content of the stack will be executed which can change the flow of execution of the current instruction. It can alter (reset) the status registers. In this way it can cause problems.
Please comment in case of any doubt.
Please upvote if this helps.