ASM Timing
Simon Ampleman
Posts: 19
Hello,
I see a 0.5 uSec difference on the oscilloscope between both of these two small asm codes, but I can't explain why. Can somebody help me?
This code :
······················· MOV OUTA,·#0
······················· MOV TIME, CNT
······················· ADD TIME, #4187
······················· WAITCNT TIME, #0
······················· NOP
Should take... 4 cycle + 4 cycle + 4 cycle + 5 cycles + 4187 cycles + 4·cycles = 4208, Am I right?
And this code :
······················· MOV OUTA,·#0
······················· MOV TIME, CNT
······················· ADD TIME, #2087
······················· WAITCNT TIME, #0
······················· MOV OUTA,·#1
······················· MOV TIME, CNT
······················· ADD TIME, #2087
······················· WAITCNT TIME, #0
Should take... 2 * (4 cycle + 4 cycle + 4 cycle + 5 cycles + 2087 cycles) = 4208 cycles.
Thank you.
Simon
I see a 0.5 uSec difference on the oscilloscope between both of these two small asm codes, but I can't explain why. Can somebody help me?
This code :
······················· MOV OUTA,·#0
······················· MOV TIME, CNT
······················· ADD TIME, #4187
······················· WAITCNT TIME, #0
······················· NOP
Should take... 4 cycle + 4 cycle + 4 cycle + 5 cycles + 4187 cycles + 4·cycles = 4208, Am I right?
And this code :
······················· MOV OUTA,·#0
······················· MOV TIME, CNT
······················· ADD TIME, #2087
······················· WAITCNT TIME, #0
······················· MOV OUTA,·#1
······················· MOV TIME, CNT
······················· ADD TIME, #2087
······················· WAITCNT TIME, #0
Should take... 2 * (4 cycle + 4 cycle + 4 cycle + 5 cycles + 2087 cycles) = 4208 cycles.
Thank you.
Simon
Comments
-Phil
In the second the MOV OUTA,#x are separated only by 4+2087+5+4... I see about a half of cycles of difference,,, dont you ?
it is unclear where the strobe is in your first snippet.. After the NOP ? You most likely have a loop...
Furthermore both snippets are not valid programs (#4268, #2087)
The main reason for differences is what Phil says. For further background of interleaved pipeline timing and WHEN an action takes place (at the 6th cycle when re-writing the register) there are some remarks in my tutorial and - as far as I remember - there was an instructive thread some weeks ago...