## LSU EE 4720 Computer Architecture Spring 2016
#

        .text

###############################################################################
#
# Add single-precision floating point to integer, return single.
#

splusi:
        ## Register Usage
        #
        # CALL VALUES:
        #  $f0: Value f.
        #  $a0: Value i.
        #
        # RETURN:
        #  $f30: Return f+i as single precision fp.
        #
        # Note:
        #  Can use $f16-$f31 as temporaries.

        mtc1 $a0, $f17
        cvt.s.w $f16, $f17
        jr $ra
        add.s $f30, $f0, $f16



###############################################################################
#
 ##  Test Code
#
#  This code calls the splusi routine multiple times using
#  the data appearing below.
#

        .data
msg:
        .asciiz "The value of %/f10/7.4f + %/s1/d = %/f12/7.4f\n"
values:
        .float 1.234
        .float -5.678
        .word 0

        .text
        .globl __start
__start:
        la $s2, values
        addi $s3, $0, -1
        mtc1 $0, $f8
MLOOP:
        addi $a0, $0, 2
        jal splusi
        lwc1 $f0, 0($s2)
        cvt.d.s $f10, $f0
        cvt.d.s $f12, $f30
        addi $s1, $a0, 0
        la $a0, msg
        addi $v0, $0, 11
        syscall
        c.eq.s $f0, $f8
        bc1f MLOOP
        addi $s2, $s2, 4
        li $v0, 10
        syscall
        nop