CS 271 Module 4 - MASM procedures & Intro to the Runtime Stack
Which of the following is true about the POP instruction?
It copies the data pointed to by the stack pointer into the operand, and then increments the stack pointer (by 2 or 4).
Which of the following is true about the PUSH instruction?
It decrements the stack pointer (by 2 or 4), and then copies the operand into the stack at the location pointed to by the stack pointer.
What advantages do stack parameters have over register parameters?
Stack parameters reduce code clutter because registers do not have to be saved and restored. Stack parameters are compatible with high-level languages.
A stack frame is _____
The area of the stack set aside for passed arguments, return address, local variables, and saved registers.
In the IA32 architecture, ESP (the stack pointer) is incremented each time data is popped from the stack.
True
In the IA32 architecture, the top item on the stack will always have a lower memory address than the bottom item.
True
Mechanically speaking, the CALL instruction pushes its return address on the stack and copies the called procedure's address into theinstruction pointer.
True
Passing by reference requires accessing a parameter's offset from inside the called procedure.
True
Which offers a more flexible approach, passing arguments to procedures in registers, or on the stack?
on the stack
Another name for a stack frame is
Actication Record
The stack frame inside a procedure is also known as the ____________.
Activation Record
Assume ESP equals 1C3Fh at Execution Point A. Trace the following code to Execution Point B, then answer the questions below: MOV EAX, 7 MOV EBX, 11 MOV ECX, 42 MOV EDX, 99 ; Nine Nine! ; Execution Point A PUSH ECX PUSH EAX PUSH EBX PUSH EDX POP ECX POP EDX POP EBX ; Execution Point B POP EAX
At Execution Point B, what is the decimal value in EBX? 11 At Execution Point B, what is the hexadecimal value in ESP? 1C3B At Execution Point B, what is the decimal value in [ESP]? 99
The RET instruction pops the top of the stack into what register?
EIP
A/An ________ procedure call occurs when a called procedure calls another procedure before the first procedure returns.
Nested
What single instruction would I use to save all general purpose registers?
PUSHAD
What instruction would I use to save the current value of the flags register?
PUSHFD
What parameter-passing method do most/all of Irvine's library procedures use?
Pass Parameters in Registers
An argument passed by reference consists of a memory address offset.
True
An input parameter may be passed by reference.
True
There are several important uses of runtime stacks in programs (select all that apply):
When calling a subroutine, you pass input values called arguments by pushing them on the stack. The stack provides temporary storage for local variables. When the CALL instruction executes, the stack is used to store the address where the called procedure will return to.
Values passed to a subroutine by a calling program are called __________.
arguments
Select the proper syntax for establishing a subprocedure.
procedureName PROC ;... ;... RET ;return to calling procedure procedureName ENDP