Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Flimsoft ! (Registered 2013-06-18) You are not logged in 
CSDb User Forums


Forums > C64 Coding > cmp $d012 / bne *-3 : how many cycles?
2012-03-14 21:09
Flavioweb

Registered: Nov 2011
Posts: 124
cmp $d012 / bne *-3 : how many cycles?

I know that in this code:

lda #rasterlinenumber
cmp $d012
bne *-3
-StartSomething-


the "comparison" between Accumulator and $d012 is made during 4th cycle of -cmp- opcode.
I've readed and asked around a lot and seems that the maximum cycles of "jitter" (related to raster) produced by the loop is 7 cycles because:
if raster line changes during first cicle of "bne" we have 3 cycles for "bne taken" then "4 cycles" for "cmp"...

But i think:
if raster goes to "#rasterlinenumber" on cycles 1 of "bne", we must wait 3 cycled for "bne taken" (because previous condition is -not equal-), 4 cycles for "cmp $d012 again", then 2 cycles for "bne not taken" (because new condition is -equal-).
So, in total, 9 cycles of maximux jitter from raster line start before execute first opcode of "-StartSomething-".

It's correct?
2012-03-14 21:44
Peiselulli

Registered: Oct 2006
Posts: 39
No, I think the loop has 7 cycles, so the maximum jitter is 6.
2012-03-14 21:49
Flavioweb

Registered: Nov 2011
Posts: 124
Quote: No, I think the loop has 7 cycles, so the maximum jitter is 6.

Ok...
7 cycles if raster change BEFORE 4th cycle of CMP...

1st cycle = 7 cycles to the end of loop...
2nd = 6
3rd = 5
4th = 4

5 = 1st "bne" cycle = how many cycles to "exit the loop"?
2012-03-14 22:02
Peiselulli

Registered: Oct 2006
Posts: 39
code performed                cycles for leaving loop if d012 changed at this cycle

      . . .
cmp $d012 fetch opcode        5
cmp $d012 fetch low addr      4
cmp $d012 fetch hi  addr      3
cmp $d012 fetch data + cmp    2
bne *-3   fetch obcode        8
bne *-3   fetch offset        7
bne *-3   perform branch      6
cmp $d012 fetch opcode        5
cmp $d012 fetch low addr      4
cmp $d012 fetch hi  addr      3
cmp $d012 fetch data +cmp     2
bne *-3   fetch obcode        8
bne *-3   fetch offset        7
bne *-3   perform branch      6
    . . .

So you have only values between 2 and 8. That means a jitter of 6.
2012-03-14 22:14
Flavioweb

Registered: Nov 2011
Posts: 124
Quoting Peiselulli

So you have only values between 2 and 8. That means a jitter of 6.

If you mean this loop as outside-of-irq-code routine, ok.
At max we have 7 cycles jitter with any code, if we avoid illegal opcodes.

I mean to use this loop to "detect" when raster line changes.
Suppose to use it with all IRQ disabled and to detect when raster line 1 (not 0 !) is reached.
On which cycle of the raster line the "-StartSomething-" first opcode is executed if first cycle of rasterline match the first "bne" cycle?
(Is this the -jitter- i mean: from rasterline first cycle to... when -StartSomething- first opcode runs. I'm sorry if i incorrectly used the term "jitter" but did not know how to explain otherwise).
2012-03-15 15:14
Freshness79

Registered: Jan 2005
Posts: 50
You probably mean the delay.
The jitter is just the difference between maximum and minimum delay.
I think that the table should be written like this:
Best case:

#1 cmp
#2 cmp
#3 cmp
* Here, on first half of Phi2, raster changes
#4 cmp	-> 1
#1 bne  -> 1
#2 bne  -> 1

Delay: 3 cycles

Best case:

#1 cmp
#2 cmp
#3 cmp
#4 cmp
* Here, on first half of Phi2, raster changes
#1 bne  -> 1
#2 bne  -> 1
#3 bne  -> 1
#1 cmp	-> 1
#2 cmp	-> 1
#3 cmp	-> 1
#4 cmp	-> 1
#1 bne  -> 1
#2 bne  -> 1

Delay: 9 cycles


That means:
Minimum delay: 3 cycles
Maximum delay: 9 cycles
Jitter: 6 cycles
2012-03-15 16:40
Flavioweb

Registered: Nov 2011
Posts: 124
Ok!
Yes i mean delay from first raster cycle.
So, if there are no more 'variables' involved, the max possible delay is 9 cycles.
Tnx.
2012-03-15 16:45
Freshness79

Registered: Jan 2005
Posts: 50
Ehm... copy & paste error.
2° case, obviously, should have been called "worst case" :)
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
Moloch/Arkanix Labs
Veto/Arsenic
Danzig/Guilty
Zielok/Elysium
Sphinx/Arsenic
Robin Levy
Medicus
Paulko64
jaws
sailor/Triad
Zapotek
Steppe/HVSC
Deev/Onslaught
Dr. Strange/Hokuto F..
Yazoo/Censor/Arsenic
JSL
Six/Dark Lords of Ch..
Sledge/Fairlight
tlr
ron.sos
Guests online: 52
Top Demos
1 Coma Light 13  (9.7)
2 Edge of Disgrace  (9.7)
3 Deus Ex Machina  (9.3)
4 Andropolis  (9.3)
5 +H2K  (9.2)
6 Artphosis  (9.2)
7 Desert Dream  (9.1)
8 2011 - A Press Space..  (9.1)
9 Soiled Legacy  (9.1)
10 Wonderland XI  (9.1)
Top onefile Demos
1 Daah, those acid pil..  (9.6)
2 One-Der  (9.2)
3 Dawnfall  (9.1)
4 Te-Te-Te-TechTech It..  (9.0)
5 Safe VSP  (9.0)
6 Exotic Excitement  (8.9)
7 Ächzzeit  (8.9)
8 Isterreport  (8.9)
9 Pimp My Commodore  (8.9)
10 Cubase64  (8.9)
Top Groups
1 Booze Design  (9.4)
2 Crest  (9.4)
3 Oxyron  (9.4)
4 Maniacs of Noise  (9.2)
5 Eagle Soft Incorpora..  (9.2)
Top Hardware-Gurus
1 Soci  (9.9)
2 Jeri  (9.9)
3 Lemming  (9.8)
4 Zer0-X  (9.8)
5 Wiesel  (9.4)

Home - Disclaimer
Copyright © No Name 2001-2013
Page generated in: 0.126 sec.