Time Loss in compiled Delay implementation SX/B Vs Assembly
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 ?
·
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
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
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?
You will find an "@" prefix on all jumps in SX/B compiled code.
Use a NOP to waste 1 cycle.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·