Question

In: Computer Science

Using double precision floating point arithmetic, write a( MIPS )program that will convert input temperatures in...

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)

Solutions

Expert Solution

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 :

  1. get user input a double precision stored in $f0
  2. divide 5/9 and store in register
  3. subtract $f0 - 32 (F-32 )
  4. multiply divided value and subtract value and store in $f12 register
  5. now store value in $v0 to print double value
  6. system call to print $f12 value

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 :



Related Solutions

Convert 103.375 into double precision floating format show all steps and explanations
Convert 103.375 into double precision floating format show all steps and explanations
Convert -99.999 into double precision floating format show all steps and explanations
Convert -99.999 into double precision floating format show all steps and explanations
Convert -99.999 into double precision floating format show all steps and explanations
Convert -99.999 into double precision floating format show all steps and explanations
Convert 103.375 into double precision floating format show all steps and explanations
Convert 103.375 into double precision floating format show all steps and explanations
Convert -99.999 into double precision floating format show all steps and explanations
Convert -99.999 into double precision floating format show all steps and explanations
Convert 103.375 into double precision floating format show all steps and explanations
Convert 103.375 into double precision floating format show all steps and explanations
Find the double precision floating point for -0.115. Put it in hexadecimal form.
Find the double precision floating point for -0.115. Put it in hexadecimal form.
Write a program that asks the user to input a set of floating-point values. When the...
Write a program that asks the user to input a set of floating-point values. When the user enters a value that is not a number, give the user a second chance to enter the value. After two chances, quit reading input. Add all correctly specified values and print the sum when the user is done entering data. Use exception handling to detect improper inputs.5 pts Your code with comments A screenshot of the execution Test Case:       Enter float: 1.0...
Using IEEE 754 single precision floating point, write the hexadecimal representation for each of the following:...
Using IEEE 754 single precision floating point, write the hexadecimal representation for each of the following: a. Zero b. -2.0 (base 10) c. 256. 0078125 (base 10) d. Negative infinity
Q1.Convert C46C000016 into a 32-bit single-precision IEEE floating-point binary number.
Q1.Convert C46C000016 into a 32-bit single-precision IEEE floating-point binary number.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT