Shop OBEX P1 Docs P2 Docs Learn Events
Clock cycles — Parallax Forums

Clock cycles

Mike GMike G Posts: 2,702
edited 2008-03-22 21:51 in Propeller 1
Hi all,

Using this code snippet

receive                 test    axmask,ina      wc      'C is set if odd parity after AND
        if_nc           jmp     #:getByte                'if C is set jump to receive
                        djnz    TOcounter, #receive
…
:getByte




If TOcounter started at 10_000 and ended at 4053. That would be 5947 loops. In clock cycles that would be
Test = 4
Jmp = 4
Djnz = 4, 8

Therefore, (4 + 4 + 8) * 5947 = 95,152 – 4 = 95,148 clock cycles, correct?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-22 21:51
    The DJNZ takes 4 cycles if the jump is successful and 8 cycles if it fails so you have 5947 * (4+4+4)+4 clock cycles until the instruction after the loop is executed. That assumes that the DJNZ is what exits the loop. If the JMP condition is successful, on the 5947th loop, you have 5946 * (4+4+4) + 4 (for the TEST) + 4 (for the JMP).
Sign In or Register to comment.