# Fahr-celsius a floating point subroutine
# which converts fahrenheit to celsius (ftoc).
	.text
	.globl	main
main:
	move	$s1, $ra	# Keep the ra safe (stack is another good place)
	li	$v0,4		# output a prompt
	la	$a0, msg1
	syscall
	li	$v0,6		# input a floating pt. number
	syscall			# User input is now in $f0
	mov.s	$f12, $f0	# Use $f12 for f. p. argument
	jal	ftoc		# Jump to the ftoc routune
	li	$v0,4		# output a label for results
	la	$a0, msg2
	syscall
	li	$v0,2		# Use 2 to print a float using syscall
	mov.s	$f12, $f0	# Put returned value in $f12 for syscall use.
	syscall
	move $ra, $s1		# $ra was munged by the call to ftoc
	j $ra			# return
	.data
msg1:	.asciiz	"\nA fahrenheit temperature?  "
msg2:	.asciiz "\nThe celsius value is: "
	.text
ftoc:###############  Convert fahrenheit to celsius ################
	la	$t0, five	# Get address of five
	l.s	$f16, 0($t0)	# Put 5.0 into $f16
	la	$t0, nine	# Get address of nine
	l.s	$f18, 0($t0)	# Put 9.0 into $f18
	div.s	$f16, $f16, $f18# Now put 5.0/9.0 into $f16
	la	$t0, thirtytwo	# Get address of thirtytwo
	l.s	$f18, 0($t0)	# Put 32 into $f18
	sub.s	$f18, $f12, $f18# f18 = fahr-32
	mul.s	$f0, $f16, $f18	# Use $f0 to return (5/9)*(f-32)
	j	$ra		# return
.data
five:	.float	5.0
nine:	.float	9.0
thirtytwo: .float 32.0