# fcmp.s -- Practice floating-point comparisons. # We assume that the numbers will be double precision. # # $f0 = return from OS input function # $f12 = first input number # $f14 = second input number #------------------------------------------------------------------------ .data prompt1: .asciiz "Please enter first floating-point number: " prompt2: .asciiz "Please enter second number: " relation_str: .ascii "The relationship(s) between " .asciiz "the 1st and 2nd number is/are:\n" equal_str: .asciiz "equal\n" not_equal_str: .asciiz "not equal\n" less_str: .asciiz "less than\n" less_equal_str: .asciiz "less than or equal to\n" greater_str: .asciiz "greater than\n" gr_equal_str: .asciiz "greater than or equal to\n" #------------------------------------------------------------------------ .text main: li $v0, 4 # ask user for 1st number la $a0, prompt1 syscall li $v0, 7 # input a double-precision number syscall mov.d $f12, $f0 li $v0, 4 # ask user for 2nd number la $a0, prompt2 syscall li $v0, 7 # input a double-precision number syscall mov.d $f14, $f0 li $v0, 4 # Introduce output. la $a0, relation_str syscall #--------------------------------------------------------- # Now we perform our comparisons like c.eq.d, c.lt.d, etc. # and print appropriate message(s). #--------------------------------------------------------- li $v0, 4 # tell user the numbers are == la $a0, equal_str syscall li $v0, 4 # tell user the numbers are != la $a0, not_equal_str syscall li $v0, 4 # tell user the first is < the second la $a0, less_str syscall li $v0, 4 # tell user the first is >= the second la $a0, gr_equal_str syscall li $v0, 4 # tell user the first is <= the second la $a0, less_equal_str syscall li $v0, 4 # tell user the first is > the second la $a0, greater_str syscall li $v0, 10 # End of program! syscall