Home / Expert Answers / Computer Science / exercise-individual-mips-sieve-in-the-files-for-this-lab-you-have-been-given-sieve-s-add-code-pa272

(Solved): EXERCISE - INDIVIDUAL: MIPS Sieve In the files for this lab, you have been given sieve.s. Add code ...



EXERCISE - INDIVIDUAL:
MIPS Sieve
In the files for this lab, you have been given sieve.s.
Add code to sieve.s to make it equi}
3
5
7
11
13
17
19
23
}
971
977
983
991
997
if (prime[i]) {
}
HINT:
printf(%d\n, i);
for (int j = 2 * i; j < ARRAY_LEN; j

EXERCISE - INDIVIDUAL: MIPS Sieve In the files for this lab, you have been given sieve.s. Add code to sieve.s to make it equivalent to this C program: // Sieve of Eratosthenes // https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes #include #include #include #define ARRAY_LEN 1000 uint8_t prime [ARRAY_LEN]; int main(void) { // Sets every element in the array to 1. // This has already been done for you // in the data segment of the provided MIPS code. memset(prime, 1, ARRAY_LEN); for (int i = 2; i < ARRAY_LEN; i++) { if (prime[i]) { } } printf("%d\n", i); for (int j = 2 * i; j < ARRAY_LEN; j += i) { prime[j] = 0; } return 0; } 3 5 7 11 13 17 19 23 } 971 977 983 991 997 if (prime[i]) { } HINT: printf("%d\n", i); for (int j = 2 * i; j < ARRAY_LEN; j += i) { prime[j] = 0; Use the space in the data area to store the array prime. For example: $ 1521 mipsy sieve.s 2 } return 0; Use lb and sb instruction to access array prime. uint8_t is equivalent to a byte.


We have an Answer from Expert

View Expert Answer

Expert Answer


Solution: TO FIND PRIME NUMBERS USING SEIVE ERATOSTHENES: { int Primes [n+1]; for (int i=0; i
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe