在 MIPS 中打印乘法后的浮点数

DDu*_*man 0 floating-point mips

.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
Run Code Online (Sandbox Code Playgroud)

如何打印 f3?这开始变得令人沮丧。我可以打印 $a1 或 $a2 并移动它,但我需要乘以一些数字并打印它们......谢谢!

gus*_*bro 5

以下是完成背后原理的答案:

  • 当您想从内存l.s $f12, ($a1)加载浮点值时应该使用
  • 如果您已经在某些协处理器寄存器中拥有要打印的浮点数(但不是系统调用 2 使用的浮点数),则必须使用指令$f12从浮点寄存器中移动其值为 的内容$f12mov.s

所以,在你的例子中你会这样做:

  li $v0, 2
  mov.s $f12, $f3   # Move contents of register $f3 to register $f12
  syscall
Run Code Online (Sandbox Code Playgroud)