3
votes

Ive read some describing the difference between $S and $T I cant seem to comprehend what exactly the difference is. So for a beginner programmer who just started learning RISC.

What exactly is the difference in laymans terms? It seems they should do the same thing for addition, subtraction? Does the difference lay in arrays?

Thank you!

2
This has nothing at all to do with RISC, nor does it have anything to do with MIPS either other than this happens to be the platform that uses this naming convention and calling convention and assembly.old_timer

2 Answers

3
votes

There is no difference in how the registers work. There is a difference in how the registers are conventionally used. According to the MIPS calling convention, the values of the $S registers $S0,..,$S7 are preserved across function calls, and the values of the $T0,...,$T9 registers may be changed by the called function.

Consider the following code as a concrete example: (Note that a syscall is basically a function call.)

li   $s3, 42
li   $t0, 81
move $a0, $t0         # the value in $a0 will be printed
li   $v0, 1           # syscall 1 is print integer
syscall

After the syscall, $s3 is still guaranteed by the calling convention to have the value 42, and the other $sxx registers' values are unchanged. We do not know what the value in $T0 will be after the call, because the convention does not require its value to be preserved.

(Edited to add an example.)

2
votes

They are completely the same, they are just registers. The only different is in the calling convention, the protocol of calling functions:

  • temporary registers: the called function, callee, may change their content. The caller is responsible of saving their content.
  • the saved registers, the callee must not change their content, if there is a need to do that, it has to store their content first and then restore their content before it returns.

You may be still at the beginning, you should find out about it when you study functions calling, stack, stack frame.