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: 36
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.
 
... 53 posts hidden. Click here to view all posts....
 
2015-05-23 20:30
MagerValp

Registered: Dec 2001
Posts: 1074
Interesting, I don't think my emulator core handles that case!
2015-05-23 21:33
Flavioweb

Registered: Nov 2011
Posts: 463
Quoting JackAsser
Didn't investigate it too deep. With plain NMI I had 7c jitter which I compensated for using indirect jumps into code places on the timer-addresses.

Seems that, to be totally sure to "compensate" all possible jitter ranges (without using illegal opcodes), we need to have a 10 cycles "compensation code".
- 2 cycles for minimum irq jitter;
- 1 cycle or 3 cycles if "branch taken" + next opcode cycles.
So, worst case: 3 + 7 cycles like
LOOP
    INC $FFFF,X
    DEX
    BNE LOOP

if irq is triggered on first cycle of BNE, then BNE + INC are executed before CPU starts irq sequence...
But this isn't related on have an irq that occur very close to one another, and should happen anyway.
2015-05-25 21:42
Copyfault

Registered: Dec 2001
Posts: 474
Without any unintended opcodes there's a 8c jitter - this was discussed "a decade ago" in Stable Raster via Timer.

It's interesting to see that 7c jitter still seems to be THE standard for max jitter; I hoped this had changed by the discussion once and for all.


However, mixing IRQ with NMI and having them overlapped as mentioned by Jackasser was not focused on back then. Are there really different states resulting in more than 8c jitter? Following the final explanation of the old discussion this could be the case if the first IRQ cycles are also "opcode fetch cycles" that block other interrupts.

Maybe it's a good idea to do a complete writeup of the irq jitter topic, e.g. a chart with all possible IRQ settings and the resulting jitter max values (just like Groepaz did for the unintended opcodes some time ago;))
2015-05-26 05:14
Oswald

Registered: Apr 2002
Posts: 5086
So how can the inc be executed if irq happens on first cycle of bne ?

according to copyfault "Note that IRQs are checked *before* the last cycle of an instruction executes, "
2015-05-26 07:40
HCL

Registered: Feb 2003
Posts: 727
I think 7 cycles jitter is enough in most cases, as it depends on what kind of op-codes you are using. Legal op-codes use max 7 cycles, only a few illegal ones use 8 cycles. So.. if you are not planning on using them outside your irq, you can of course have less jitter.
2015-05-26 19:23
Copyfault

Registered: Dec 2001
Posts: 474
From what I remember right now (it's a little while ago;)):

@Oswald: if the irq happens on the first cycle of a branch, it will be processed after the second cycle of the branch; but if an irq happens during the second cycle of a branch, processing is delayed until the end of the opcode following the branch instruction.

@HCL: 8c jitter is the uncomfortable reality even when sticking to the socalled legal opcodes outside the irq. This was the major conclusion of the thread I started those years ago. This comes from the oddity of the branch logic: if a branch is taken, the additional "branch taken"-cycle adds to the no. of cycles of the following opcode and it can not be interrupted. Thus, if there is an indexed RMW instruction that can be reached by a branch _and_ if the irq happens on the second cycle of the branch (which is going to be taken), the jitter will be 8 cycles.

So it does not depend on wether using illegals or not but rather on what opcode can be reached by a branch. Ok, I have to admit that this specific case is also not very probable ;))

I'll have a look if I can find the test code I did back then; maybe I should release it here for everyone to play around with it.
2015-05-26 19:34
chatGPZ

Registered: Dec 2001
Posts: 11350
dont forget to submit that kind of code snippets for use in the VICE testprog repo :)
2015-05-26 19:38
Flavioweb

Registered: Nov 2011
Posts: 463
Quoting Copyfault
if the irq happens on the first cycle of a branch, it will be processed after the second cycle of the branch; but if an irq happens during the second cycle of a branch, processing is delayed until the end of the opcode following the branch instruction.

So, with this code
LOOP
    INC $FFFF,X
    DEX
    BNE LOOP

if an irq happens durng second cycle of BNE, and branch is taken, 2(BNE)+7(INC)=9 cycles are executed before irq and, as a "borderline case of the corner cases", if BNE cross page boundary, 3+7=10 cycles are executed.
I'm wrong?
(Ok... i know we all need to avoid boundary cross... and probably no one use a INC $FFFF,X... but it's just to see if my thoughts are correct.)
2015-05-26 20:28
Oswald

Registered: Apr 2002
Posts: 5086
"if irq is triggered on first cycle of BNE, then BNE + INC are executed before CPU starts irq sequence..."

this still doesnt seem to make sence. last cycle of bne will check forr irq condition, if bne finished then cpu jmps to irq, or why not ?
2015-05-26 20:30
Copyfault

Registered: Dec 2001
Posts: 474
@Flavio: I remember there was a different behaviour when that branch was pagecrossing.

No pagecrossing, branch taken, irq on 2nd branch cycle (marked with <>):
next op.....cycles
BNE (taken) [R=1st branch cycle]<R=2nd branch cycle>[R=add.cycle]
INC abs,X   [R=1st INC cycle][2][3][4][5][6][7]
<irq processing starts here>


Same with pagecrossing:
next op.....cycles
BNE (taken) [R=1st branch cycle]<R=2nd branch cycle>[R=add.cycle for branch taken][R=add.cycle for pagecrossing]
<irq processing starts here>


There was this explanation with socalled "opcode fetch cycles" that do not allow irq acknowledging and that an irq is not processed before it was acknowledged. Having a pagecrossing situation, the first additional branch cycle belongs to those opcode fetch cycles whereas the next additional cycle for the page crossing does not; thus, it results in less jitter.
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
Gordian
grasstust/Hoaxers
WVL/Xenon
metalux/G★P
Shake/Role
SoNiC/Onslaught/tOM
t0m3000/hf^boom!^ibx
Hairdog/BOOM!^Dream
Brittle/Dentifrice^(?)
Knobby/Role
Soya/Fairlight
REBEL 1/HF
4gentE/ΤRIΛD
sLASH
iAN CooG/HVSC
zscs
sln.pixelrat
tlr
mutetus/Ald ^ Ons
Guests online: 138
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 Wonderland XIV  (9.6)
8 Comaland 100%  (9.6)
9 Halloweed 4 - Blow Y..  (9.6)
10 Fishbomb  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Morph  (9.5)
9 Dawnfall V1.1  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Censor Design  (9.3)
Top Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

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