Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED THE ANSWER IN MIPS NOT C. Ive asked this question 4 times and cant seem to get it in mips. You are tasked

I NEED THE ANSWER IN MIPS NOT C.
Ive asked this question 4 times and cant seem to get it in mips.
You are tasked to use positive integers to compute:
h = ( f / g );
#returns h_quotient and h_remainder
i = ( f + g ) / h_quotient;
#returns i_quotient and i_remainder
j = ( f g ) % i_quotient;
#returns j_remainder
More formally, write MIPS code to output the result of above expression of h, i, and j without using any
built-in MIPS/MARS instructions for multiplication or division. The values already entered for Part A for
a, b, c, and d can be used. Output the value of h, i, and j in a format shown below, as separate decimal
integers.
To receive credit, no multiplication, no division, and no shift instructions shall be used. Namely, do not use
any of {mul, mul.d, mul.s, mulo, mulou, mult, multu, mulu, div, divu, rem, sll, sllv, sra, srav, srl, srlv}. The
goal is to compose your own division technique. In addition, use of a loop is required for credit to realize
the division code. It is part of the project points to design a way to realize division using a loop.
Do not use
of Macro, Subroutines, or Functions in this project
.
You can refer to the definition of division and how division works. For example, given a positive integer
X, and a positive integer Y where X>Y then the division X/Y is computed such that unique integers Q and
R satisify X=( Y * Q + R) where 0 R < Y. The value Q is called the quotient and R is called the remainder.
Some examples are:
{X = 7, Y = 2} then 7 = 2 * 3 + 1 so Q=3 and R=1
{X = 8, Y = 4} then 8 = 4 * 2 + 0 so Q=2 and R=0
{X = 13, Y = 5} then 13 = 5 * 2 + 3 so Q=2 and R=3
Sample output for Part B is:
f_ten = 49026
g_ten = 13122
h_quotient = 3
h_remainder = 9660
i_quotient = 20716
i_remainder = 0
j_remainder = 15188
here is the code from the previous part A:
.data
msg1: .asciiz "Enter 4 integers A,B,C,D respectively: "
msg2: .asciiz "f_ten="
msg3: .asciiz " f_two="
msg4: .asciiz " g_ten="
msg5: .asciiz " g_two="
.text
main:
li $v0,4
la $a0,msg1 #program prints "Enter 4 integers A,B,C,D respectively: "
syscall
li $v0,5 #user enters integer A
syscall
move $t0,$v0 #stores integer A into t0
li $v0,5 #user enters integer B
syscall
move $t1,$v0 #stores integer B into t1
li $v0,5 #user enters integer C
syscall
move $t2,$v0 #stores integer C into t2
li $v0,5 #user enters integer D
syscall
move $t3,$v0 #stores integer D into t3
li $t6, 0 # sets t6 to zero
move $t4,$t0 #moves A into t4
move $t5,$t0 #moves A nto t5
jal multiply #multiplication of A by itsel
move $s0,$t6
li $t6,0 # resets t6 to zero
move $t4,$t1 #moves integer B ito t4
move $t5,$t3 #moves integer D into t5
jal multiply #multiplies B and D
sub $s0,$s0,$t6 #realizes function f
li $t6,0 # resets t6 to zero
move $t4,$t0 #moves A into t4
move $t5,$t3 #moves D into t5
jal multiply #multiplies A and D
move $s1,$t6
li $t6,0 # resets t6 to zero
li $t4,6 #sets t4 to 6
move $t5,$t2 #moves C to t5
jal multiply #multiplies C and 6
add $s1,$s1,$t6 #realizes function G
j printexit
multiply: #loop
beq $t4,$zero,term #when t4 is zero, end multiply
add $t6,$t6,$t5 #add t5 to t6 and store into t6
sub $t4,$t4,1 #subtract t4 by 1
j multiply
term:#endloop
jr $ra #return
printexit:
li $v0,4
la $a0,msg2 #program prints "f_ten="
syscall
li $v0,1 #displays f in decimal
move $a0,$s0
syscall
li $v0,4
la $a0,msg3 #program prints "f_two="
syscall
li $v0,35 #displays f in binary
move $a0,$s0
syscall
li $v0,4
la $a0,msg4 #program prints "g_ten="
syscall
li $v0,1 #displays g in decimal
move $a0,$s1
syscall
li $v0,4
la $a0,msg5 #program prints "g_two="
syscall
li $v0,35 #displays g in binary
move $a0,$s1
syscall
li $v0,10
syscall

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

Students also viewed these Databases questions

Question

Why are notes to statements necessary?

Answered: 1 week ago

Question

12. Identify the ultimate boon in Excalibur.

Answered: 1 week ago