ECEn 324 Homework Set #2

Submit your (hardcopy) solutions to the problems below in the homework box by 5:00 PM on the assigned date.

  1. Consider the C code below.
         #include <stdio.h>
    	 float f,g;
    	 f = 0.0;
    	 g = f + 1.0;
    	 while (f != g)
    	     f = g;
    	     g = f + 1.0;
    	 printf("Does it ever get here?\n");
  2. Problem 2.86
  3. Problem 2.92
  4. Problem 3.54
  5. Problem 3.55


Problem 2.86: No code is required for this problem.

For problem 2.92, here is some code to help you with testing. Of particular interest, it provides functions that convert between unsigned numbers and floating point numbers without changing the underlying bit representation.

Problem 3.54: You should write C code for the decode2() function, compile it, and study the assembly code produced. You don't need to write any other C code (to test the correctness of the function by calling it and comparing results, for example). Therefore, your submission should include your C source code and the corresponding assembly code. Note that it is not always possible to exactly match compiler-generated code, particularly with a different version of the compiler. If you can't match it exactly after a reasonable number of attempts, come as close as you can and discuss the differences. Remember, code examples in the book are generally compiled with a -O1 optimization flag (see Section 3.2). This may help when trying to match assembly code.

Problem 3.55: No code is required. Looking at Practice Problem 3.12 and its solution can be quite helpful.

Last updated 2 May 2013