I am writing a program in MIPS to convert inches into centimeters, but the result is always evaluating to zero. I don't know where I did wrong. I have written the program below. It's compiling, but not evaluating the correct result, always giving 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