CSCI 431 Homework 1

time due submission file
10:25 PM Friday 26 August, 2005 csci/431/HW1/Assignment1

A bit more on the submission details

This homework is due at 10:25 PM, the beginning of class, on Friday, 26 August, 2005. You turn the program in by copying it to the file csci/431/HW1/Assignment1 on busbee.cs.unca.edu, the UNCA Computer Science server.

The Department requires an SSH-enabled FTP for the transfer. If you need help doing this from a Windows computer, look at Section 5 of the UNCA CSCI 107 lab on files and directories.

The assignment

Download the ZIP file Home1.zip and examine its five files.

First compile the C++ and Java programs and run them on a Linux computer. I suggest you use the make command for the C++ program, but it would also be a good idea to study the commands of Makefile for hints about completing the remainder of the assignment.

Open the file Assignment1 and record the sizes of the object (.o), class, and executable (DPdriveC) files produced by this compilation.

Next, we're going to look at the machine code produced by the compilation of the C++ programs. Use the -S option of the g++ compiler to examine the Intel assembly code produced in compiling DotProduct.cpp. Pay attention to how the stack (%esp) and base (%ebp) pointers are used to maintain the stack frame for DotProduct. Also, look for the local variables on the stack. This is all very similar to the way C subroutines were implemented in chapter 14 of your CSCI 255 textbook, so you should be on familiar ground.

Add a bit more to Assignment1 about your latest discoveries.

This time, compile DotProduct.cpp with optimization turned on using the the -O2 option. You'll notice that the compiled code is considerably smaller. Again, write about your observations in Assignments1.

Now, instead of compiling DPdrive.cpp, use the -E option of g++ to run the C++ preprocessor. Remark on the output of the preprocessor in Assignment1. You should be impressed by the amount of code it produces to compile a 17-line C++ program.

We have one last task for the C++ program. Let's look at the executable file DPdriveC. Use the Linux program readelf with the -S option to display the section headers. Get on the Internet and Google for elf format to learn a little about this popular way of storing executable files. Then use the Linux program ldd to list the shared libraries used by DPdriveC. Once again, report on your findings.

Finally, turn to the Java program. Use the -c option of the javap program to examine the Java "bytecode" generated by the Java compiler. Make one final entry into Assignment1.

One last thing

Be sure to transfer your file.