In: Computer Science
Using double precision floating point arithmetic, write a( MIPS )program that will convert input temperatures in Fahrenheit to Celsius. The program should prompt the user for a temperature in Fahrenheit and then print the corresponding temperature in Celsius. The formula for the conversion is:
C = 5/9 * (F – 32)
Answer : please up vote or comment for any query . i will update the same . Thanks
Note : check attached image for output and program
I used MARS Simulator for programming
Program plan :
Program :
.data
   enter : .asciiz "enter farenheit temperature:
\n"
   print : .asciiz "temperature in celsius: \n"
.text
   li $v0,4 #load v0 with 4 to print string
   la $a0 , enter #print enter string
   syscall #system call for string print
  
   li $v0 ,7 #get double value from user
   syscall #user entered value will be stored in
$f0
     
   li $t0, 9 #load 9 in t0
   li $t1 , 5 #load 5 in t1
   li $t2 ,32 #load 32 in t2
  
  
   mtc1.d $t0 , $f20 #move 9 to $f20
   cvt.d.w $f20, $f20 #convert into double precision
value
  
   mtc1.d $t1 , $f22 #move 5 to $f22
   cvt.d.w $f22, $f22 #convert into double precision
value
  
   mtc1.d $t2 , $f24 #move 32 to $f24
   cvt.d.w $f24 ,$f24 #convert into double precision
value
  
   div.d $f26 , $f22, $f20 #divide 5/9 and store in
$f26
  
   sub.d $f28 , $f0, $f24 # subtract user entered
fahrenheit from 32 (F-32 ) and store in #f28
  
   mul.d $f12 , $f28 , $f26 #multiply value of $f26 and
$f28 and store in $f12
  
  
  
  
   li $v0,4 #print message which store in print string
variable
   la $a0 , print
   syscall
  
   li $v0 ,3 #print celsius value which is store in $f12
or you can move in any variable
   syscall
  
  
Output :

Program :

