Question: Assignment # 5 : Prime numbers are pretty well distributed. Starting at 3 ( we will ignore 2 as it's the only even prime )

Assignment #5:
Prime numbers are pretty well distributed. Starting at 3(we will ignore 2 as it's the only even
prime), the distance between the first two primes (3 and 5) is 2, the distance between the next two
primes (5 and 7) is also 2 and the distance between the next (7 and 11) is 4, the distance between
the next two primes (11 and 13) is 2 again. So the question I want you to answer is what is the
maximum distance between two consecutive primes over a range, for instance between 3 and 100?
This would be a trivially easy program to write in C or another high level language, but here you
have to capture all the logic in Intel assembly. C code should only be used to declare variables at
the beginning of the program and output the results at the end. Your output should be the two
consecutive primes found and the distance between them. For instance, from 3 to 99 the output
should be something like:
The maximum distance is 8 found between 89 and 97
Write the program in C first so you can see how it works. Then, convert your C code into Intel
assembly. Note: you might find it easier to write an isPrime-like function in your C code but when
it comes to assembly, only have a main function (do not write any other functions).
Test your program on the range from 3 to 99 and you should get the results shown above. When
done, run your program on 3 to 999,3 to 49999 and 3 to 999999(this run may take a couple of
minutes to execute). Collect all three outputs and paste them at the bottom of your code.
Assignment #6:
Implement the Bubble Sort in assembly code. Your program should declare all variables, including
initializing your array, in C, enter assembly to perform the entire sort, and then after exiting the
assembly block, use a C for loop to output the results. The Bubble Sort is given below in
pseudocode. Run your program on both lists of numbers below (hardcode the numbers in your
program, do not use any input), collect the outputs and paste them at the bottom of your code.
Array 1: 80,65,33,45,20,86,97,22,21,30,84,66,98,12,74,89,92,37(n=18)
Array 2: 30,28,25,24,22,20,19,18,16,14,13,12,11,10,8,7,6,4,3,1(n=20)
Assignment # 5 : Prime numbers are pretty well

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!