I am new to mips assembly. I cant get what exactly those instructions do so I try to test it. This a code to switch values of the registers t0 and t1.
# Perform swap.
lw $t3, 0($t0)
lw $t4, 0($t1)
sw $t3, 0($t1)
sw $t4, 0($t0)
The code seems reasonable,storing their values in t3 and t4 and then swapping them. The thing I can't understand here is why we cant use move or load word here instead of store word? For example why the code cant not be like this?
# Perform swap.
lw $t3, 0($t0)
lw $t4, 0($t1)
move $t1,$t3
move $to,$t4
Or like this
# Perform swap.
lw $t3, 0($t0)
lw $t4, 0($t1)
lw $t1,0($t3)
lw $t2,0($t4)