0

I'm starting with MIPS and have been assigned a homework in which I have to find the hypotenuse of a triangle given its legs (all of them are single precision floating point numbers). However, in every step I have to check for overflow, by comparing the number with the IEEE754 representation for "infinite", but I don't know how to do that, and I would appreciate any help.

Edit: only code I have so far is for the inputs.

.text
main:
in1:    li $v0,4            #
        la $a0,inleg1       #message to request leg 1
        syscall             #
        li $v0,6            #read entered value as float
        syscall
        mov.s $f1,$f0       #move read value --> $f1=leg1

    #So now I have to include a condition to detect overflow, and show an error message and request the number again
    #The idea is to compare $f1 with infinity, and if it's not smaller, we have overflow
    #Then I have to repeat the evaluation after every operation performed
David E.
  • 1
  • 1
  • Which part are you stuck on? Creating the +infinity floating-point number? Or doing the comparison of the value you have with infinity? Or something else? It would be helpful if you could show the code you have so far. – Mark Dickinson May 22 '17 at 10:08
  • Load the infinity value into a floating-point register, use the `C.cond.fmt` instruction, followed by `BC1F` or `BC1T` (look up those instructions in _MIPS32™ Architecture For Programmers Volume II: The MIPS32™ Instruction Set_). – Michael May 22 '17 at 10:11
  • @MarkDickinson I'm stuck at creating the +infinity floating-point number, so that I can compare my value $f1 with it and detect if there's overflow. – David E. May 22 '17 at 11:13
  • https://www.h-schmidt.net/FloatConverter/IEEE754.html – markgz May 22 '17 at 22:10
  • Solved, thank you all for your help! – David E. May 23 '17 at 04:38

0 Answers0