Are these two instructions equivalent, i.e do they both do the exact same thing?
addi $s0,$s0,0 and add $s0, $s0, $zero

Recommended Answers

All 3 Replies

I haven't use a MIPS assembler that accepts $zero, but yes - they both don't do anything.

Though I've heard that some might prefer one to the other when the other is used more often (a little less heat going through one instruction). I'm not sure how usefull that is in practice though.

What do you mean they don't do anything?

So I just learned that the convention of using $zero and $s0 are specific calling conventions for some tools chains (O32/N32/N64). In this case $s0 is really $16 and $zero is really $0.

What I mean when I say "they don't do do anything" is that they don't do anything. Is this homework? Read out the instruction to yourself. add $16, $16, $0. What signed integer value does register $0 always hold? If you know what add $d, $s, $t does, then what is the effect when $t is $0 and $d is $s? Now do the same thing for addi $16, $16, 0. Contrast and compair the state before and after both instructions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.