1
votes

My method is to spill the int register and load into the float register and then convert

li $t0, 2       
sw $t0, -88($fp)    
l.s $f4, -88($fp)
cvt.d.s $f6, $f4

I'm trying to translate an expression like

float a = 3.0;
float b = a / 2;

But the above method doesn't give me a proper answer (print out inf).

So where have I done wrong? Any suggestions?

P.S. 2 doesn't know the lhs operand is a float type so I can not load 2.0 instead

1

1 Answers

1
votes

You are using an incorrect suffix; .d will operate on a double word (64 bit). Here's what you want:

li   $t0, 2
sw   $t0, -88($fp)
lwc1 $f4, -88($fp)
cvt.s.w $f6, $f4