I want to load a float that is stored on a memory location. In this case, it's aSpace, bSpace and one. If I load, for instance, one BEFORE I ask for the user's input, it loads correctly, as "1.0". Although, if I load it AFTER the user's input, it it loads as whatever the user input on his last input. In fact, every loaded float does that. What am I doing wrong here?

I've tried changing the order of the operations, running it line by line, pretty much everything. I can't understand these results.

.data
    aSpace:     .float
    bSpace:     .float
    one:        .float      1

.text
    la $a0, aSpace
    jal floatInput

    la $a0, bSpace
    jal floatInput

    lwc1 $f12, one
    jal floatPrint
    lwc1 $f4, aSpace
    lwc1 $f6, bSpace
    jal floatPrint
    j exit

##################################################

return:
    jr $ra


floatPrint:
    li, $v0, 2
    syscall
    j return

floatInput:
    li $v0, 6
    syscall
    swc1 $f0, ($a0)
    syscall
    j return

exit:
li, $v0, 10
syscall

I expected to load the value in "one", but I load whatever the user's last input was instead.

1 Answers

0
Pedro Cavalheiro On Best Solutions

As Jester and Peter Cordes said, my problem was having aSpace: .float, instead of aSpace: .float 0.0. Fixed