Shop OBEX P1 Docs P2 Docs Learn Events
Time Loss in compiled Delay implementation SX/B Vs Assembly — Parallax Forums

Time Loss in compiled Delay implementation SX/B Vs Assembly

Wissam Ch.Wissam Ch. Posts: 36
edited 2008-03-15 12:36 in General Discussion
I have checked the ASM equiv of the SX/B command PAUSEUS and found the following

I entered in SX/B· :
· PAUSEUS· 100

I checked the ASM and found :

·MOVE·· __PARAM4, #80
·DJNZ·· __PARAM4,@$

why the compiler chose the constant 80 and based on what ??


Knowing that the·freq settings is 4_000_000 , which means each cycle is 250ns .
DJNZ· takes 4 cycles if the jump is executed .

4cycles x 80 = 320 cycle· needed for __PARAM4 to be zero
320 cycle * 250ns = 80,000 ns or· 80 microseconds.

we still miss 20 microseconds to achive the 100 us delay.
How could that be ?
Where is the missing part ?






·

Comments

  • BeanBean Posts: 8,129
    edited 2008-03-14 23:06
    The "DJNZ __PARAM4,@$" takes 5 cycles not 4 cycles (the "@" makes it take an extra cycle).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • Wissam Ch.Wissam Ch. Posts: 36
    edited 2008-03-15 07:42
    Thanks Bean for the clarification.

    what is the benefit of using the @ , is it just to make the selection of the __PARAM4 startup value easier.
    can we use @@ or whatever number of @s in order to select a number of cycle which is easy match the required delay?
  • BeanBean Posts: 8,129
    edited 2008-03-15 12:36
    The "@" is used to select the correct code page.
    You will find an "@" prefix on all jumps in SX/B compiled code.

    Use a NOP to waste 1 cycle.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
Sign In or Register to comment.