write a MIPS program that successfully executes on the QiSpim simulator that determines if numbers input...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
write a MIPS program that successfully executes on the QiSpim simulator that determines if numbers input by a user are perfect or prime. Your program should prompt the user, read an integer value, show the sum of the factors of the value that was read, and indicate whether or not the number is perfect. If it is not perfect, then you should also indicate whether or not it is prime. You should continue until a number less than 2 is entered. You are required to write a separate function to determine if one integer value is a factor of another integer value. Call this function is a factor. This function will accept two integer arguments, where the first is the larger value (received through Sa0) and the second is the potential factor (received through Sal). It returns a value (through $v0) of one if the second value is a factor of the first value, and otherwise returns a value of zero. You are also required to write a separate function that prints the factors of a integer value, where a '+' separates each preceding factor and the next factor. The factor list should be followed by an '=' and the sum of the factors. Call this function print_sum_of_factors. It accepts an integer argument (through Sa0) and return the sum of the factors of the argument (through $v0). The is_a_factor, print_sum_of_factors, and main functions should follow the MIPS calling conventions described in class. Note you should only use a syscall instruction to perform I/O and should not use it to exit the program. Be sure to provide a comment before each block of MIPS assembly code so others can understand your program. The assignment is due in Canvas before the beginning of class on September 28. Below is an example session where the output is generated by the program with the values entered by the user dis- played in bold. You should make your output exactly match output. Enter a value greater than 1: 4 1+2=3 The number 4 is not perfect. Enter a value greater than 1: 6 1+2+3=6 The number 6 is perfect! Enter a value greater than 1: 10 1+2+5=8 The number 10 is not perfect. Enter a value greater than 1: 13 1=1 The number 10 is not perfect and prime. Enter a value greater than 1: 0 Exiting program. write a MIPS program that successfully executes on the QiSpim simulator that determines if numbers input by a user are perfect or prime. Your program should prompt the user, read an integer value, show the sum of the factors of the value that was read, and indicate whether or not the number is perfect. If it is not perfect, then you should also indicate whether or not it is prime. You should continue until a number less than 2 is entered. You are required to write a separate function to determine if one integer value is a factor of another integer value. Call this function is a factor. This function will accept two integer arguments, where the first is the larger value (received through Sa0) and the second is the potential factor (received through Sal). It returns a value (through $v0) of one if the second value is a factor of the first value, and otherwise returns a value of zero. You are also required to write a separate function that prints the factors of a integer value, where a '+' separates each preceding factor and the next factor. The factor list should be followed by an '=' and the sum of the factors. Call this function print_sum_of_factors. It accepts an integer argument (through Sa0) and return the sum of the factors of the argument (through $v0). The is_a_factor, print_sum_of_factors, and main functions should follow the MIPS calling conventions described in class. Note you should only use a syscall instruction to perform I/O and should not use it to exit the program. Be sure to provide a comment before each block of MIPS assembly code so others can understand your program. The assignment is due in Canvas before the beginning of class on September 28. Below is an example session where the output is generated by the program with the values entered by the user dis- played in bold. You should make your output exactly match output. Enter a value greater than 1: 4 1+2=3 The number 4 is not perfect. Enter a value greater than 1: 6 1+2+3=6 The number 6 is perfect! Enter a value greater than 1: 10 1+2+5=8 The number 10 is not perfect. Enter a value greater than 1: 13 1=1 The number 10 is not perfect and prime. Enter a value greater than 1: 0 Exiting program.
Expert Answer:
Answer rating: 100% (QA)
MIPS assembly program data inputprompt asciiz Enter a value greater than 1 resultnotperfect asciiz The number is not perfect resultperfect asciiz The ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Traditional versus Object-Oriented Design" : Compare the object-oriented approach to design to the traditional approach.
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
5. (8 points) (Determining a hidden "dot product vector") Consider the problem where one is given black-box access to a function f: {0, 1}" {0, 1} such that f(x) = a-z, where a {0,1}" is unknown....
-
A person stands on a scale in an elevator. As the elevator starts, the scale has a constant reading of 591 N. As the elevator later stops, the scale reading is 391 N. Assume the magnitude of the...
-
Refer to the data in Exercise 6-1 for Ida Sidha Karya Company. The absorption costing income statement prepared by the company's accountant for last year appears below: Sales . . . . . . . . . . . ....
-
The three bars are made of A-36 steel and form a pinconnected truss. If the truss is constructed when T 1 = 50F, determine the vertical displacement of joint A when T 2 = 150F. Each bar has a...
-
Rapture Corporation had the following transactions. 1. Issued $200,000 of bonds payable. 2. Paid utilities expense. 3. Issued 500 shares of preferred stock for $45,000. 4. Sold land and a building...
-
Insert 2, 7, 12, 10 in the following AVL tree. Perform rotation(s) if needed. 5 15 25 00 8 20 35
-
The information below pertains to the retiree health care plan of Thompson Technologies: Thompson began funding the plan in 2024 with a contribution of $127,000 to the benefit fund at the end of the...
-
Discuss the notion of administration of justice with its classification and influences in a legal system.
-
Data for Hermann Corporation are shown below: Selling price Variable expenses Contribution margin Percent Per Unit of Sales $ 60 39 100% 65 $ 21 35% Fixed expenses are $72,000 per month and the...
-
The following Trial Balance was extracted from the books of Hope Enterprise as at 31 December 2022. Sales Purchases Inventory as at 1 January 2022 Motor vehicles Office equipment Accounts receivable...
-
ps://mybscbryantstratton.edu/webapps/assessment/take/launch.jsp?course_assessment_id=_361377_18course_id=_93... A Question Completion Status: QUESTION 10 8.5 points Compose a statement that correctly...
-
2. Enlist the assistance of at least four volunteers to undertake the role of the members of Team A and Team B. Each team must have at least two members. Discuss with your volunteers the roles they...
-
A chemical company has developed a new lightweight, high-strength plastic. The company is planning to spend $20 million for a manufacturing plant in order to begin full-scale production. As a result,...
-
Use a calculator, spreadsheet, or another tool to solve for the unknown sides of the given right triangle. The length of the hypotenuse is 13. a is the length of the side opposite the 10 angle and b...
-
Information graphics, also called infographics, are wildly popular, especially in online environments. Why do you think infographics continue to receive so much attention? How could infographics be...
-
Answer each of the following questions: a) What does it mean to choose numbers at random? b) Why is the Random class useful for simulating games of chance? c) Why is it often necessary to scale or...
-
What does the following app display? // Ex. 5.25: Mystery2.cs using System; 3 2 class Mystery2 { static void Main() { int count = 1; 4 5 while (count
-
Besides the obvious benefits of reuse made possible by OOP, what do many organizations report as another key benefit of OOP?
-
What is the impact of the Internet on international business? Which companies and which countries will gain as Internet usage increases throughout the world? Which will lose?
-
How do merchandise exports and imports differ from service exports and imports?
-
What is portfolio investment?
Study smarter with the SolutionInn App