2

I had this question on my exam and i am confused because as far as i know that

move $t0, $a0               # COPY $A0 TO $T0

in MIPS instruction provides that and MIPS is a RISC processor. Am I missing something?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
roffensive
  • 564
  • 4
  • 22
  • 1
    If they have zero register like MIPS (and most RISC-like do), then `add`/`or` are "obvious" substitutions. Without zero register it would made me scratch my head for some time. – Ped7g Nov 13 '18 at 18:51
  • 1
    Also it's maybe not obvious why, if you missed that part about how machine code is encoded. On RISC machines usually every instruction has size of exactly one machine "word" (32 bits quite often). So the fewer instructions you need to encode, the more bits are left for registers specification and/or immediate values. Notice that 32 bit instruction can't contain both instruction opcode and 32 bit immediate, so that's why loading full 32b constant on 32b RISC CPU into register usually takes either 2-3 normal instruction, or the constant is fetched from memory. No `move` = more bits for others. – Ped7g Nov 14 '18 at 00:16
  • [almost all RISC ISAs have a zero register](https://stackoverflow.com/a/52438497/995714) to remove the need for a move instruction. [Why MIPS uses R0 as "zero" when you could just XOR two registers to produce 0?](https://electronics.stackexchange.com/q/293830/27052), [Difference between adding 0 and moving a register in MIPS](https://stackoverflow.com/q/42315308/995714), [How does a zero register improve performance?](https://stackoverflow.com/q/24646101/995714), [Why the %r0 of SPARC or MIPS, is always 0?](https://stackoverflow.com/q/19130790/995714) – phuclv Oct 01 '21 at 07:23
  • Does this answer your question? [Difference between adding 0 and moving a register in MIPS](https://stackoverflow.com/questions/42315308/difference-between-adding-0-and-moving-a-register-in-mips) – phuclv Oct 01 '21 at 07:24

1 Answers1

5

Move is a pseudo-instruction, and when assembled will really be a different instruction.

For instance

move $t0, $zero gets implemented as addu $t0, $zero, $zero

phuclv
  • 37,963
  • 15
  • 156
  • 475
lostbard
  • 5,065
  • 1
  • 15
  • 17