0

is it this instruction is correct Using SPIM ?

add $t1,$zero,-1

after run program the $t1 is fill by "ffffffff"

Craig Estey
  • 30,627
  • 4
  • 24
  • 48
Hary Coder
  • 13
  • 5
  • ffffffff is the hex for -1 – Linear Apr 18 '16 at 20:28
  • It's not an accepted practice on SO to post a question with code that has a bug, get an answer, and then edit the question with the answer [obscuring the original code and the reason why you asked the question in the first place]. This makes both the question and the answer make no sense. Questions and answers have value for others that might have a similar problem. It is acceptable to edit your question and append updated code to the bottom, but here, it's a one liner, so hardly worth it. I've rolled back the edit – Craig Estey May 28 '16 at 04:51

1 Answers1

1

You want addi instead of add

addi $t1, $zero, -1

The addi instruction sign-extends the 16-bit immediate, so it should place 0xffffffff in $t1.

Zack
  • 6,232
  • 8
  • 38
  • 68