Topic: The Intel x86 ISA, x86 Assembly Programming, Procedure Calls, and the Stack Frame
Related Reading: class notes and Chapter 3 (esp. sections 3.7 and 3.8)
Practice problems from the textbook (answers are at the end of the chapter):
When you turn in your assignment, you must include a signed cover sheet (PDF version) with your assignment (you're assignment will not be graded without a completed cover sheet).
You are allowed to submit your assignment via email, but if you choose to do so, you must bring a hardcopy of your assignment along with a completed cover sheet to the instructor at the next class. (Note: Do not email the instructor any .zip file attachments, as SLU's email may not accept these emails; i.e. the instructor may not receive your email.)
What operation is performed by the following sequence of instructions?
pushw %ax pushw %dx popw %ax popw %dx
Given the four major sections of a process' memory organization (Text, Data, Heap, and Stack), indicate which area each of the following are stored in:
Given the following code:
snippet: pusha pushl $100 pushl $25 pushl $7 call SomeProcedure pop %eax pop %eax pop %eax popa ret SomeProcedure: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movl 12(%ebp), %ebx movl 16(%ebp), %edx #Part D below refers to this line cmpl %ebx, %eax jle L1 subl %ebx, %eax jmp L2 L1: subl %eax, %ebx movl %ebx, %eax L2: movl $0, %ecx addl %eax, %ecx addl %ecx, %edx leave ret
With respect to SomeProcedure:
What does this procedure do? Give an equation in terms of the inputs...
What is the purpose of the pusha
and popa
instructions?
Supposing that SomeProcedure
is called from snippet
, draw the
program stack from 16(%ebp) to (%ebp) after executing instruction movl 16(%ebp), %edx
.
Also, give the contents of the registers EAX, EBX, ECX, and EDX as of the same line.
Submit via email, if you haven't already, your six in-class programming assignments.