程序代写代做 assembler 1 MARS

1 MARS
CS 352 : MIPS & Amicable Numbers
You will be using the MIPS Assembler and Runtime Simulator (MARS) for this lab assignment. Download: http://courses.missouristate.edu/KenVollmar/mars/download.htm
Here is a sample Fibonacci (fibonacci.asm) program to familiarize yourself with the MARS environment.
2 Description
In number theory, classifications can be given to numbers, such as perfect, amicable, and sublime. For this project, you are required to compute pairs of amicable numbers.
3 Definitions Proper divisors:
A number m is said to be a proper divisor of another number n if there exists a whole number k such that n = mk, and where k is ≠ 1. In other words, the proper divisors of n
are all whole numbers from 1 to n-1 that divide evenly into n. For example, the proper divisors of 10 are: 1,2, and 5.
Perfect Numbers:
A number is said to be a perfect number if the sum of its proper divisors is equal to the number. As an example, the proper divisors of 6 are: 1, 2, 3. When you sum these together, you get 6. (There is no need to calculate perfectness for this project)
Original number: 6
Proper divisors: 1, 2, 3
Sum of proper divisors: 1 + 2 + 3 = 6 (original number)
Amicable Numbers:
Given two numbers, if the sum of the proper divisors of the 1st number is equal to the 2nd number and the sum of the proper divisors of the 2nd number is equal to the 1st number, the two are considered amicable numbers.
As an example, 220 and 284 are amicable numbers. The proper divisors of 220 (the 1st number) are:
1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110
When you sum these together you get 284 – the 2nd number. The proper divisors of 284 (the 2nd number) are:
1, 2, 3, 71, and 142

If you add these up you get 220 – the 1st number.
1st number: 220
Divisors of 1st number: 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 Sum of divisors: 284 (2nd number)
2nd number: 284
Divisors of 2nd number: 1, 2, 3, 71, 142 Sum of divisors: 220 (1st number)
Sublime Numbers (not implemented – just for fun):
A number is said to be a sublime number if the sum and number of its divisors are both perfect. For example, 12 is sublime. The number 12 has 6 divisors ( 1 2 3 4 6 12). The sum of these divisors is 28. Both the number of divisors (6) and the sum of these divisors (28) are perfect numbers. Therefore, 12 is sublime. (There is no need to calculate sublimeness for this project)
4 The Problem:
You are to write a MIPS program that:
• inputs a range of values to process.
• finds any pairs of amicable numbers in that range and outputs them in ascending order. • continues to run until you input a value that is out of range.
5 Project Code Requirements (READ CAREFULLY)
Besides the functionality requirements for the project, there are the following graded requirements on your code:
• You must use functions. You must have the following functions: isFactor, and isAmicable. You may create other functions as you deem appropriate.
• You must comment your code adequately and follow basic style guidelines such as
proper indentation of code. A small comment at the start of each function definition about what it does is considered good practice.
6 The Input:
1st Prompt
You will input the range of numbers as two values on separate lines at separate prompts. The 1st prompt should be:
Input the start of the range: xxxxx
where xxxxx is your integer value and will be a valid integer.

When to Quit
If the user inputs a non-positive number (zero or negative) then you are to print the following error message:
Unable to check non-positive values
Exiting……
and exit the program without producing any further output.
2nd Prompt
The 2nd prompt, for the end of the range, should be:
Input the end of the range: yyyyy
Again, yyyyy is a valid integer. If the value is non-positive, then you should output the same
message as in the first case and exit the program without producing any further output.
Start > End
If the 2nd number is less than the first number you should print a message:
End of range < start of range -- swapping values And swap or exchange the two values to correct the problem. 7 Output: Amicable Numbers Output (see sample run below) If you find a pair of amicable numbers you should output: uuuuu and wwwww are amicable numbers where uuuuu and wwwww are the two amicable numbers in ascending order and are printed as integers with no decimal point. Stats Output Upon completion of the program, in this case, you should print a message giving the total number of amicable numbers found in the form: Range of numbers: xxxxx - yyyyy Pairs of amicable numbers = zzz ----- 8 Sample Run: Input the start of the range: 1 Input the end of the range: 300 220 and 284 are amicable numbers Range of numbers: 1 - 300 Pairs of amicable numbers = 1 ----- Input the start of the range: 1250 Input the end of the range: 1 End of range < start of range -- swapping values 220 and 284 are amicable numbers 1184 and 1210 are amicable numbers Range of numbers: 1 - 1250 Pairs of amicable numbers = 2 ----- Input the start of the range: -10 Unable to check non-positive values Exiting ...... 9 Testing You will want to consider the following before submission: • Your program detects amicable numbers correctly. • The amicable number pairs are NOT listed twice. • Your program exits gracefully. 10 Grading Rubric Correctness 50% Stress Tests (large data sets) 20% Efficiency (fast execution time) 20% Specifications Compliant 10% 11 Submission Requirements The code should be in a file named yourname_amicable.asm and submitted to the W: drive folder by 11:00am on the due date. A hardcopy must be submitted in class along with a sample run. 12 Some amicable numbers (for testing purposes): 1 220 2 1184 3 2620 4 5020 5 6232 6 10744 7 12285 8 17296 9 63020 10 66928 11 67095 12 69615 13 79750 14 100485 15 122265 16 122368 17 141664 18 142310 19 171856 20 176272 21 185368 22 196724 23 280540 24 308620 25 319550 26 356408 27 437456 28 469028 29 503056 30 522405 31 600392 32 609928 33 624184 34 635624 35 643336 36 667964 37 726104 38 802725 39 879712 40 898216 284 1210 2924 5564 6368 10856 14595 18416 76084 66992 71145 87633 88730 124155 139815 123152 153176 168730 176336 180848 203432 202444 365084 389924 430402 399592 455344 486178 514736 525915 669688 686072 691256 712216 652664 783556 796696 863835 901424 980984