# floating-point multiplication .data newline: .asciiz "\n" .text main: addiu $v0, $zero, 6 # read a single syscall mfc1 $a0, $f0 mov.s $f1, $f0 addiu $v0, $zero, 6 syscall mfc1 $a1, $f0 mov.s $f2, $f0 jal fmult mtc1 $v0, $f12 addiu $v0, $zero, 2 #display a single syscall addiu $v0, $zero, 4 la $a0, newline syscall mul.s $f12, $f1, $f2 addiu $v0, $zero, 2 syscall addiu $v0, $zero, 10 syscall # Preconditions: # 1st parameter (a0) single precision floating point multiplicand # 2nd parameter (a1) single precision floating point multiplier # Postconditions: # result (v0) single precision floating point product fmult: # v0 = 0, the default result # return if multiplicand is zero # return if multiplier is zero # place mask for leftmost bit in t5 # t5 = 0x80000000 # place sign of multiplicand in t0 # mask off exponent and significand # place sign of multiplier in t1 # mask off exponent and significand # place sign of product in t2 # t2 = xor of signs # place exponent of multiplicand in t0 # shift to remove sign bit # shift to remove significand bits # subract exponent bias # place exponent of multiplier in t1 # shift to remove sign bit # shift to remove significand bits # subract exponent bias # place exponent of product in t3 # ignore the possibility of overflow or underflow # t3 = sum of exponents # add exponent bias # place significand of multiplicand in t0 # shift to remove exponent # restore implicit 1 to left of significand # place significand of multiplier in t1 # shift to remove exponent # restore implicit 1 to left of significand # place significand of product in t4 # ignore rounding and overflow # multiply significands (unsigned) # t4 = high word of product # branch if already normalized # shift significand to normalize # adjust exponent norm: # shift to remove implicit 1 # assemble product in v0 # shift exponent into proper position # shift significand into proper position # place sign in v0 # place exponent in v0 # place significand in v0 return: # return