Create a new MIPS program that will ask a user to enter a number repeatedly. This...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a new MIPS program that will ask a user to enter a number repeatedly. This program will calculate 2 sums: even_sum (sum of all even numbers) and odd_sum (sum of all odd numbers). The program will stop when the user enters a '0' and print out both sums (even if they are zero). You may NOT use any the following instructions in your solution: div, and, or, andi, or ori. You will be using a loop to determine when to end the program. In MIPS, ALL types of loop can be implemented with a branch statement (beq or bne). Therefore, write a pseudocode to describe your approach to this problem before writing the MIPS code. It is VERY SIMILAR to the average.c you created in Lab 01. Save your code as sumall.s. Sample Run (user input shown in blue, with each run separated by a dashed line): Please enter a number: 1 Please enter a number: 2 Please enter a number: 3 Please enter a number: -1 Please enter a number: -2 Please enter a number: -3 Please enter a number: 0 Sum of even numbers is: 0 Sum of odd numbers is: 0 SAMPLE RUN 1 ^ Create a new MIPS program that will ask a user to enter a number repeatedly. This program will calculate 2 sums: even_sum (sum of all even numbers) and odd_sum (sum of all odd numbers). The program will stop when the user enters a '0' and print out both sums (even if they are zero). You may NOT use any the following instructions in your solution: div, and, or, andi, or ori. You will be using a loop to determine when to end the program. In MIPS, ALL types of loop can be implemented with a branch statement (beq or bne). Therefore, write a pseudocode to describe your approach to this problem before writing the MIPS code. It is VERY SIMILAR to the average.c you created in Lab 01. Save your code as sumall.s. Sample Run (user input shown in blue, with each run separated by a dashed line): Please enter a number: 1 Please enter a number: 2 Please enter a number: 3 Please enter a number: -1 Please enter a number: -2 Please enter a number: -3 Please enter a number: 0 Sum of even numbers is: 0 Sum of odd numbers is: 0 SAMPLE RUN 1 ^
Expert Answer:
Answer rating: 100% (QA)
Heres the MIPS assembly code for the described program assembly data prompt asciiz Please enter a nu... View the full answer
Related Book For
The Science And Engineering Of Materials
ISBN: 9781305076761
7th Edition
Authors: Donald R. Askeland, Wendelin J. Wright
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
(a) How does the use of condition codes complicate the implementation of a superscalar processor that supports out-of-order execution? [4 marks] (b) A branch predictor with a high prediction accuracy...
-
In Section 36.6 we saw that muons can reach the ground because of time dilation. But how do things appear in the muons reference frame, where the muons half-life is only 1.5 s? How can a muon travel...
-
Convenience store operator Alimentation Couche-Tard Inc. reported the following selected information for the years ended April 29, 2012, and April 24, 2011 (in U.S. $ millions): (a) Calculate the...
-
How is entrepreneurial diversity impacting small business and the economy?
-
Use the Black-Derman-Toy model with \(b=.01\) to match the term structure of Example 16.7. Data from Example 16.7 The 12-year term structure has been extended here to 14 years. We will assume that...
-
Johson Corporation issued bonds twice during 2010. The transactions were as follows: 2010 Jan 1Issued $1,000,000 of 7.5 percent, 10-year bonds dated January 1, 2010, with interest payable on June 30...
-
How can systems theory inform the development of holistic frameworks for assessing the multifaceted dimensions of empowerment within complex adaptive systems ? Explain
-
Sherry, who is 52 years of age, opened a Roth IRA three years ago. She has contributed a total of $12,300 to the Roth IRA ($4,100 a year). The current value of the Roth IRA is $17,600. In the current...
-
Suppose your meetings with the Board, general manager and owner have raised many concerns. It seems over the past few years the general manager has been forced to use his personal credit card to fund...
-
(b) A suspension bridge cable is made up of 100 strands of steel wire each with a cross-section of 10 mm. If a tensile force on the cable of 300 kN results in the cross-sectional area of each strand...
-
2.8) A square reinforced concrete pier 300 mm x 300 mm in cross-section and 2.5 m high has 8 steel square reinforcing bars, each 20 mm x 20 mm, placed symmetrically about the vertical axis of the...
-
The endurance limit of an alloy at 1 x 107 cycles is found to be a = 70 MPa when tested at a load ratio of R = 0.2. Calculate the endurance limit at a mean stress of zero. Take the ultimate tensile...
-
2 For the first order system G (s) s+0.5 response has a damping ratio of 0.5 and natural frequency 2 rad/s. R(s) E(s) = find the parameters of a PI-controller so the closed loop K(s) U.(s) G(s) D(s)...
-
The mass of the Moon is approximately 7.35 E+22 kg, and its mean distance form the Earth is about 3.80 E+8 km. Determine the force of mutual gravitational attraction in newtons between the Earth and...
-
e. For exponential and log equations: You should wait until the variable is isolated to plug anything into your calculator. f. When given a rational function, you determine a hole versus a vertical...
-
What services are provided by the provincial and territorial governments?
-
Determine the crystal structure for the following: (a) A metal with a 0 = 4.9489 , r = 1.75 , and one atom per lattice point; and (b) A metal with a 0 = 0.42906 nm, r = 0.1858 nm, and one atom per...
-
Calculate the fractions of ionic bonds in silicon carbide (SiC) and in silicon nitride (Si3N 4 ).
-
Explain the meaning of these terms: creep, stress relaxation, crazing, blushing, environmental stress cracking, and aging of polymers.
-
Briefly explain the budgetary variances and the way it is used.
-
What do we mean by budgeting, and how would this process serve the firm?
-
Briefly describe the two most common types of budget.
Study smarter with the SolutionInn App