CSE 351: The Hardware/Software Interface

Summer 2013 Course Website Return home »

Homework 2: x86 Control Flow, Stacks and Procedure Calls

Assigned Monday, July 15, 2013
Due Date Wednesday, July 24, 2013 at 11:00pm (23:00)
Submissions Please turn in a PDF with your solutions here.
Solutions posted 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

Since these written homeworks are not programming lab assignments, you will turn in your assignment online as electronic documents in PDF format. We will not accept any paper submissions.

We will provide solutions to all of the problems in the written homework assignments in a timely fashion after the assignment is due.

Questions

Answer the following problems from the textbook. 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 below. For all Practice Problems except 3.31, your write-up only needs to contain the information necessary to understand your answer to the additional questions listed on this page -- you do NOT need to turn in the answer to the practice problem in its entirety.

  1. Practice Problem 3.30. Is the stack affected after executing these two instructions? If so, how? If not, why not?
  2. Practice Problem 3.31 - Please turn in your answer to the problem itself.
  3. Practice Problem 3.33. Review the Aside on p. 226 to understand why GCC allocates unused space on the stack. If we wanted to eliminate the unused space in proc's stack frame regardless, how would you change the assembly code to do this?
  4. Practice Problem 3.42: What was your strategy (if any) to reduce wasted space? Would this always work? If not, can you describe a general strategy such that the space the struct uses is minimized?
  5. Practice Problem 3.51. What value is returned if the function is called with i=6?
  6. Homework Problem 3.59 (Looking at the previous problem may be helpful)
  7. Homework Problem 3.64

Notes

Make sure you are using the 2nd edition of Computer Systems: A Programmer's Perspective. If you're not using the right book, you might be doing the wrong problems!

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.