From C64-Wiki
Jump to navigationJump to search

RTI (short for "ReTurn from Interrupt") is the mnemonic for a machine language instruction which returns the CPU from an interrupt service routine to the "mainline" program that was interrupted. It does this by pulling first the processor status flags (similar to PLP), and then the program counter, from the stack, effectively handling program execution back to the address pulled from the stack.

Besides the status flags, a programmer needs to save the accumulator and the X and Y index registers (and retrieve them just before ending at the RTI), in order to ensure the interrupt service routine not to interfere with what the "mainline" program is doing with these processor registers.

Addressing mode[edit | edit source]

Opcode Addressing
in bytes
Number of
Dec Hex
64 40 Implied RTI 1 6

RTI only supports the Implied addressing mode, as shown in the table at right.

CPU flags[edit | edit source]

Because of the retrieval of previously saved status flags, this instruction potentially affects all seven flags, even including the unused bit 5 (weight 32/$20) in the byte formed by the flags.