JSR (short for "Jump to SubRoutine") is the mnemonic for a machine language instruction which calls a subroutine; for those familiar with BASIC programming, this is the machine language "equivalent" to GOSUB. It does this by first incrementing the program counter by two, pushing the result onto the stack, high-byte first (for retrieval when the subroutine is done and needs to hand back control to the calling part of the program), and then transfers program execution to the specified address, similar to JMP.
When the subroutine ends in an RTS, this instruction pulls the address from the stack, further increasing it to a total of 3 bytes from the address of the initial JSR instruction, reaching the address of the instruction immediately after the JSR.
Addressing mode[edit | edit source]
CPU flags[edit | edit source]
JSR does not affect any of the CPU's status flags.