This project acquaints students with techniques of array-processing used to implement a classic algorithm from antiquity, processing command-line arguments, and timing the program execution at runtime.
Write an assembly language program which generates a listing of all the prime numbers smaller than a given upper bound, based upon the famous Sieve of Eratosthenes. (A prime number is an integer, greater than one, which is not evenly divisible by any integers except itself and one. Examples of prime numbers are 2, 3, and 5. The number 4 is not a prime, since it has the number 2 as a factor.
In ancient times, the Greek mathematician Eratosthenes proposed the following simple algorithm for determining all the prime numbers smaller than an arbitrary positive number N.
This algorithm (known as the 'sieve') has often been applied by computer scientists as a standard "benchmark" for evaluating the performance of a new processor or language compiler. As such, it would be useful to include a time measurement, and to inform the user at the end how long the sieve took to execute.
Your program should take a required argument, specifying the upper bound for the prime number search. It should also accept an option -v switch on the command line, which if present, should trigger a printout of the prime numbers that your program has found.
For example:
$ ./sieve 1000 There are 168 primes below 1000 Search took 0 seconds $ ./sieve -v 100 List of prime numbers below 100 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 There are 25 primes below 100 Search took 0 seconds
array: 0 0 1 1 0 1 0 1 0 0 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ index: 0 1 2 3 4 5 6 7 8 9would serve to represent the list of all prime numbers smaller than ten.
Please submit your source code, Makefile, object file, and executable to your submit directory for this class. (located under /home/submit/cs210.) In addition please submit a printout of your source code to the instructor.