Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Cycles to get into IRQ routine
2015-05-20 04:17
Hypnosis

Registered: Mar 2015
Posts: 30
Cycles to get into IRQ routine

How many cycles does it take from an IRQ trigger to the start of the IRQ routine, assuming the CPU finished the instruction when it triggers? It should be around 6-9 cycles but I'm not sure how many.
2015-05-20 04:34
Mixer

Registered: Apr 2008
Posts: 418
http://codebase64.org/doku.php?id=base:making_stable_raster_rou..

Read that. See background section. It'll explain what is going on.
2015-05-20 04:37
Hypnosis

Registered: Mar 2015
Posts: 30
Thanks a lot!
2015-05-20 07:12
MagerValp

Registered: Dec 2001
Posts: 1055
See the section "Interrupts" here: http://vice-emu.sourceforge.net/plain/64doc.txt

Note that IRQs are checked *before* the last cycle of an instruction executes, and not between instructions as you might expect.
2015-05-20 09:00
Hypnosis

Registered: Mar 2015
Posts: 30
Ooh, that was really handy, showing the memory accesses per cycle and instruction in nice tables!
2015-05-22 08:06
JackAsser

Registered: Jun 2002
Posts: 1987
Things get a bit more tricky men using NMI together with IRQ. If an NMI triggers while the IRQ is being setup, the NMI will get stalled the addional cycles it takes for the CPU to complete the IRQ-setup.
2015-05-22 12:22
MagerValp

Registered: Dec 2001
Posts: 1055
You're not talking about an NMI "stealing" an IRQ in progress are you? Please explain what you mean by "setup" and "stalled".
2015-05-22 16:18
Hypnosis

Registered: Mar 2015
Posts: 30
I would assume setup would mean push PC and status on stack and stalled would mean waiting for additional cycles to push on the stack, perhaps another 7 cycles?
2015-05-22 18:08
Flavioweb

Registered: Nov 2011
Posts: 442
Quoting Hypnosis
I would assume setup would mean push PC and status on stack and stalled would mean waiting for additional cycles to push on the stack, perhaps another 7 cycles?

This seems to be a "borderline case", where we can have an "Interrupt hijacking".

The MOS 6502 and by extension the 2A03/2A07 has a quirk that can cause one type of interrupt to partially hijack another type if they occur very close to one another.

For example, if NMI is asserted during the first four ticks of a BRK instruction, the BRK instruction will execute normally at first (PC increments will occur and the status word will be pushed with the B flag set), but execution will branch to the NMI vector instead of the IRQ/BRK vector:

Each [] is a CPU tick. [...] is whatever tick precedes the BRK opcode fetch.

Asserting NMI during the interval marked with * causes a branch to the NMI routine instead of the IRQ/BRK routine:

     ********************
[...][BRK][BRK][BRK][BRK][BRK][BRK][BRK]


http://wiki.nesdev.com/w/index.php/CPU_interrupts
2015-05-23 09:58
MagerValp

Registered: Dec 2001
Posts: 1055
Yes, this is the NMI stealing or hijacking a BRK or IRQ, however you want to call it. There are no stalls here though, it's the same 7 cycles as always, just jumping to the NMI vector at the end.
2015-05-23 15:12
JackAsser

Registered: Jun 2002
Posts: 1987
Quote: Yes, this is the NMI stealing or hijacking a BRK or IRQ, however you want to call it. There are no stalls here though, it's the same 7 cycles as always, just jumping to the NMI vector at the end.

Well. I had to conpensate for an additional 3c jitter i clearly remember.
 
... 53 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Didi/Laxity
icon/The Silents, Sp..
Seppo Heavy
hedning/G★P
algorithm
t0m3000/ibex-crew
Laurikka
WVL/Xenon
Airwolf/F4CG
jmin
Derision/Longshot
Guests online: 350
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 MWS  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.04 sec.