6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Nov 04, 2024 9:56 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: What happens when ...
PostPosted: Wed Apr 18, 2018 8:37 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
.. you return execute an RTI while /IRQ is still asserted low? Does the processor immediately perform an IRQ sequence or does an instruction get executed first?

I think we have discussed this before but I can't find it.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 18, 2018 10:24 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10975
Location: England
Just checked on visual6502 and the PC makes no progress: the same next-instruction is refetched and internally overridden with a BRK.
http://visual6502.org/JSSim/expert.html ... loglevel=2


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 18, 2018 8:52 pm 
Offline
User avatar

Joined: Thu Jun 23, 2011 2:12 am
Posts: 229
Location: Rancho Cucamonga, California
!IRQ is level-triggered, so if the interrupt handler doesn't take the source of the interrupt request away, an interrupt will occur again as soon as the Interrupt flag in the processor is set. In most cases that happens when RTI restores the flags from the stack but it can also happen when the interrupt handler executes CLI to allow nested interrupts. As long as !IRQ is asserted, no code outside the interrupt service routine is executed: the I flag gets set sometime during the RTI (or CLI) instruction so by the end of the last clock of the instruction that sets the I flag, the hardware is ready to handle the interrupt again, before starting execution of the next instruction. This makes it possible for multiple devices to generate an interrupt at the same time, and have all those devices (and BRK instructions) serviced by a single interrupt service routine.

By the way, !NMI is edge-triggered: when the level goes from high to low, a non-maskable interrupt is generated. No matter how long the !NMI input stays low, no new interrupt is generated until it goes from high to low again (nothing happens when it goes from low to high). This makes sense if you think about it: imagine if NMI would be level-triggered; that would mean that if the circuitry would hold the pin low for any amount of time, an interrupt would occur again immediately after the processor started handling the interrupt. That would keep happening until NMI would be deasserted, and the processor would be doing nothing except start the NMI handler over and over, and push return addresses and flags onto the stack if !NMI were level-triggered. However because it's edge-triggered, the interrupt happens only once and it's possible for hardware to prevent it from happening again by holding !NMI low.

===Jac


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: