News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Jump speed

Started by SittingDuck, November 02, 2005, 05:52:50 PM

Previous topic - Next topic

SittingDuck

Why do jumps take so long? Is it to do with the prefetch cache?

Tedd

Yes.
Straight jumps (jmp) aren't so bad, it's the conditionals (jz, jnz, jc, jnc, .....) that cause the problems since the processor doesn't know whether the jump will be taken until it gets to it, and by then it's a bit late for prediction.
A simple version of the way it works is that the first time you get to a conditional jump it will be predicated as being taken if it jumps backwards, and not taken if forwards (this is because loops usually jump backwards, and exists from loops jump forwards.) Then, jumps are remembered (up to a limit) and the next time they're encountered are predicted as going the same way as the previous time. There are extra things for predicting patterns of jumps, but let's not get into that :wink
No snowflake in an avalanche feels responsible.