Flow-control structures: Difference between revisions
m
→{{header|6502 Assembly}}
Puppydrum64 (talk | contribs) m (→{{header|Z80 Assembly}}: added HALT) |
Puppydrum64 (talk | contribs) |
||
Line 111:
A return from subroutine instruction pops the return address off the stack, adds one, and jumps to that location:
<lang 6502asm> RTS ;ReTurn from Subroutine</lang>
===NMI===
This isn't a CPU instruction, it stands for Non-Maskable Interrupt. A non-maskable interrupt will push the program counter and the flags (in that order) then execute <code>JMP ($FFFA)</code>, thereby reading the address stored there and jumping to that address. This interrupt cannot be disabled with <code>SEI</code>. The code at that address will need to end in <code>RTI</code> to properly return from the interrupt.
===BRK===
Similar to NMI, except the CPU executes execute <code>JMP ($FFFE)</code> instead. This is intended for debugging but is not of much practical use. Returning from this interrupt will skip the instruction after the <code>BRK</code>.
===IRQ===
This is a generic interrupt that jumps to the handler stored in memory location <code>$FFFE</code>, but unlike <code>BRK</code> it doesn't skip anything when it returns. This can be disabled with <code>SEI</code>, and often can be configured at runtime to occur upon specific events, unlike NMI which usually is triggered by the same event. Use <code>RTI</code> to return from this interrupt.
=={{header|68000 Assembly}}==
|