Homework 3

CS 220

50 points, due Oct. 17, 1997

  1. (15 pts.) Represent the decimal values 26, -37, 497, and -123 as signed, 10-bit numbers in the following binary formats:
    1. sign and magnitude.

    2. 1's complement.

    3. 2's complement.

  2. (15 pts.) Consider a ``downsized'' IEEE FP standard for 12-bit FP numbers. The exponent is a 5-bit bias 15 number and the fractional mantissa is 6 bits.
    1. Represent the decimal numbers 1.7, -0.012, 19, and 0.125 in this format.

    2. What are the smallest and largest numbers representable in this format?

    3. How does the range calculated in part (b) compare to the ranges of a 12-bit signed integer and a 12-bit signed fraction?

  3. (5 pts.) Some computers have explicit instructions to extract an arbitrary field from a 32-bit memory word and place it in the least significant bits of another memory word, like this:

    Find the shortest sequence of SAL instructions that extracts a field for the constant values i=7 and j=19 from the word variable source and places it in the word variable destination.

  4. (5 pts.) Determine the minimal SAL instruction sequence which will swap two word variables, say i and j, without using any other variables.

  5. (10 pts.) Joe Pro designed a new CPU chip, forgetting to implement any arithmetic/logic instructions other than or, add, and sub. He used 2's complement integer representation. Help Joe to find the shortest sequence of instructions to perform the not and and bit operations.



Thomas P. Kelliher
Tue Oct 7 18:47:40 EDT 1997
Tom Kelliher