Before we begin our exploration into assembly language, I would like for you to write a C program that accomplishes the following (we will be creating a program of similar functionality in assembly language):
Some tips:
For example:
lab46:~$ ./my_prime Enter upper range: 12 2: Prime 3: Prime 4: Composite 5: Prime 6: Composite 7: Prime 8: Composite 9: Composite 10: Composite 11: Prime 12: Composite lab46:~$
The goal is, once we have a working C version, to eventually create an assembly version that works the same way and produces identical output.
Often times it is extremely beneficial to have a working algorithm in a higher level language as a basis for comparison when delving into a new programming environment.
When you are done, and prior to submitting, you may want to verify that your code will work when evaluated.
To do so, you can follow the following steps–
To wit:
lab46:~/src/asm/prime$ gcc -o prime prime.c lab46:~/src/asm/prime$
If, when compiling it with gcc, it just returns a command-line, without saying anything, you will likely be okay.
After you've successfully compiled it, you will want to check your program's output against the master.
To check this, do the following:
lab46:~/src/asm/prime$ ./prime < /var/public/asm/prime_input.txt > output.txt lab46:~/src/asm/prime$ diff /var/public/asm/prime_output.txt output.txt lab46:~/src/asm/prime$
Again, if all you get is your prompt back, then your program's output matches the master copy, and all should be good in the universe… assuming there are no further logic problems with your program, you should consider your program ready for submission.
If not, then take the necessary steps to bring your program into alignment before submitting. You only get one chance to submit.
When you are finished with your program and ready to submit, you will want to copy it into your data/submit directory, before the deadline.
Assuming a program name of prime.c, one could submit it as follows:
lab46:~/src/asm/prime$ cp prime.c ~/data/submit
And that's it! Remember to submit your source code only, and make sure it compiles and runs.
After about a minute, assuming everything goes according to plan, you should have a results.asm.projects file appear inside ~/data, which you can cat to see your results.
Your program will be compared against the master, with a randomly chosen prime number at some range starting in the triple digits.