What does "Jmp $+2" mean?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Christopher

What does "Jmp $+2" mean?

Post by Christopher »

I have seen it in some delay-functions...

Best Regards
// Christopher Vigren
Tim

Re:What does "Jmp $+2" mean?

Post by Tim »

Literally, jmp $+2 jumps to the instruction immediately after the jmp instruction, and was used as a short delay. For example, the XT (?) used a 4.77MHz ISA bus and an 8MHz CPU; the jmp instruction was required to keep the CPU in sync with the bus. Nowadays the delay induced by the jmp instruction will be tiny, if not zero (a modern CPU will eliminate it); in any case, the chipset should handle most bus timings.

If you do need a short delay, consider writing to an imaginary port (I think port 80h is suitable for this purpose), or using a tight delay loop in conjunction with the real-time clock.
Christopher

Re:What does "Jmp $+2" mean?

Post by Christopher »

Okey. Can the jump have any other effects (flags?)? Or is't just a simple try to a delay-function?

Best Regards
// Christopher Vigren
anubis

Re:What does "Jmp $+2" mean?

Post by anubis »

$ means the current instruction and $+2 points to the next instruction after it.

traditionally using a "jmp " flushes a processor's pipeline and it is forced to refetch the next instruction
from the memory, causing a small delay during this refetching

thus jmp $+2 though referiing to the next instruction causes a small delay which is usually used when syncing with slower devices like PIC's
Christopher

Re:What does "Jmp $+2" mean?

Post by Christopher »

Okey, thanx!
Post Reply