Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write and test a MIPS assembly language program to compute and display the first

ID: 3765655 • Letter: W

Question

Write and test a MIPS assembly language program to compute and display the first prime numbers up to n where n is given. Set n to be 19 but the program should work of any value of n.

This can be implemented in any way you wish. I suggest that you write a high level language program to do it first to make sure you have the algorithm correct.

For the program to identify primes, the easiest way is to use the algorithm:

for (i = 2; i < x; i++)  
    if ((x % i) == 0) break;   //break out, not prime

where x is the number you are checking to see if prime. The "remu" instruction can do x % i. The suggested algorithm is not an efficient algorithm but easier to code than a more efficient algorithm. (Note for example, the above code does not actually have to iterate from 2 to x to find whether x is prime; stopping at squareroot(x) is sufficient.)

Explanation / Answer

Answer :

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote