the 'jump + 1' and other delay tricks

I came across some code that needs tight delays and doesn't use NOP.
Instead, it uses JMP + 1.
Apparently this is for 2 clock cycles rather than one.
There is also mention of a 4 clock cycle delay in a PIC book I have, but nothing in the Parallax texts about these handy building blocks.· I suppose I can use them without figuring them out, but I am a bit concerned if they are completely compatible because the SXes use the pipeline in a tighter fashion.
You can even have 4 inside 4 for 16 clock delays.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
Instead, it uses JMP + 1.
Apparently this is for 2 clock cycles rather than one.
There is also mention of a 4 clock cycle delay in a PIC book I have, but nothing in the Parallax texts about these handy building blocks.· I suppose I can use them without figuring them out, but I am a bit concerned if they are completely compatible because the SXes use the pipeline in a tighter fashion.
You can even have 4 inside 4 for 16 clock delays.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Comments
I think you mean jmp $+1 ???
The "$" in this context means "current program address", so jmp $+1 simply continues with the next instruction following the jmp $+1. Whenever the SX executes a jmp instruction, it clears the instruction pipeline (when TURBO mode is on), so it takes three clock cycles (not two). Two cycles are "eaten up" by skip instructions.
When code size matters, a jmp $+1 instruction for delaying three cycles requires only one word in program memory, where three nop instructions (for the same delay time) would take three words instead.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
IREAD is used for a 4 cycle delay, but it affects the W and M registers.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
"People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
·
I did overlook the $ requirement.
I suspected it would be different from the PIC as they don't have TURBO.
What you are saying is different that PIC's coding tricks -- But useful.
As pointed out, rather than fill up an EEPROM with NOPs, you can reduce the delays to 1/3 of the EEPROM space.
Guenther,
I'll take a look in your simulator to be sure I understand that it is three, not two.
I am trying to program a 1-wire interface and the timing is quite important.
Bean,
I never would have thought of using IREAD.
I do understand that it returns a 12 bit value from EEPROM.
More to think about.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
For timing you don't care about the value returned. It's just used as a 1 word 4 cycle delay instruction.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
"People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
·
This code is also kind of funny because of the two stack limitation of PIC. So I am pondering if the additional stacks make time delays easier as well.
In some cases I guess so. I am not really crowded as the PIC program is for a 512byte EEPROM and the SX-28 has 2K.
Overall, it seems that one has to depend more on loops or slow the SX by 4 or more to use these. Timing can be 4x more accurate at the same rate. Of course slowing means less wasted power too.
It all confirms that the SXes are a home for upwardly ambitious PIC users.
{And I don't have to buy another chip version everything my project I/O changes.}
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
If you are trying to convert a PIC program, either run the SX at 1/4 the clock frequency (best for power consumption). Or DON'T use TURBO on the device line. Either method will give you the same speed as the PIC.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
"People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
·
You significantly waste both the power and speed. Very funky engineering. The options were put there by some marketing genius [noparse][[/noparse]an oxymoron!].
Using only two stacks has similar implications. I can just dust off my PIC programmer and cut and paste the PIC program -- but I think I would run out of both EEPROM and RAM.
The real pleasure is in gaining the confidence to transfer programs and improve upon them. I am having to learn C for similar reasons. I don't want to program in it, but I do want to impliment algorthms that are only expressed in C.
I can already look at a Basic program and see how to translate commands into SX-Key assembly language.
If one only reads Parallax examples, there are huge areas of innovative programming that one is ignoring. The JUM $+1 is one tiny example.
It is superior hardward, but you always have to look at the whole community of programmers to see how to improve the firmward and software.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········