9
votes

I'm currently taking a Computer Organization and Assembly Language course that mainly uses the MIPS instruction set to teach assembly language.

I noticed that many of the examples that the professor has posted online use add or addi to move a value into the $a0 argument register for calling print services like the following...

# store the first integer in $a0 and print
add $a0, $zero, $t0
li $v0, 1
syscall

or...

# store the first integer in $a0 and print
addi $a0, $t0, 0
li $v0, 1
syscall

I've also noticed some examples online where others just use the move instruction to accomplish the same thing like the following...

# store the first integer in $a0 and print
move $a0, $t0
li $v0, 1
syscall

Is using the add or addi instruction preferred over simply using move in this scenario? If so then why? Is there a performance difference or is this just a matter of taste?

1

1 Answers

12
votes

The move instruction is not a real instruction - it is a pseudo instruction that is translated into an add instruction by the assembler.

There are a whole bunch of these pseudo instructions, see e.g. https://en.wikipedia.org/wiki/MIPS_architecture#Pseudo_instructions

This type of thing is very common on RISC processors, where you want a minimal instruction set, and a particular instruction may be used for more than one purpose.