4 ms·
This is imprecise wrt the point of view of caller vs callee. > All a (argument) and t (temporary) registers must be considered destroyed after a function call.
by dreamcompiler 5y ago
This is imprecise wrt the point of view of caller vs callee.
> 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?
- pavehawk2007 5y agoA and T are "caller saved", meaning that if I want their value after I make a function call, I, the caller, must save the registers. So, 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.