From C64-Wiki
Jump to navigationJump to search

RTS (short for "ReTurn from Subroutine") is the mnemonic for a machine language instruction which returns the CPU from a subroutine to the part of the program which initially called the subroutine; for those familiar with BASIC programming, this is the machine language "equivalent" to RETURN. It does this by first pulling the "return address" from the stack – this address has already been incremented by two bytes by the JSR instruction used to call the subroutine, and now RTS increments it with yet another byte, making a total of three bytes (the length of the JSR instruction), and stores the result in the program counter. This ensures that upon returning from the subroutine, the CPU executes the instruction following the aforementioned JSR instruction.

Addressing mode[edit | edit source]

Opcode Addressing
in bytes
Number of
Dec Hex
96 60 Implied RTS 1 6

RTS only supports the implied addressing mode, as shown in the table at right.

CPU flags[edit | edit source]

RTS does not affect any of the CPU's status flags.