0

I have a loop that ends with this

bne $f2, $zero, loop

It should return to the beginning of the loop if $f2 equals zero, but I'm getting this error.

"$f2": operand is of incorrect type

How do I compare a double value to zero?

smac89
  • 39,374
  • 15
  • 132
  • 179
Matt123
  • 556
  • 3
  • 15
  • 36
  • 1
    You will need to use floating point comparison and branch. Consult an instruction set reference. Alternatively, if you don't have signed zero, you can move the value back into an integer register and keep the `bne` since a floating point zero is all 0 bits. – Jester Nov 10 '16 at 01:48

1 Answers1

3

You have to use something like

li.d $f0, 0        # store the value 0 in register $f0
c.ne.d $f0, $f2    # $f0 != $f2?
bc1t loop          # if true, branch to the label called "loop"
Community
  • 1
  • 1
smac89
  • 39,374
  • 15
  • 132
  • 179