Question: Complete the assembly code for the fmult function. Ignore the possibility of overflow and underflow, and do not round the result. If you need an

Complete the assembly code for the fmult function. Ignore the possibility of overflow and underflow, and do not round the result. If you need an immediate value that is larger than 16 bits, such as for a mask, use the li pseudo-instruction to first load the value into a register.

# float.s

# floating-point multiplication

.text

.globl fmult

# 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

multu $t0, $t1 # multiply significands (unsigned)

mfhi $t4 # t4 = high word of product

bge $t4, $zero, norm # branch if already normalized

srl $t4, $t4, 1 # shift significand to normalize

addi $t3, $t3, 1 # adjust exponent

norm: sll $t4, $t4, 2 # shift to remove implicit 1

# assemble product in v0

sll $t3, $t3, 23 # shift exponent into proper position

srl $t4, $t4, 9 # shift significand into proper position

move $v0, $t2 # place sign in v0

or $v0, $v0, $t3 # place exponent in v0

or $v0, $v0, $t4 # place significand in v0

return: jr $ra # return

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!