Question

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!

Was it helpful?

Solution

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.)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top