Reputation: 35
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)
Upvotes: 0
Views: 13063
Reputation: 831
Store word (4 bytes) : to take content from register and store it in memory
Load word (4 bytes): It's strictly the opposite, get value from memory emplacement and store it in register
Move: it's copy value from register 1 (for example) and put it to another register
Upvotes: 1