Upload a pdf file containing your solutions to the problems below to Learning Suite before 11:00pm on the assigned date.
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:
imulq S,D
)
shown in table 3.10 on page 192 writes the lower 64-bits
of the 128-bit product to the destination register and discards
the upper 64-bits. This is the instruction used in the homework
problem.
imulq S
)
shown in table 3.12 on page 198 writes the result of the 64-bit
by 64-bit multiply (a 128-bit product) to registers
%rdx
(for the upper 64-bits) and
%rax
(for the lower 64 bits).