Assignment 10, due Nov. 6

Part of the homework for 22C:60, Fall 2009
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). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!

Problems

  1. Background: In the long-integer package for mp4, there are methods for both comparison and subtraction.

    A question: Explain why long comparison has the potential to be faster than subtraction. (0.5 points)

  2. Background: In the long integer package from mp4, all the arithmetic routines operate on their first parameter and return that parameter as a result, so longadd(a,b) adds the long integer pointed to by b to the long integer pointed to by a and returns the pointer a.

    A question: Assuming that X, Y, Z are local variables, each holding a long integer, write Hawk code equivalent to the following expression in a high level language: X = 100*Y + Z. In your code, take maximal advantage of the background information presented above. Your code must, of course, be well commented. (0.5 points)

  3. Background: Long ago (in the 1970's) Bell Labs was experimenting with ways to digitize sound. Long term results of this included little things like MP2 and MP3, but early in the process, they talked about storing sound as a string of floating-point values, using 8 bits per value. Each floating point value in the proposed number system had the following fields:
            S E E E M M M M
             S - the sign of the mantissa
             E E E - the 3-bit exponent, biased
             M M M M - the 4-bit mantissa, with a hidden 5th bit
    

    The normalization rule is the common one for binary floating point numbers: the mantissa is strictly less than one and greater than or equal to 0.5, so that the hidden bit is always 1 -- and therefore, need never be stored. This number system has no NaNs and no unnormalized values, so the exponent values run over the entire range from 000 to 111.

    a) What is the largest value that can be represented in this number system? Give both the binary representation and the decimal equivalent. (0.3 points)

    b) What is the binary representation of 1.0 in this number system? (0.2 points)

    c) What is the smallest positive nonzero value that can be represented in this number system. Give both the binary representation and the decimal equivalent. (0.3 points)

    d) Explain the problem this number system poses for the representation of zero? (0.2 points)

  4. A Problem: Write a SMAL Hawk assembly code fragment that, when given an 8-bit floating-point number int the format given above in R3, breaks it up and puts the exponent field in R4, converted to a 32-bit 2's complement value, and the mantissa in R5, also converted to a 32-bit 2's complement value, with 5 places after the point. (1.0 points)