CSE 351: The Hardware/Software Interface

Winter 2015 Course Website Return home »

Homework 2: Assembly to C and Array Indexing

Assigned Monday, February 2nd, 2015
Due Date Friday, February 6th, 2015 at 5:00pm (17:00)
Submissions Submit a PDF file of your solutions here.

Introduction

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.

Logistics

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.

Questions

Answer the following problems from 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.

  1. Practice Problem 3.30, p. 223. Is the stack affected after executing these two instructions? If so, how? If not, why not?
  2. Practice Problem 3.34, p. 231.
    • Change line 2 of the assembly code to movl $-1, %eax.
    • Change line 3 of the assembly code to cmpl %eax, %ebx.
    • Redo part B with these modifications.
  3. Practice Problem 3.36, p. 234. Give the type, value, and assembly code for the expression: &S[i + 2]
  4. Homework Problem 3.56, p. 296.
  5. Homework Problem 3.69, p. 306.

Notes

Make sure you are using the second edition of Computer Systems: A Programmer's Perspective, ISBN: 978-0-13-610804-7. If you're not using the right book, you might be doing the wrong problems! Here is a pdf file of the relevant pages of the textbook for use on this assignment, in order to eliminate issues with students having a different version of the book.

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.