|Assigned:||Monday, October 31|
|Due:||Monday, November 7, 11:59PM|
Work individually. Submit your answers by email. Any clarifications and revisions to the assignment will be posted on the course help system.
In this homework, you will examine assembler output from gcc in order to determine the original C code. This was generated in 64bit using the same version of gcc in the TLab.
to a working directory on your Unix box, and execute the command
tar xvf hw2.tar. You should get the following files:
gcc -Wall -S code.c -o code-unopt.s)
gcc -Wall -c code.c -o code-unopt.o)
gcc -Wall -O -S code.c -o code-opt.s)
gcc -Wall -O -c code.c -o code-opt.o)
Your goal is to figure out what C code was in code.c and replicate it in code-handin.c. The function definitions in code-handin.c are currently empty. You have to write them. It will probably easiest to do so by studying the contents of code-unopt.s and code.h, and playing with the compiled code using test.c. The purpose of giving you code-opt.s and code-opt.s is to give you an idea of what a compiler will do differently when optimizing. These files are not needed to complete the homework.
When you run make, you will generate code-handin.s, code-handin.o, test-with-handin, and test-with-handout. code-handin.s and code-handin.o are the assembly and object code for code-handin.c, i.e., the code that you've written. test-with-handin is an executable of test.c that's linked with your code-handin.o. test-with-handout is an executable of test.c that's linked with code.o, the compiled version of the unknown source code. You might also find it useful to compare your code-handin.s with code-unopt.s.
You can do your code development using any system or compiler you choose. Just make sure that the version you turn in compiles and runs correctly on our class machines. If it doesn't compile, we can't grade it.
Some of the code is floating point. Documentation on floating point is in ASM:X87 on the book's web asides page for the 2nd edition.
Hand In Instructions
- Email just the file code-handin.c.
- Put comments identifying yourself at the start of the code file.
- Document in those comments any significant discrepancies you were unable to resolve between what your code does versus what the original code does.
- Email to c-riesbeck in the grand domain of northwestern.edu. Put 213 Homework HW2 in the Subject line.