Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

outline some of the current issues facing HR managers

Answered: 1 week ago