Write an x86 assembly language program that will prompt the user for a non–negative decimal integer nand determine whether or not n is prime. (You will need to do a bit of research regarding algorithms that can be used to test numbers to see if they are prime.) The program must display the number input and the result of the test on the screen, then prompt the user to enter another number. For example, if the user entered the numbers 7 and 100, the screen output produced by your program should appear as follows:
Enter a non–negative integer (0 to exit): 7
7 is a prime number.
Enter a non–negative integer (0 to exit): 100
100 is not a prime number; it is divisible by 2.
The input number is to be stored as an unsigned32–bit (doubleword) value(legal input is any decimal integer value between 0 and 232–1, inclusive). The program should terminate when the user enters 0and should generate an error message if the user enters non–numeric input or a negative number. The prime number test must be done in a separate procedure that is called from the main program; the single argument (the number to be checked for primality) must be passed to this procedure on the stack, and a result code must be returned to the caller in the EAX register. The value returned in EAX must be 0 if the users number is prime and must be a divisor of the users number if it is composite(if the number has multiple divisors, any one of them may be returned as proof of non–primality). In the special case that the user enters the number 1, return 1(note that the number 1 is not prime by definition, since it does not have two distinct divisors.) No other registers may be changed by the prime check procedure, so use the stack to save and restore any registers your procedure uses, other than EAX. Your called procedure must create a base pointer which is used to reference its input parameter as well as the local variables (if any) that it creates and must restore the callers base pointer before returning.
Your program must also measure the elapsed time, in milliseconds, taken to check each (legal) input value for primality. You should do this by calling Irvines GetMseconds procedure twice: once after the input is error–checked, but before the prime number procedure is called; and again, just after the prime number procedure returns. The difference between the second value and the first will give you the run time in milliseconds, assuming that you did not commence your program run shortly before midnight (correction for midnight rollover is a desirable, but not required, feature of your program). In addition to outputting whether or not the number is prime, your program should also display the run time in milliseconds for each computation. For example:
Enter a non–negative integer (0to exit): 1046527
1046527 is a prime number.
This computation took 15 milliseconds.
Enter a non–negative integer (0 to exit): 4
4 is not a prime number; it is divisible by 2.
This computation took 0 milliseconds.