Question: OBJECTIVE Write a program to find prime numbers in a range of numbers, start from number 2. BACKGROUND: Prime Numbers Prime numbers are positive integers


OBJECTIVE Write a program to find prime numbers in a range of numbers, start from number 2. BACKGROUND: Prime Numbers Prime numbers are positive integers that are exactly divisible only by themselves and 1. There are many methods for computing prime numbers, but one of the simplest and most elegant was discovered by an ancient Greek named Erathosthenes. His algorithm, called the "Sieve of Erathosthenes, proceeds like this: 1. List all the positive integers, in ascending order, over the range you wish to search. Let's start with 2: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2. Let your first current prime number be 2. We know 2 is prime. 3. Starting at the current prime number initially 2), step by that number of positions. Now change the value you just reached to 0. Keep stepping by the current prime and zeroing until you reach the end of the range. Our example now looks like this: 2 30 50 7 0 9 0 11 0 13 0 15 4. Now find the next nonzero number (3) in the list. Repeat step (3) with this step size. The example is: 2 3 0 5 0 7 0 0 0 11 0 13 0 0 5. Repeat steps (3) and (4) until you finish the list. 6. The nonzero numbers left are prime numbers. (No division is necessary!) REQUIREMENT a. Write a MSP430 assembly language program to find all prime numbers between 2 and 150, inclusive, using the Sieve of Erathosthenes. o Put the original numbers (2-150) into memory start from address 0x1200 (each number is a word size: 0x0002, 0x0003, ...), then use Sieve of Erathosthenes (steps 1-6) zeroing out the non-prime numbers, only the prime numbers remain in the memory. b. Put the resulting prime numbers into memory, start from 0x2000. c. Count how many prime numbers were found in range 2-150, and put the result in R8. WHAT TO SUBMIT You need to submit two files: 1. Your commented course code (.asm file). 2. A PDF file includes o a written description of your approach o a flowchart o a screenshot of the memory range including 0x1000 - 0x1D50 proving your results o a screenshot of the memory range including 0x2000 - Ox2050 proving your results o a screenshot of your registers (RO-R15) at the end of the execution o a written description of your results
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
