Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MIPS program(Mars) that calculates the product of two unsinged integers. In your implementation, you are not allowed to use the MIPS instructions mul

Write a MIPS program(Mars) that calculates the product of two unsinged integers. In your implementation, you are not allowed to use the MIPS instructions mul or mult for multiplication. Use two 32-bit general registers for storing the 64-bit product, e.g., $s1 for products left half and $s0 for right half. Use the following starter code for your program. Assume any values for the two numbers for testing your code. You dont need to print the product on the screen.

Hints: - To logically shift-right the 64-bit product represented by ($s1,$s0), you need to:

(1)shift-right the right-half $s0 by 1 bit,

(2) copy the least-significant-bit (LSB) of $s1 to the MSB of $s0, and then

(3) shift-right the left-half $s1 by 1 bit. - To read, set, or reset a single bit in a register, you may use andi and ori instructions.

# (s1,s0): 64-bit product (s1: prodLeft, s0 prodRight) # t0: 32-bit multiplier # t1: 32-bit multiplicand

# Algorithm: # Product(left_half) = 0, product(right_half) = multiplier # for 32 iteration { # if (product[0] == 1) //if(multiplier[0] == 1) # left-half of product += multiplicand # shift-right product by 1 # }

.text #assume any values for multiplier and multiplicand addi $t0, $0, 6553712 # multiplier addi $t1, $0, 4365537 # multiplicand # Multiplication algorithm starts here

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago