4 ms·
long relative branches are even more fun. Not all PIC has a GOT. Sometimes you just need a chunk of code that can run anywhere in memory. For MIPS this can get
by dmitrygr 9mo ago
long relative branches are even more fun. Not all PIC has a GOT. Sometimes you just need a chunk of code that can run anywhere in memory. For MIPS this can get hard beyond +/-32KB... Here is approximately the minimum thunk to allow branching to anywhere in 32 bit address space relatively to current location, where "offset" is addr of dst minus addr of this thunk minus 8
BGEZAL $zero, . + 8
ADDIU $at, $ra, 0
LUI $t7, hi16(offset)
ORI $t7, $t7, lo16(offset)
ADDU $t7, $ra, $t7
JR $t7
ADDIU $ra, $at, 0