ECEn 424 Homework Set #2

Upload a pdf file containing your solutions to the problems below to Learning Suite before 11:00pm on the assigned date.

  1. Problem 2.87
  2. Problem 2.93
  3. Problem 3.58
  4. Problem 3.59
  5. Problem 3.60

Clarifications

Problem 2.87: No code is required for this problem.

For problem 2.93, 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.58: 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.59: No code is required. Before tackling this problem, take a careful look at the example on pages 198-199. You will find that the imulq instruction is described on page 198 in the text, but perhaps not as clearly as one might like, so here's more to go on. There are actually two distinct versions of this instruction:

Problem 3.60: Your submission should include answers to parts A through E for the problem from the book. For part F, create a file with your best guess as to the original loop() function and compile it to assembly (use the "-S" and "-m64" flags, and use different optimization levels to match the assembly code in the book as closely as possible). Your submission should include your C source file, the resulting assembly code for the function, and the compiler options you used. (You don't have to run your code or show any execution results.) As a convenience, you can get the assembly code to annotate here if desired.


Last updated 16 January 2018