Assignment 1, due Jan 26

Part of the homework for 22C:169, Spring 2007
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday), and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.

  1. What is your E-mail address? (If you have more than one, give the address you'd prefer used for class purposes.)

    Real Homework!

  2. Find a C compiler, any C or C++ compiler on any computer system. Veryfy that you can actually compile programs under it and that it produces an executable object file that you can find in some file system. Name that compiler and identify the computer system on which it works. (1 point)

  3. Compile and run the C Hello World program from lecture 2. Change the program so that it contains a comment giving your name and so that it outputs your name instead of the string Hello World (see the C style guidelines cited in lecture 2 for a suggested commenting convention). Turn in a legible printed copy of this modified program. (1 point)

  4. Modify the program so that it outputs, in hexadecimal, the bytes of your string instead of outputting them as characters. To output the character ch in hex using C, use printf("%2x",ch). Add a blank space between each successive character for legibility. Again, turn in a legible printed copy. (1 point)

  5. Figure out how to modify the object file! This is certainly possible with object files on the CS department's Linux systems (I tested it), so that your name is corrupted by replacing it with a string of exactly the same length. In the extreme case, it can always be done by writing a little program that reads in the object file, modifies it, and writes it out, but the UNIX sed utility can be made to do this for you. Report on your methodology, giving details of how you did it. (1 point)

  6. Write a C or C++ function that prints out the return address of its caller, in hex. You'll have to write the function so it prints out a range of addresses, then call it several times to see what address is the return address, then narrow the range so it prints only the return address. Print out and turn in your finished function. Make sure you document what version of C or C++ it is tuned to work with. (1 point)