gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Speed of jumps

#59568 - SittingDuck - Wed Nov 02, 2005 6:49 pm

Why do jumps take so long? Is it because the prefetch cache has to fill up?

#59594 - poslundc - Wed Nov 02, 2005 8:48 pm

SittingDuck wrote:
Why do jumps take so long? Is it because the prefetch cache has to fill up?


The instruction prefetch on the GBA (which is turned off by default) can improve performance of sequential code, but I think you'll only ever see a benefit in Thumb code running from ROM. I'm not too clear on the specifics of its operation, but it only ever "caches" a single instruction ahead.

Branches are slow because they require a flush of the three-stage instruction pipeline. They are even slower for code running from ROM because they require a random rather than sequential memory access. Branches in code running from EWRAM or IWRAM still requires the pipeline flush (two extra cycles), but you don't incur an additional penalty for reading from a different memory location.

Dan.