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 :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.