Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Celsius to Fahrenheit Conversion (Single Precision Floating Point and Procedure

ID: 3643602 • Letter: C

Question

Celsius to Fahrenheit Conversion (Single Precision Floating Point and Procedure usage)
Write a simple program for converting temperature in Celsius to temperature in Fahrenheit.
Please use single precision floating point and make sure to write and call a procedure c2f to do the actual conversion.
Temp in degree Fahrenheit = (Temp in degree Celsius)*(9.0/5.0) + 32.0
Note: You will need to look up syscall codes for reading and printing float.
Also for procedure calls remember to use jal proc_name and then jr $ra for returning from the procedure back to the main program. When you use proc calls remember to send arguments and receive results in appropriate registers.

You may use mov.s and li.s for moving and loading floating point single precision.
For example
mov.s $f12, $f0 #moves contents of reg f0 into reg f12
li.s $f18, 9.0 # loads the const 9.0 into reg f18
You may use mul.s, div.s, add.s, sub.s with 3 f registers

Explanation / Answer

(°F - 32) x 5/9 = °C #The Fahrenheit to Celsius part: .globl fini .text main: #--------------------- addi $v0, $0, 5 # v0 = readInt code 5: Read Line syscall # call an operation add $t0, $0, $v0 # $t0 receives input Fahrenheit t0 = F addi $t1, $0, 32 # t1=32 mul $t2, $t1, 5 mfhi $a0 #hi mflo $a1 #lo add $t3, $a0, $a1 addi $s0, $s1, 9 div $t4, $t3, $s0 mflo $a3 # That's your Celsius. Hope that helps. =D

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote