Difference between load word and move?

Niklas R. picture Niklas R. · Aug 28, 2012 · Viewed 14.7k times · Source

What is the difference between

ldw r8,0(r4)

and

mov r8, r4

Load word says "copy from memory" but when load word copies from r4, it is copying from register and not from memory right?

Answer

paxdiablo picture paxdiablo · Aug 28, 2012

The lw instruction (I assume that's what you meant since ldw isn't a standard MIPS instruction, though all the loads will be similar in the context of this answer) loads a word from the memory address specified by 0 + r4, while move1 simply transfers the value of r4 into r8.

For example, let's say r4 is currently 1234 and the word stored at 1234 in memory is 5678.

The difference is thus:

move r8, r4            ; r8 is now 1234
lw   r8, 0(r4)         ; r8 is now 5678

1 The move instruction" is actually a pseudo-instruction where move $rt, $rs is encoded as addi $rt, $rs, 0.