Section 05 Part 05 The JSR and RTS Instructions
I refuse to go bungee jumping, I came into this world because of a broken rubber, I'm not leaving because of one. ~Unknown Author
The JSR Instruction
JSR Jump to SubRoutine
The destination operand is moved into the PC, the return address is moved into the stack, the 68k will continue reading at the location of the destination operand.
This functions almost exactly the same as the JMP instruction. When the instruction is read, the address is moved into the PC, and that routine is ran next:
(See Section 05 Part 02 for details)
The difference here is that JSR does one extra thing that JMP does not. JSR stores the return location into the stack, so the 68k can return back to the JSR, and continue.
The RTS Instruction
RTS ReTurn from Subroutine
The return address is loaded out of the stack and put into the PC, the 68k will continue reading at the return address.
Heres an example of JSR and RTS being used together:
Heres a graphical diagram, first JSR/RTS: