by dreamcompiler · 5y ago · 0 comments
> All a (argument) and t (temporary) registers must be considered destroyed after a function call. All s (saved) registers can be considered saved after a function call.
Who must do the considering here? The caller or the callee? I expect it's the caller because that makes the most sense, but I'd like to see it spelled out.
If my assumption is correct, that implies that callees are required to restore the s registers before returning but they are not required to restore a or t registers before returning. Correct?
li t0, 10 call somefunc # Must consider t0 destroyed here unless we save it first
The saved registers are different li s0, 10 call somefunc # Can consider s0 = 10 here.
However, if we use the s registers, we have to make sure we put it back the way we found it. So, before li s0, 10, I need to save the old value of s0.