How to replace 7 nop?
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
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
DAT :aWSBits test aData,#$80 wz if_z andn outa,mskSI if_nz or outa,mskSI shl aData,#1 long 0,0,0,0,0,0,0 ' Need to wait for 2 CLKI = 83 nano-seconds ' nop = 4 prop cycles = 50 nano-seconds ' So 2 nops might be enought, but seems not. or outa,mskSCLK long 0,0,0,0,0,0,0 ' So 2 nops might be enought, but seems not. andn outa,mskSCLK...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.
Apologies for getting slightly OT. Repeating large numbers of instructions can also be done like this:
CON mult_pin = 0 add_frqa_frqa = $80BFF5FA ' add frqa, frqa [COLOR="Red"]ror_outa_imm1[/COLOR] = $20FFE801 ' ror outa, #1 zero = $1FF ' vscl DAT ... xor outa, minus1 ' +20 OR logic, 1: disabled long [COLOR="Red"]ror_outa_imm1[15][/COLOR] ' long [COLOR="Red"]ror_outa_imm1[16][/COLOR] ' send out remaining gate bitsor even:
( movs acc,ina shl acc,#8) [4]'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