| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
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?
|
|
| |
Peiselulli
Registered: Oct 2006 Posts: 81 |
No, I think the loop has 7 cycles, so the maximum jitter is 6. |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
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"? |
| |
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.
|
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
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). |
| |
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 |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
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. |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
Ehm... copy & paste error.
2° case, obviously, should have been called "worst case" :) |