6502 Timing of Interrupt Handling

From VisualChips

(Difference between revisions)
Jump to: navigation, search
m (moved 6502 Taken Branch Delays Interrupts to 6502 Timing of Interrupt Handling: instructions affecting status register also worth discussing)
(first cut at some content. Needs a lot of work.)
Line 1: Line 1:
-
no description here yet
+
This page contains some as-yet unpolished extracts from postings by user Hydrophilic on commodore128.org, material used by permission.
-
== resources ==
+
This page contains work in progress and unanswered questions, which should be answered by reference to visual6502 simulation URLs.
 +
 
 +
=== Interrupt handling sequence ===
 +
 
 +
The 6502 performs an interrupt as a 7-cycle instruction sequence which starts with an instruction fetch. (Is this true when the interrupted instruction is a branch?)  The fetched instruction is substituted by a BRK in the IR.
 +
 
 +
=== Interrupts colliding ===
 +
 
 +
* this needs to be studied and verified. Observations by Hydrophilic follow
 +
 
 +
[http://visual6502.org/JSSim/expert.html?graphics=f&loglevel=1&logmore=Execute,nmi,~NMIP,irq,480,629,INTG&steps=88&a=0011&d=58&a=fffe&d=2000&a=0020&d=e840&r=0010&nmi0=26&nmi1=31&irq0=12&irq1=74&a=0014&d=78 This simulation] shows a lost NMI. NMI is brought low when doing an IRQ acknowledge.  Specifically, 1/2 cycle before fetching the IRQ vector (cycle 13 phase 2).  NMI remains low for 2.5 cycles.  NMI returns high on cycle 16 phase 1. 
 +
 
 +
The NMI is never serviced.  This *might* be due #NMIP being automatically cleared after fetching PC high during any interrupt response...
 +
 
 +
=== Interrupts and changes to I mask bit ===
 +
 
 +
Instructions such as SEI and CLI affect the status register during the following instruction, due the the 6502 pipelining. Therefore the masking of the interrupt does not take place until the following instruction is already underway.  However, RTI restores the status register early, and so the restored I mask bit already is in effect for the next instruction.
 +
 
 +
=== Interrupts during branches ===
 +
 
 +
=== Resources ===
* back to parent page [[6502Observations]]
* back to parent page [[6502Observations]]
* [http://forum.6502.org/viewtopic.php?t=1634 A taken branch delays interrupt handling by one instruction] forum thread on 6502.org
* [http://forum.6502.org/viewtopic.php?t=1634 A taken branch delays interrupt handling by one instruction] forum thread on 6502.org
* [http://www.atariage.com/forums/topic/168550-a-taken-branch-before-nmi-delays-nmi-execution-by-one-full-instruction/ A Taken branch before NMI delays NMI execution by one full instruction] forum thread on AtariAge
* [http://www.atariage.com/forums/topic/168550-a-taken-branch-before-nmi-delays-nmi-execution-by-one-full-instruction/ A Taken branch before NMI delays NMI execution by one full instruction] forum thread on AtariAge
 +
* [http://www.commodore128.org/index.php?topic=3863 CLI - My 8502 is defective ???] forum thread on commodore128.org
 +
* [http://forum.6502.org/viewtopic.php?t=1817 Effects of SEI and CLI delayed by one opcode?] forum thread on 6502.org

Revision as of 09:01, 16 May 2011

This page contains some as-yet unpolished extracts from postings by user Hydrophilic on commodore128.org, material used by permission.

This page contains work in progress and unanswered questions, which should be answered by reference to visual6502 simulation URLs.

Contents

Interrupt handling sequence

The 6502 performs an interrupt as a 7-cycle instruction sequence which starts with an instruction fetch. (Is this true when the interrupted instruction is a branch?) The fetched instruction is substituted by a BRK in the IR.

Interrupts colliding

  • this needs to be studied and verified. Observations by Hydrophilic follow

This simulation shows a lost NMI. NMI is brought low when doing an IRQ acknowledge. Specifically, 1/2 cycle before fetching the IRQ vector (cycle 13 phase 2). NMI remains low for 2.5 cycles. NMI returns high on cycle 16 phase 1.

The NMI is never serviced. This *might* be due #NMIP being automatically cleared after fetching PC high during any interrupt response...

Interrupts and changes to I mask bit

Instructions such as SEI and CLI affect the status register during the following instruction, due the the 6502 pipelining. Therefore the masking of the interrupt does not take place until the following instruction is already underway. However, RTI restores the status register early, and so the restored I mask bit already is in effect for the next instruction.

Interrupts during branches

Resources

Personal tools