How to replace 7 nop?
jmspaggi
Posts: 629
Hi all,
In a PASM method I have 7 NOP that I would like to replace by something cleaner.
They are used to create a delay.
This is not my code I got it for the VLSI ogg player chipset.
Initialy, there was 3 NOPs. But I figured that some songs need more, so I moved to 4, 5, and so on. Now, look like with 7 NOPs it's slow enought so each song has the time to play.
7 NOP = 28 cycles = 350ns.
Do I have a way to use WAITCNT for that?
Like:
My questions: Is that cleaner than 7 nop? Will I not miss the clock because I'm not fast enought?
Thanks,
JM
In a PASM method I have 7 NOP that I would like to replace by something cleaner.
They are used to create a delay.
:aWSBits test aData,#$80 wz if_z andn outa,mskSI if_nz or outa,mskSI shl aData,#1 nop ' Need to wait for 2 CLKI = 83 nano-seconds nop ' nop = 4 prop cycles = 50 nano-seconds nop ' So 2 nops might be enought, but seems not. nop nop nop nop or outa,mskSCLK nop nop nop ' So 2 nops might be enought, but seems not. nop nop nop nop andn outa,mskSCLK
This is not my code I got it for the VLSI ogg player chipset.
Initialy, there was 3 NOPs. But I figured that some songs need more, so I moved to 4, 5, and so on. Now, look like with 7 NOPs it's slow enought so each song has the time to play.
7 NOP = 28 cycles = 350ns.
Do I have a way to use WAITCNT for that?
Like:
mov t1, 28 ' 4 cycles. add t1, cnt ' 4 cycles. waitcnt t1, #0
My questions: Is that cleaner than 7 nop? Will I not miss the clock because I'm not fast enought?
Thanks,
JM
Comments
Including the mov, this provides 7 x 4 clock cycles' delay.
Got it!
Minimum is mov + djnz = 4 + 8. So 3 cycles.
Thanks! Will look cleaner than adding NOPs
JM
...each Zero after the long evaluates to a NOP instruction.
may be even cleaner. Anyway, I don't see anything wrong with a waitcnt (as long as the minimum delay isn't an issue). A djnz may take less space but active delays feel wrong.
This will delay for 14 + n cycles.
FWIW, the initial example (assuming #28) is waiting for too long (14 + 28 - 5) anyway.
good one!... I just briefly looked at the DAT definition in the Manual and didn't think that (meaning the square brackets) would have been possible in Pasm, but I just tried it and it worked just fine.
Apologies for getting slightly OT. Repeating large numbers of instructions can also be done like this:
or even:
'Makes perfect sense.
But, in any event, the rep instruction in the Prop II will spare us all that.
-Phil
Folks, you are crazy!
Anyway, I now know a bit more in PASM
I will probably use the long 0[7]. I found it nice. I will just have to comment it a lot.
Thanks all!
JM