MIPS将整数乘以浮点,得到错误答案

MIPS将整数乘以浮点,得到错误答案,mips,Mips,当我运行程序并输入20度时,输出为8.8E-44(火星)和0.000000(QtSpim)。应该是62.8 我在这里使用了错误的说明吗 .data pi: .float 3.14 c: .word 180 initMSG: .asciiz "\nEnter an angle in degrees: " .text .globl main main: mul $t5, $t2, $t6 add $t5, $t5, $sp addi $t5, $t5, 4

当我运行程序并输入20度时,输出为8.8E-44(火星)和0.000000(QtSpim)。应该是62.8

我在这里使用了错误的说明吗

.data
pi:     .float   3.14
c:      .word   180
initMSG: .asciiz "\nEnter an angle in degrees: "

.text
.globl main

main:
    mul $t5, $t2, $t6
add $t5, $t5, $sp
addi    $t5, $t5, 4
lw  $t9, 0($t5)

mul $t4, $t1, $t6
add $t4, $t4, $a0
sw  $t9, 0($t4)

addi    $t2, $t2, 1

addi    $t1, $t1, 1
j   forLoop3


Exit:
li $v0, 10          #load the system exit command 
syscall             #stop the program

问题在于,
pi
是一个浮点数,但从用户那里获取的值是一个纯整数。在将用户的值与
pi
相乘之前,需要将其转换为浮点值

幸运的是,您不必手动转换它,因为有一个读取浮点而不是整数的系统调用。将读取syscall从5更改为6(6表示读取浮点),并删除随后的两行(syscall 6将浮点直接读取到
$f0
)。在这样做并使用20度再次运行之后,我得到62.800003作为输出(会有少量错误,因为3.14不能用二进制浮点精确表示)