.text .globl main .data #variable declarations enter: .asciiz "Enter the temperature: " result: .asciiz "The temperature in Celsius is " newline: .asciiz "\n" .text #code section main: li $v0, 4 # system call for print_string la $a0, enter # load string to print syscall # print the string li $v0, 5 # system call for read_int syscall # read the temperature jal ftoc # call to procedure ftoc rtn1: move $t0, $v0 # store the result li $v0, 4 # system call for print_string la $a0, result # load string to print syscall # print the string li $v0, 1 # system call for print_int move $a0, $t0 # move the int to print syscall # print the int li $v0, 4 # system call for print_string la $a0, newline # load string to print syscall # print the string li $v0, 10 # syscall for exit syscall # exit # procedure ftoc # computes the celsius temperature from the fahrenheit temperature ftoc: add $t0, $v0, -32 # add -32 to fahrenheit temperature # and store in celsius temperature mul $t0, $t0, 5 # multiply celsius temperature by 5 div $t0, $t0, 9 # div celsius temperature by 9 move $v0, $t0 # move the result to return register jr $ra # return to procedure call