I came across an instruction jalr $t1, $t2that supposedly sets $ t1 to the return address and goes into $ t2. However, there seems to be some ambiguity as to which operation takes place in the first place. For example, MARS and SPIM work differently:
.text
main:
la $t0, func
jalr $t0, $t0
li $v0, 10
syscall
func:
jr $t0
In MARS, it is $t0first set to pc + 4(return address) and then goes to $t0, so the code under funcnever starts. However, SPIM seems to do oppsite: jump first, then set the value $t0(previous) pc + 4; therefore funccalled and executed as usual.
So my question is, which simulator implements the correct behavior in this case?