0
.data
    time:       .float 310.4, 390.8
    miles:      .float 12.0, 96.2

.text  
    li $t0, 3           #terminating value
    li $t1, 4           #byte shifting 
    li $t2, 1           #i increments by 1  
    la $a1, time        # put address of time into $a1
    la $a2, miles       # put address of miles into $a2     
    l.s $f1, ($a1)
    l.s $f2, ($a2)

    mul.s $f3, $f1, $f2

    li $v0, 2           
    l.s $f12, __  <------- here????         
    syscall

how do I print f3? This is starting to get frustrating. I can print $a1 or $a2 and shift it, but I need to multiply some numbers and print them.... thanks!

4

1 回答 1

5

Here goes as an answer to complete the rationale behind:

  • You should use l.s $f12, ($a1) when you want to load a floating point value from memory
  • If you already have the floating point number you want to print in some coprocessor register (but not in $f12 which is used by syscall 2), you have to move the contents from the floating point register which has the value to $f12, using instruction mov.s

So, in your example you would do:

  li $v0, 2
  mov.s $f12, $f3   # Move contents of register $f3 to register $f12
  syscall
于 2013-04-01T18:26:20.180 回答