So I'm learning MIPS right now and I saw on the MIPS green sheet that there are a total of 12 registers (including the s registers) that are preserved across a call. In my understanding of this, one must stack all such registers and retrieve them later when we want access to them again.
However my question is if there was the trouble of going through this, why bother even using these registers? Is there a point of using these registers other than possibly running out of registers to use?
MIPS assembly has a calling convention which specifies that the t
registers are caller saved, and the s
registers are callee saved.
This means that if you call somebody else's function, say mine, you can gaurantee that the s
registers will be the same in your function after my function exits. You cannot gaurantee this for the t
registers, which my function is free to overwrite.
When writing MIPS assembly you should always follow this convention.