Shop OBEX P1 Docs P2 Docs Learn Events
How many clock cycles asm commands — Parallax Forums

How many clock cycles asm commands

DXCDXC Posts: 33
edited 2010-08-10 23:57 in Propeller 1
Hello all,

I have made some code but dont know how many clock cycles they take to execute.
Can someone tell me howmany cycles the command below take?

if_z jmp #Begin


I think the instruction below takes 4cycles?

mov t2,SLCK wz ' 4c Clock Pin

gr,

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2010-08-09 10:46
    Most all instructions take 4 clocks. At 80Mhz, this is 50ns.

    (more, but I'm looking)

    Found it, darn quick! That new forum search is worth every other teething pain we are dealing with right now.

    DJNZ, TJZ, TJNZ take 4 on a branch, but 8 on a non-branch. (faster to loop, slower to leave loop)

    Jumps always take 4.

    If you turn a instruction into a conditional, it still consumes 4 cycles, just like a NOP would.

    The timing is more complex on waitpeq, waitvid, etc... Those can be discussed later, if needed.
  • kuronekokuroneko Posts: 3,623
    edited 2010-08-09 17:33
    DXC wrote: »
    I have made some code but dont know how many clock cycles they take to execute.
    For future reference, instructions timing is described in the Propeller datasheet (included with the PropellerTool) on pages 22/23.
  • DXCDXC Posts: 33
    edited 2010-08-09 22:42
    Most instructions are indeed 4cycles.

    But <if_z jmp #Begin> takes a total of 4 cycles or 8 cycles?
    What does NOP mean? No Operational Proces?

    I know a DJNZ is optimized for DOING(4cycles) the jump that NOT DOING(8 cycles)

    Putting the wz flag on the Mov instruction does not cost more the 4 cycles?
    <mov t2,SLCK wz>


    gr,
  • kuronekokuroneko Posts: 3,623
    edited 2010-08-09 22:49
    DXC wrote:
    But <if_z jmp #Begin> takes a total of 4 cycles or 8 cycles?
    It's an absolute jump or a nop (Z = 0) both take 4 cycles.
    DXC wrote:
    What does NOP mean?
    No OPeration (it's useful when you have to e.g. fill the pipeline for self-modifying code but nothing else to do)
    DXC wrote:
    Putting the wz flag on the Mov instruction does not cost more the 4 cycles?
    <mov t2,SLCK wz>
    No, it doesn't. Internally all operations involved (with flags) are done anyway. The flags are just not updated when wz or wc aren't specified. So a mov will always cost you 4 cycles.
  • DXCDXC Posts: 33
    edited 2010-08-10 10:12
    Thnx mate,

    Thats the info I wanted to hear.
    Now I have a very small tlc5940 driver, now I will try to put the GSCLK in the DAtashift bit.

    Btw.
    The rdlong instruction takes 7..22clock cycles, I all software is running will the clock cycle stay the same?
    Thus:
    First run is takes 16 cycles, next run no cags are swapped or deactivated.
    Will the second loop still consist of 16 cycles.
    This way I will be able to make pulses in between the data clock in routine.

    Well if it doesnt work I still have a small and fast tlc5940 driver.

    gr,
  • Nick McClickNick McClick Posts: 1,003
    edited 2010-08-10 10:56
    If you're asking if the hub access window is the same regardless of how many cogs are running - yes, it is. Page 24 in the Propeller Manual.
  • jazzedjazzed Posts: 11,803
    edited 2010-08-10 11:44
    DXC wrote: »
    Btw.
    The rdlong instruction takes 7..22clock cycles, I all software is running will the clock cycle stay the same?
    Thus:
    First run is takes 16 cycles, next run no cags are swapped or deactivated.
    Will the second loop still consist of 16 cycles.
    This way I will be able to make pulses in between the data clock in routine.
    Yes, you can make a pulse between rdlong with 2 xor instructions if you like. The Propeller counters (CTRA,CTRB,WAITVID,etc...) are very good for making pulses too. You can make pulses happen at the same time as one 4 cycle instruction with proper counter setup. Counters can be turned on/off in different ways.
  • DXCDXC Posts: 33
    edited 2010-08-10 23:57
    Jazzed,

    Don't know if you ment to say the same, but I saw something on a AVR forum.
    They used a counter for the GSCLK.
    GSCLK needs 4096 pulses and then a blank then 4096 .... enz.

    Need some digging into the book to see if its also possible with a prop.

    gr,
Sign In or Register to comment.