12

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?

TheLethalCoder
  • 6,668
  • 6
  • 34
  • 69
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424

1 Answers1

17

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.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • Thank you for the answer which was what I thought and why then is my r8 always 0 when it is supposed to be handling a call from a testing function? The background is here http://stackoverflow.com/questions/12105322/how-to-proceed-coding-for-this-assignment and here http://stackoverflow.com/questions/12152323/why-is-load-word-not-working – Niklas Rosencrantz Aug 28 '12 at 08:23
  • 1
    @Nick, looking over your other two questions, the initial value for `testmytime` _IS_ zero. It only seems to change on each test iteration using all that `randr` and other random stuff. – paxdiablo Aug 28 '12 at 08:39