单精度浮点数的 MIPS 除法错误

Error in MIPS division with single precision floating point numbers

我正在尝试在 MIPS 中实现两个数字的除法,我应该执行以下操作:10.0/2.5

我正在尝试的代码低于一个

 .data 
    float1 : .float 2.5 # declaring the floating values
    float2 : .float 10.0 # declaring the floating values
.text 
 main :

 l.s $f2, float1 # loading the floating values to regester
 l.s $f3 , float2 # loading the floating values to regester

 li $v0,2
 div.s $f1 , $f3 , $f2
 syscall

您需要将浮点值加载到寄存器 $f12

.data 
    float1 : .float 2.5 # declaring the floating values
    float2 : .float 10.0 # declaring the floating values
.text 
     main :

         l.s $f2, float1 # loading the floating values to regester
         l.s $f3 , float2 # loading the floating values to regester

         li $v0,2
         div.s $f12 , $f3 , $f2
         syscall

通过系统调用输出值时,通常会检查寄存器 $a0,但使用浮点寄存器时会检查 $f12。您可以直接将值保存在那里或使用 move 将其复制过来

.data 
    float1 : .float 2.5 # declaring the floating values
    float2 : .float 10.0 # declaring the floating values
.text 
     main :

         l.s $f2, float1 # loading the floating values to register
         l.s $f3 , float2 # loading the floating values to register

         li $v0,2
         div.s $f1 , $f3 , $f2
         mov.s $f12, $f1
         syscall