3) Write a MIPS assembly program to calculate the factorial of a given integer n. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
3) Write a MIPS assembly program to calculate the factorial of a given integer n. The factorial of n is defined as n!= n*(n-1)*...*1 Note that 0! = 1. Algorithm for computing factorial: 1. INPUT n= 5; //given number n 2. f = 1; 3. while (n > 1) f = f * n; n = n - 1; } 4. OUTPUT 1; //factorial f = n! Requirements: 1. Input number n = 5, to be stored in memory location at address 0x00. 2. Register assignment: $aon; $s0n! 3. You must use the algorithm shown above. 4. The assembly program shall contain no more than 11 real MIPS instructions. 5. The factorial of 5 must be written to the memory location at address 0x10. 4 3) Write a MIPS assembly program to calculate the factorial of a given integer n. The factorial of n is defined as n!= n*(n-1)*...*1 Note that 0! = 1. Algorithm for computing factorial: 1. INPUT n= 5; //given number n 2. f = 1; 3. while (n > 1) f = f * n; n = n - 1; } 4. OUTPUT 1; //factorial f = n! Requirements: 1. Input number n = 5, to be stored in memory location at address 0x00. 2. Register assignment: $aon; $s0n! 3. You must use the algorithm shown above. 4. The assembly program shall contain no more than 11 real MIPS instructions. 5. The factorial of 5 must be written to the memory location at address 0x10. 4
Expert Answer:
Answer rating: 100% (QA)
Answer Heres a simple MIPS assembly program to calculate the factorial of a given integer nn and sto... View the full answer
Related Book For
Computer Organization And Design The Hardware Software Interface
ISBN: 9780123747501
4th Revised Edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these programming questions
-
Write a MIPS assembly program that sorts a sequence of positive integers entered from the console (one number in one line). The end of the sequence is indicated by a 0 (zero). Verify that the program...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Why might cloud computing be greener than conventional computing alternatives? Research online and share examples suggesting that cloud firms could be less environmentally taxing than if a firm built...
-
In a column in the Wall Street Journal, venture capitalist Peter Thiel described the difference between monopoly businesses and competitive ones: "Suppose you want to start a restaurant in Palo Alto...
-
Lucky Enterprises is using a discounted cash flow model. Identify which model Lucky might use to estimate discounted fair value under each scenario, and calculate the fair value: Scenario 1: Cash...
-
Show that the Stefan-Maxwell model can be rearranged to define a pseudo-binary diffusivity, \(D_{i \mathrm{~m}}\), for species \(i\) in the mixture: \[\frac{1}{D_{i...
-
Suresh Co. expects its five departments to yield the following income for next year. Recompute and prepare the departmental income statements (including a combined total column) for the company under...
-
What is the output? int main() { for (int i = 0; i < 3; ++i) { cout < < i; } } cout < < i; return 0;
-
The City of Castletons General Fund had the following post-closing trial balance at June 30, 2022, the end of its fiscal year: Debits Credits Cash $ 265,120 Sales Taxes Receivable 11,000 Taxes...
-
The Westfield branch of Security Home Bank has submitted the following cost data for last year: $ 144,000 69,000 90,000 $ 303,000 Teller wages Assistant branch manager salary Branch manager salary...
-
3. Assume that the donor concentration in an n-type semiconductor at T = 300 K is given by Na(x) = 106-1015x (cm-3) where x is in cm and 0 x 0.01 cm. The electron mobility is, n = 960 cm V.S (i)...
-
Inadvertently, a manufactured laminate is not labeled and the fiber orientations of the layers are unknown. It is known that the layer thickness of the laminate produced using graphite/epoxy is...
-
Consider the following alternatives: Alternative 1 Alternative 3 Alternative 2 First cost ($) 170,000 120,000 100,000 Net cash flow per year ($/year) 34,500 24,000 15,000 Salvage value ($) 0 0 0...
-
The equation that describes this lab is: Gm m Fg = Notice that in the equation, ris squared AND it is on the bottom of a fraction. We therefore say that the relationship between Fg and ris an inverse...
-
1. The stress-strain diagram below for carbon steel was obtained by tensile testing. a) Elastic modulus? b) The highest load that the cylindrical sample with an initial diameter of 9.4 mm can carry?...
-
A wastewater treatment plant serving a city of 200,000 discharges 1.10 m3/s of treated effluent having an ultimate BOD of 50.0 mg/L into a stream that has a flow of 8.70 m3/s and an ultimate BOD of...
-
Burberrys competitive advantage is through its differentiation strategy. What risk should Burberry remain aware of?
-
Prioritize interrupts from the devices listed in each table row. Section 6.6 defines an eight-step process for handling interrupts. The Cause and Status registers together provide information on the...
-
The following problems explore translating from C to MIPS. Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C program. For the C statements...
-
List at least one more possible pair of values for C and D if such assumptions are not maintained. Memory consistency concerns the views of multiple data items. The following table shows two...
-
Make an energy diagram for gas B in Figure 20.4. Figure 20.4 When gases of different temperatures are placed in thermal contact, energy is transferred thermally from the hotter to the cooler gas...
-
Suppose you were to play the two film clips shown in Figure 20.7 backward. Would the resulting processes be possible? Figure 20.7 Quasistatic versus non-quasistatic expansion of a cylin- der...
-
(a) What are the SI units of \(Q\) ? (b) For the process depicted in Figure 20.2a, make an energy diagram for each of these systems: (i) water, pot, and flame; (ii) pot and flame; (iii) pot. Figure...
Study smarter with the SolutionInn App