Did you check it was safe to change $at (or whetever you used) in the implementation ?
If you use JALR $ra, $ra to jump into your function, its behavior is said undefined in the MIPS instructions set document : if $ra is updated BEFORE jumping to address pointed by $ra, it happens to skip the...