We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

RTI: Difference between revisions

From SnesLab
Jump to: navigation, search
(made flags affected more prominent)
(how many bytes pulled)
Line 47: Line 47:
|}
|}


'''RTI''' (ReTurn from Interrupt) is a 65x instruction used to return control from an [[interrupt handler]].  It does this by first pulling the [[status flags]] off of the [[stack]] and then the [[program counter]] too.
'''RTI''' (ReTurn from Interrupt) is a 65x instruction used to return control from an [[interrupt handler]].  It does this by first pulling the [[status flags]] off of the [[stack]] and then the [[program counter]] too.  In native mode, 4 bytes are pulled.  In emulation mode, 3 bytes are pulled.


==== Syntax ====
==== Syntax ====
Line 79: Line 79:
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#RTI
* Pickens, John. http://www.6502.org/tutorials/6502opcodes.html#RTI
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.3.2
* Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#6.3.2
* lbid, APPENDIX: EMULATION MODE, http://www.6502.org/tutorials/65c816opcodes.html#APPENDIX:


[[Category:ASM]]
[[Category:ASM]]

Revision as of 23:03, 31 July 2024

Basic Info
Addressing Mode Opcode Length Speed
Stack (RTI) 40 1 byte 7 cycles*
Flags Affected
N V M X D I Z C
65c816 native mode N V M X D I Z C
6502 emulation mode N V . . D I Z C

RTI (ReTurn from Interrupt) is a 65x instruction used to return control from an interrupt handler. It does this by first pulling the status flags off of the stack and then the program counter too. In native mode, 4 bytes are pulled. In emulation mode, 3 bytes are pulled.

Syntax

RTI
Pitfalls
  • RTI should only be run when the e flag is in the same state as when the interrupt fired
  • RTI cannot even tell whether the interrupt actually occurred or not
  • RTI does not increment the program counter after pulling it like RTS and RTL do
Cycle Skipped

RTI takes one fewer cycle in emulation mode as the program bank register doesn't need to be pulled from the stack.

See Also

External Links