CS 202 - Homework 4 - 10/1/07

Due: Monday, 10/08/07, in class (or by 2pm the latest)

This assignment has a written part and a programming part. Please hand in your written answers together with printouts of your programs. Also, submit your programs electronically (see below). On the first page of your submission, please write your own name as well as the names of the students with whom you collaborated.
  1. Do the following "practice problems" from the Bryant and O'Hallaron text:
    1. Practice problem 3.1 (p. 138)
    2. Practice problem 3.3 (p. 143-144)
    3. Practice problem 3.4 (p. 145)
    4. Practice problem 3.6 (p. 147)
    5. Practice problem 3.8 (p. 155)

  2. Write Pentium assembly functions that take two integer arguments a and b and return
    1. The (integer) average of a and b.
    2. The maximum of a and b.
    3. The argument whose absolute value is larger. Examples: (2, 3) -> 3; (2, -3) -> -3; (-100, -3) -> -100.
    4. The sum a + (a+1) + (a+2) + ... + b, or 0 if a > b
    5. The number of ones in the binary representation of a. Examples: a=3 -> 2; a=15 -> 4; a=16 -> 1; a=-1 -> 32.
    Call your assembly functions "avg", "max", "maxabs", "sumseq", and "countbits", respectively, and store them using corresponding filenames with the extension ".s". A "driver" program named hw4.c to call your functions and print their results is provided in my directory ~schar/cs202/hw4/ on the CS machines.

  3. How much time did it take you to complete this assignment?

Electronic submission

Make sure that all your files for this assignment are in one directory. Then, go to this directory and type
  ~schar/bin/submit202
This will copy all files in your current directory and store them in my account. You can resubmit your files as many times as you want - only the newest submission will be kept. The final deadline for both paper and electronic submission is Monday, 2pm. Note: please use the file names and function names that are specified in this document! This will help me grade your files.