Assignment 7, due July 11

Part of the homework for 22C:60, Summer 2005
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, 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. Consider the multiplication problems that show up in Machine Problem 3:

    ti+1 = 16807 li+1 - 2836 hi+1

    a) Give fast Hawk code to multiply by 16807. (4/10 point)

    b) Give fast Hawk code to multiply by 2863. (4/10 point)

    Hint: You will find chapter 10 of the Hawk manual (Support for Multiply and Divide) helpful here!

     
     

  2. The same machine problem requires division by 127773.

    a) To divide by 127773, you can multiply by 1/127773. What is this fraction, in conventional decimal form? (1/10 point)

    b) What is this fraction, in binary? If it cannot be represented exactly, give no more than 33 bits of precision. (6/10 point)
    Hint: The fraction begins 0.0000 0000 0000 0000 1000

    c) Give a sequence of shift and add-and-shift instructions to multiply R3 by this fraction (and therefore, to divide by 127773). (1/2 point)

     
     

  3. Write a signed integer divide routine for the Hawk. You may base this on the unsigned divide given in section 10.7 of the manual. (1 point)

 
 
 

 
 
 

 
 

 
 

 
 

 
 

 
 

 
 

Machine Problem 4, Due July 18

a) Make the program beautiful. Flaws in the top level structure of your program will make it very difficult to enhance with the features to be added later!

b) Store the locations of all of the hash marks you plotted on the display in the previous machine problem, so that you can detect when the asterisk collides with a hash mark. You'll probably want to use a global two-dimensional array to store the locations of all the hash marks.

c) If the asterisk bumps into a hash mark, the game should terminate with this message printed approximately in the center of the screen:

        +----------+
        | YOU LOSE |
        +----------+

d) If you have time, make your program fast. Improved computations in the random number generator, based on the most recent homework assignment, can make a real difference in the speed of that part of the code.

Submitting your result: Use the submit command on the department linux cluster. Your program must be named mp3.a; submit for the course c060 and the directory mp2.

Note: Your code must be in a single source file, but it will likely consist of several subroutines as well as a main program.

Grading: The usual warnings apply. Failure to include an appropriate TITLE directive will be penalized as in MP1. Up to half credit will be deducted for each of the following, depending on severity: Assembly errors, illegible or badly formatted code (these are the subject of part a above), poorly thought out logic of the solution, or failure of your program to perform as required (these are the subject of parts b and c). Poorly thought out commentary that belabors the obvious or fails to explain the obscure will cost at most one point. Finally, full credit will require significant attention to part d, but failure to do part d will cost at most one point.