Linkage
In this assignment, you will put together a program that has parts written in C and parts written in assembly, and explore linkage between object files.
Requirements
Your program must contain code in both C (in a .c file) and x86-64
assembly (in a .s file). You must have a header (a .h file) to
provide C declarations for your globals.
You must have a global variable either defined in C and used in assembly, or vice versa. (Either way, declare it in the header.) You must use a static variable or function somehow; it can be in either C or assembly.
Your assembly code must define a function that takes parameters and produces a return value, and which uses jumps to implement some form of control flow. That function must be declared in the header and called from the C code, which must use the return value in some user-visible way.
Other than that, your program may perform any task, similar to the Interactivity and Memory assignments. You may extend your program from them, adding the required features, or you can write a new program based on another idea. (This program does not have to have the features required for other assignments; e.g. there is no need for file I/O or dynamic memory if they don't help this program.)
Submit your work in the form of a .tar.gz archive that unpacks to
contain a directory with the same name as the archive with the extension
removed. All of your files must be in that directory, including a
Makefile such that make or make all builds your program, and
make clean deletes any files produced by the build. If you want,
there may also be a text or pdf file that describes your program and
anything a user might want to know about how to use it. Any files you
create that your program needs to exist when it runs should also be
included in the archive.
Remember, no matter how easy or difficult you think your idea will be for you to implement, start out so easy it's trivial and add functionality slowly but surely. That way, an ambitious idea that you can't quite achieve results in a working program that does less than you'd hoped, rather than a broken program. Any program that can build and run without crashing and meets the requirements above counts for fulfilling the learning outcomes of the assignment.
Sources of ideas
Optionally, if you want to add something extra, choose a computation
for the assembly portion of your program that has a good reason to be
written in assembly rather than C. You might use the cpuid instruction
(not available in C), leverage that div produces both quotient
and remainder in one instruction (while C has separate / and %),
perform single-operation multiple-data (SIMD) parallelism exploiting
the XMM registers, etc. Anything where you can do something better in
assembly or even only in assembly, which you then make available to call
from C. This is not expected for satisfying the learning outcomes of
the assignment, but it would count as something else impressive.
You may base your idea on a description or code you find, and even refer to existing source code to guide the design of your work, but in the end you must set other material aside and write your own program. If you use any found material in any way, you must cite it. Citations can appear in the source code in comments, or collected in another file in your project directory. You may use any citation format, as long as it includes the title (if applicable), author, and a reference such as a link that is sufficient for somone else to find a published copy of the work. You might also include a brief description of how you used the source.