Page 1 of 1
What does "Jmp $+2" mean?
Posted: Fri Jun 14, 2002 1:17 pm
by Christopher
I have seen it in some delay-functions...
Best Regards
// Christopher Vigren
Re:What does "Jmp $+2" mean?
Posted: Fri Jun 14, 2002 1:44 pm
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.
Re:What does "Jmp $+2" mean?
Posted: Fri Jun 14, 2002 1:52 pm
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
Re:What does "Jmp $+2" mean?
Posted: Fri Jun 14, 2002 1:54 pm
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
Re:What does "Jmp $+2" mean?
Posted: Fri Jun 14, 2002 1:56 pm
by Christopher
Okey, thanx!