Question

I'm writing some self-modifying code and I want to call a C function (call it foo) from MIPS.

I've loaded the mem add of foo, &foo into $t1. Now I jr/jalr $t1.

Will C set $ra as my current PC(+8) (before the jump) allowing me to use JR or will I have to JALR instead (ie, take care of it because C won't)?

I can't test this right now as I'm debugging my macros (for the MIPS mnemonics). I must have messed some up because I keep getting illegal instruction errors.

Was it helpful?

Solution

You have to use JALR. How could the C function possibly know how to set $ra for you?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top