Homework 2: Assembly to C and Array Indexing
|Assigned||Saturday, October 31, 2015|
|Due Date||Friday, November 6, 2015 at 17:00|
|Submissions||Submit a PDF file of your solutions here.|
The purpose of written homework assignments is to get you thinking about the topics being covered in lecture and in readings in the textbook which are not represented in the hands-on, programming lab assignments. These written assignments also better prepare you for course examinations. It is worth noting that the book contains many practice problems similar to the problems we ask on these written assignments! The solutions for those practice problems are located at the end of each chapter and should give you a feel for the kind of answers we expect you to turn in for these kind of assignments.
Please write up your answers and submit them as a PDF file in the online dropbox. This simplifies our grading and ensures we read your answers clearly. If you don't know how to create a PDF, a quick internet search should help, or ask us.
We will provide solutions to all of the problems in the written homework assignments in a timely fashion after the assignment is due. This may be around 4 or 5 days after the due date, in general, because a student may use up to 3 late days on an assignment.
Make sure you are using the 3rd edition of Computer Systems: A Programmer's Perspective. If you're not using the right book, you might be doing the wrong problems!
Answer the following problems, some from the 3rd edition of the textbook. Notice that several of these problems are practice problems. If a practice problem is listed, try to solve the problem on your own first, then check your answer at the end of the chapter. Make sure you understand the solution provided, then complete the additional questions we ask about the practice problem below. Your write-up only needs to contain the information necessary to understand your answer to the *additional questions listed here* - you do NOT need to turn in the answer to the practice problem in its entirety.
- Practice Problem 3.2, p. 185. What is the appropriate
instruction suffix for:
mov__ (%rdi), %eax?
- Practice Problem 3.3, p. 186. (Note that there are a
few typos in the
solution to this problem on p. 326) Describe a problem
movq %eax, (%rsi).
- Practice Problem 3.6, p. 192. What is the result stored in
%rdx for this instruction:
leaq (%rax), %rdx.
- Practice Problem 3.8, p. 194. Assuming the state of registers
and memory after all of the instructions in the problem have been
executed, describe the destination affected and the value placed
there by this instruction:
leaq (,%rax,2), %rcx.
- Practice Problem 3.37, p. 258. Give the type, value, and
assembly code for the expression:
&S[2i + 1]
- Homework Problem 3.60, p. 312. Notice that there is a typo in the partially filled-in C code on p. 313 - parameter n should be of type int.
Submitting Your Work
Please turn in a PDF file containing your answers to the Catalyst Drop Box for this assignment. We will not accept submissions that are not in PDF format.