Whenever I pass arguments ($a0 or $a1) to a section (label) I reach using jal, does it matter if I use temporary registers (like $t0) instead of saved registers like ($s0) to hold or manipulate the arguments in that section? Is there any risk using one set instead of the other while the section is running?

有帮助吗?

解决方案

If by "segment" you mean function call, you should follow the MIPS calling convention described here. A function can change the values of $t0,...,$t9 without needing to restore them before returning. Code that calls a function must assume that $t0,...,$t9 values have been changed when the function returns.

其他提示

if you are implementing a function call from somewhere that supports the calling convention (a C program calling your asm code). No you dont HAVE to make all of your own internal calls conform so long as those internal callees are assumed to not be visible outside that context. Meaning you cannot call them from C for example because you are choosing not to conform to the C calling convention for that compiler and target. So long as the entry point that you will be calling from the outside, from the outside conforms to the standard then you can do whatever you want.

The pros and cons are things like not conforming can improve performance, but conforming makes register management and maintenance easier.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top