6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 2:43 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Aug 11, 2015 3:45 pm 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
We know that the RTI instruction has a fixed instruction time (6 cycles). But what I have never seen is exactly at what point are interrupts actually allowed during the course of that instruction. Is it at instruction clock 1,2,3,4,5, or only after the conclusion of cycle 6?

Anyone know?


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 11, 2015 4:44 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8491
Location: Midwestern USA
JimDrew wrote:
We know that the RTI instruction has a fixed instruction time (6 cycles). But what I have never seen is exactly at what point are interrupts actually allowed during the course of that instruction. Is it at instruction clock 1,2,3,4,5, or only after the conclusion of cycle 6?

Anyone know?

I can't speak for the exact timing of the 65C02, but I can tell you that the 65C816 pulls the status register at cycle 4, which would enable interrupts if the I bit in the stack copy of SR is clear. However, you should note that the MPU doesn't actually acknowledge an IRQ until the completion of the current instruction. Hence the exact point at which interrupts are enabled in the RTI instruction sequence isn't particularly important.

Incidentally, in 65C816 native mode, RTI requires seven clock cycles.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 11, 2015 9:08 pm 
Offline

Joined: Sun Oct 14, 2012 7:30 pm
Posts: 107
Thanks. I was thinking as well as the 6502 would not check the flags until after the RTI instruction has finished.


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 11, 2015 10:11 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
You can run experiments fairly readily with visual6502 by using specific URLs to set up your test code and fire an interrupt at a specific time. See for example
viewtopic.php?p=23519#p23519
and see the URL section in the help page of the simulator.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 12, 2015 2:44 pm 
Offline

Joined: Wed Oct 06, 2010 9:05 am
Posts: 95
Location: Palma, Spain
When I was looking into getting the 6502 emulation right for jsbeeb, I think my conclusion was that RTI pulls the flags off the stack before the moment that pending IRQs are checked. So it should be possible for an interrupt to be serviced immedately after the RTI and prior to the instruction it returns to. This is also stated here:
Visual 6502 wiki wrote:
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.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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: