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 > cmp $d012 / bne *-3 : how many cycles?
2012-03-14 20:09
Flavioweb

Registered: Nov 2011
Posts: 447
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 20:44
Peiselulli

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

Registered: Nov 2011
Posts: 447
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 21:02
Peiselulli

Registered: Oct 2006
Posts: 81
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 21:14
Flavioweb

Registered: Nov 2011
Posts: 447
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 14:14
Fresh

Registered: Jan 2005
Posts: 101
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 15:40
Flavioweb

Registered: Nov 2011
Posts: 447
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 15:45
Fresh

Registered: Jan 2005
Posts: 101
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
Hoogo/Padua
CommodoreBlog
Scrap/Genesis Project
A3/AFL
Guests online: 79
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 No Bounds  (9.6)
7 Comaland 100%  (9.6)
8 Aliens in Wonderland  (9.6)
9 Uncensored  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Happy Birthday Dr.J  (9.7)
2 Layers  (9.6)
3 It's More Fun to Com..  (9.6)
4 Cubic Dream  (9.6)
5 Party Elk 2  (9.6)
6 Copper Booze  (9.6)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Rainbow Connection  (9.5)
9 Dawnfall V1.1  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 SHAPE  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

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