Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: You are to nrite a MIPS assembly program that can multiply or divide two unsigned integers. The program will read2 unsigned integer numbers from

image text in transcribed

Description: You are to nrite a MIPS assembly program that can multiply or divide two unsigned integers. The program will read2 unsigned integer numbers from the SPIM console and then an operation. You must support maltiplication and division You re NOT allowed to use any fom of MIPS multiplication or division instructions (such as malt, muln, div, o divu). You will implement a multiplication algorithm as described in Figure 3.3 in the testbook (i.e, vesion 3 in lecture slides) and a division algorithm as described in Figure 3.11 (e, version 3 in lecture slides) asing shifts, addition and subtraction, etc. Your program will e the SPINM sycallIO support to read a mumber from the console, then read another aumber, and finally the operator (as a string Yoa can assume that all nmbers are entered correctly, so you don't eed to do ary error checking on the mumbers. You sbould print out an eror message if the operation specified by the user is not one of the two listed below. If the operation entered is ",you should print out the product of the 2 numbers; if the operation entered is , you should print out the quouentd the lemainder. You do not need to check overiow. Assume all imputs results are unsigmed 32 bit integers. You should detect and prevent divisson by zero Hints For mulsiply, the final product will be in the lower half of the 64-bit Product register; the upper half is ofen used for overflow checking. The Product register is a pair of 32-bit registers, say(3 s4), when shifting it right one bit, Ss3'sLSB sbould become MSB of S84. The code help you with that. #dothe shifting of the product register li St0, 0x00000001 and $t0, St0, Ss3 sri Ss3. Ss3, 1 add $s4, StO, $84 Use system call mumber to read a string. The following code snippet may be useful whenyou need to the desired data # length 3 for operator because operator enter nulr operstor .sscil ext la SaD, operator li. Sa1, 3 li 3v0, 8 syscall la Ss2, operator lbu S14, 0($52) #loads the character entered by the user la Sto, mult sign lbu beq St4. St5. do-mult #if the character entered is*, perform multiply algorithm # puts entered stuff into "operator" string reads 3 things: character, an enter, and null load the "read string syscall number # operator = s2 = value returned # loads the address of the multiply symbol St5 0($t0) # loads the multiply symbol Description: You are to nrite a MIPS assembly program that can multiply or divide two unsigned integers. The program will read2 unsigned integer numbers from the SPIM console and then an operation. You must support maltiplication and division You re NOT allowed to use any fom of MIPS multiplication or division instructions (such as malt, muln, div, o divu). You will implement a multiplication algorithm as described in Figure 3.3 in the testbook (i.e, vesion 3 in lecture slides) and a division algorithm as described in Figure 3.11 (e, version 3 in lecture slides) asing shifts, addition and subtraction, etc. Your program will e the SPINM sycallIO support to read a mumber from the console, then read another aumber, and finally the operator (as a string Yoa can assume that all nmbers are entered correctly, so you don't eed to do ary error checking on the mumbers. You sbould print out an eror message if the operation specified by the user is not one of the two listed below. If the operation entered is ",you should print out the product of the 2 numbers; if the operation entered is , you should print out the quouentd the lemainder. You do not need to check overiow. Assume all imputs results are unsigmed 32 bit integers. You should detect and prevent divisson by zero Hints For mulsiply, the final product will be in the lower half of the 64-bit Product register; the upper half is ofen used for overflow checking. The Product register is a pair of 32-bit registers, say(3 s4), when shifting it right one bit, Ss3'sLSB sbould become MSB of S84. The code help you with that. #dothe shifting of the product register li St0, 0x00000001 and $t0, St0, Ss3 sri Ss3. Ss3, 1 add $s4, StO, $84 Use system call mumber to read a string. The following code snippet may be useful whenyou need to the desired data # length 3 for operator because operator enter nulr operstor .sscil ext la SaD, operator li. Sa1, 3 li 3v0, 8 syscall la Ss2, operator lbu S14, 0($52) #loads the character entered by the user la Sto, mult sign lbu beq St4. St5. do-mult #if the character entered is*, perform multiply algorithm # puts entered stuff into "operator" string reads 3 things: character, an enter, and null load the "read string syscall number # operator = s2 = value returned # loads the address of the multiply symbol St5 0($t0) # loads the multiply symbol

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions