CS 271 - Module 5 Summary Exercises

Ace your homework & exams now with Quizwiz!

When values are received by a called subroutine, they are called __________. a) variables b) parameters c) arguments d) return values

b) parameters

ESP always points to ______ a) the beginning of the stack when your program first began. b) the last value to be added to, or pushed on, the top of stack. c) the next, empty, location below the stack. d) the next, empty, location above the stack.

b) the last value to be added to, or pushed on, the top of stack.

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 EAX PUSH ECX PUSH EDX PUSH EBX POP EBX ; Execution Point B POP EDX POP EAX POP EDX 1) At Execution Point B, what is the decimal value in EBX? a) 7 b) 44 c) 99 d) 11 2) At Execution Point B, what is the hexadecimal value in ESP? a) 1C37 b) 1C47 c) 1C3B d) 1C2F e) 1C3F f) 1C33 g) 1C43 3) At Execution Point B, what is the decimal value in [ESP]? a) 7 b) 44 c) 99 d) 11

1. d) 11 2. f) 1C33 3. c) 99

What will be the value of EAX when the following sequence of instructions has executed? PUSH 5 PUSH 10 PUSH 20 POP EAX

20

What will be the value of EAX when the following sequence of instructions has executed? PUSH 5 PUSH 10 POP EBX POP EAX

5

(T/F) An input/output parameter may be passed by value.

False

(T/F) High-level languages always pass arrays to subroutines by value.

False

(T/F) In the IA32 architecture, ESP (the stack pointer) is incremented each time data is pushed onto the stack.

False

(T/F) PUSHF is used to preserve all general purpose register contents on the stack.

False

(T/F) When an argument is passed by value, a copy of the address is pushed on the stack.

False

What instruction (with any necessary operands) would pop the top 32 bits of the runtime stack into the EBP register?

POP EBP

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?

PUSHF

(T/F) A subprocedure's stack frame contains the return address and its local variables.

True

(T/F) Arrays are passed by reference to avoid copying each element into the stack/registers.

True

(T/F) Mechanically speaking, the CALL instruction pushes its return address on the stack and copies the called procedure's address into the instruction pointer.

True

(T/F) 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? a) in registers b) on the stack

b) on the stack

Select the proper syntax for establishing a subprocedure. a) procedureName PROC ;... ;... RET ;return to calling procedure procedureName ENDP b) PROC procedureName ;... ;... RET ;return to calling procedure procedureName ENDP c) procedureName PROC ;... ;... exit ;return to calling procedure procedureName ENDP d) PROC procedureName ;... ;... exit ;return to calling procedure ENDP procedureName

a) procedureName PROC ;... ;... RET ;return to calling procedure procedureName ENDP

Which of the following are normally part of the stack frame? (Select all that apply) a) Arguments b) Local Variables c) Return Address d) Calling Procedure Starting Address e) Saved Register Values

a) Arguments b) Local Variables c) Return Address e) Saved Register Values

Which of the following is true about the PUSH instruction? a) 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. b) It increments the stack pointer by 1 and copies the operand into the stack at the location pointed to by the stack pointer. c) It increments the stack pointer (by 2 or 4) and copies the operand into the stack at the location pointed to by the stack pointer. d) It copies the operand into the stack at the location pointed to by the stack pointer, and then decrements the stack pointer (by 2 or 4).

a) 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? a) Stack parameters reduce code clutter because registers do not have to be saved and restored. b) Programs using stack parameters execute more quickly. c) Register parameters are optimized for speed. d) Stack parameters are compatible with high-level languages.

a) Stack parameters reduce code clutter because registers do not have to be saved and restored. d) Stack parameters are compatible with high-level languages.

The stack frame inside a procedure is also known as the ____________. a) Activation Stack b) Activation Record c) Procedure Frame d) Program Record

b) Activation Record

What parameter-passing method do most/all of Irvine's library procedures use? a) Pass Parameters on the Stack b) Pass Parameters in Registers c) Shared memory

b) Pass Parameters in Registers

The CALL instruction functions similarly to which of the following? a) Jump, then Push b) Push, then Jump c) Move, then Jump d) Jump

b) Push, then Jump

A stack frame is _____ a) An area in the heap that is used to store global variables b) The area of the stack set aside for passed arguments, return address, local variables, and saved registers. c) The area of the text segment set aside for passed arguments, subroutine return address, local variables, and saved registers d) The area of the stack set aside for storing global strings. e) A register window pointing to local variables.

b) The area of the stack set aside for passed arguments, return address, local variables, and saved registers.

What general types of parameters are passed on the stack? a) Activation records b) Value parameters c) Stack frames d) Local variables e) Reference parameters

b) Value parameters e) Reference parameters

There are several important uses of runtime stacks in programs (select all that apply): a) The stack provides temporary storage for local variables. b) When the CALL instruction executes, the stack is used to store the address where the called procedure will return to. c) The stack makes a convenient temporary save area for registers when they are used for more than one purpose. d) When calling a subroutine, you pass input values called arguments by pushing them on the stack.

b) When the CALL instruction executes, the stack is used to store the address where the called procedure will return to. c) The stack makes a convenient temporary save area for registers when they are used for more than one purpose. d) When calling a subroutine, you pass input values called arguments by pushing them on the stack.

Which of the following code sequences assigns the value 10 to EBX? a) PUSH 20 MOV ECX, 10 PUSH ECX POP EAX POP EBX b) MOV ECX, 10 MOV EDX, 20 PUSH ECX PUSH EDX POP EBX POP EDX c) MOV EDX, 20 PUSH EDX MOV ECX, 10 PUSH ECX POP EBX POP EDX

c) MOV EDX, 20 PUSH EDX MOV ECX, 10 PUSH ECX POP EBX POP EDX

The RET instruction pops the top of the stack into what register? a) EBP b) ESP c) It does not pop the top of the stack into a register. d) EIP

d) EIP

Another name for a stack frame is a) Peripheral Memory b) Stack record c) Local storage d) Heap record e) Activation record

e) Activation record


Related study sets

prefinal: care of clients in emergency situations

View Set

Chapter 12 SCM managing inventory

View Set

OB - Chapter 11: Maternal Adaptation During Pregnancy

View Set

Chapter 11- Designing and Implementing Brand Architecture Strategies

View Set

Chapter 9 The Reproductive System

View Set