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 > A question about branching

#166055 - brave_orakio - Mon Jan 19, 2009 4:11 am

Hi guys, this is a question of curiosity more than anything else.

If I remember correctly, the speed at which code execute from ROM is 3,1 correct? 3 from the start and 1 for subsequent code.

Now, would the 1 cycle still be applicable for a b(branch) call going to within the same file or would that already take 3 cycles? an example would be a loop like this:

Code:

.L6
add r2,r3
mov r0,r2
cmp r0,r1
blt .L6



Please forgive me if the above code doesn't make sense, I really haven't programmed in thumb/arm assembly(The above is supposed to be a loop). Now, would the blt .L6 use 3 cycles or would it consume only 1 cycle?
_________________
help me

#166056 - Dwedit - Mon Jan 19, 2009 5:54 am

In addition to all waitstates from the memory type your code is in, it is 3 cycles for a branch which is taken, and 1 cycle for a branch which is not taken.

To get no additional penalty from waitstates, your code must be in IWRAM on the GBA, or in Cache or ITCM on the NDS. Maybe 16-bit thumb code in VRAM during HBLANK or VBLANK also gives no waitstates.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."