Difference between return from interrupt(RTI) and return from subroutine(RTS)

Amit Singh Tomar picture Amit Singh Tomar · Mar 11, 2011 · Viewed 18.6k times · Source

I would like to know what is difference between return from interrupt(RTI) and return from subroutine(RTS). Are both are the same or there is any difference between these two?

Answer

old_timer picture old_timer · Mar 11, 2011

Usually return from interrupt restores the flags so that the interrupted code can continue to execute properly. Return from subroutine does not need to do that instruction is used intentionally in that flow of code and known that the flags are or are not destroyed depending on the architecture. In architectures that use a stack for the return address it is very apparent. A return from interrupt will pop the flags then the return address where a return from subroutine will pop only the return address.