Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to write an ARM assembly program that uses the Sieve of Eratosthenes (er-uh-tos-thuh-neez) algorithm to calculate all prime numbers less than or equal

You are to write an ARM assembly program that uses the Sieve of Eratosthenes (er-uh-tos-thuh-neez) algorithm to calculate all prime numbers less than or equal to N, where N is a named constant. A good description of the algorithm can be found at http://www.geeksforgeeks.org/sieve-of-eratosthenes/. The program below is a C++ version of the solution. The first N+1 bytes of memory beginning at address 0x40000000 will correspond to the bool prime[N+1] array. Each entry in this array will be of type DCB. The first available full-word boundary address after the end of the prime array will corresponds to the start of the vector primes data store. Each entry in this data store will be of type DCD. Obviously your program will be unable to actually display the prime numbers as does the C++ version. Submit your .s file through Canvas. // C++ program to calculate all primes less than or equal to // N using Sieve of Eratosthenes. The primes are stored in a vector #include #include using namespace std; int main() { // Create a boolean array "prime[0..N]" and initialize // all entries it as true. A value in prime[i] will // finally be false if i is Not a prime, else true. const unsigned int N = 100; bool prime[N+1]; for(unsigned int i=0; i primes; // Save all primes in a vector for (unsigned int p=2; p<=N; p++) { if (prime[p] == true) primes.push_back(p); } // Display the contents of the vector for (unsigned int prime : primes) cout << prime << endl; return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions