我正在 MIPS 中编写一个程序来将英寸转换为厘米,但结果总是评估为零。我不知道我哪里做错了。我写了下面的程序。它正在编译,但没有评估正确的结果,总是给出 0。
#declaring some things
.data
inchesText: .asciiz "Enter the number in inches: "
resultText: .asciiz " Centimeters are ==> "
inches: .double 0
inchesToCenti: .double 2.54
centi: .double 0
zero: .word 0
result: .double 0
.text
main:
jal getInches
jal inches_To_Centi
jal finalResult
jal Exit
getInches:
# printing string
la $a0,inchesText
li $v0, 4
syscall
# get inches
li $v0, 7
syscall
s.d $f2, inches
jr $ra
inches_To_Centi:
# loading the formula contstant as it is
l.d $f0, inchesToCenti
#actual inches gained through argument
l.d $f2, inches
# mul both of these to get the centimeters
mul.d $f6, $f0, $f2
s.d $f6, centi
jr $ra
finalResult:
# printing text
la $a0, resultText
li $v0, 4
syscall
# now printing the actual value
l.d $f12, centi
li $v0, 3
syscall
Exit:
li $v0, 10
syscall