1/43
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
PUSH
Push on Runtime Stack. Decrements the ESP value (the stack pointer) and then loads a source operand onto the stack's top.
POP
Pop from Runtime Stack. Loads the value from the stack's top (ESP points to this value) to the location specified by the destination operand.
PUSHAD
PUSHAD pushes eight (8) four-byte registers on the stack
POPAD
Pop All GP Registers. Pops the top 32 BYTEs from the top of the stack into eight general-purpose registers in the following order: EDI, ESI, EBP, ESP, EBX, EDX, ECX, EAX
PUSHFD
Push EFLAGS Register. Pushes the 4 BYTE EFLAGS (Status Flags) register onto the stack.
POPFD
Pop EFLAGS Register. Pops the top 4 BYTEs of the stack into the EFLAGS (Status Flags) Register.
CALL
Call a Procedure. Saves on the stack the memory location of the instruction that follows the CALL instruction, then branches to the called procedure's memory location.
RET
Return from Procedure. Pops off the return address located on the top of the stack into the EIP register (the instruction pointer).
In 32-bit mode, which register points to the top of the stack?
ESP
Why is a stack called a LIFO structure?
The last value pushed on the stack is the first value to be popped from the stack.
Assume ESP = 00F4h, and then PUSH EAX is executed. What is the new value of ESP?
00F0h
ESP is decremented by 4 (the size of EAX). 00F4h - 0004h = 00F0h
Assume ESP = 00F4h, and then POP AX is executed. What is the new value of ESP?
00F6h
ESP is incremented by 2 (the size of AX). 00F4h + 0002h = 00F6h
(True/False) The PUSH instruction can have an immediate operand.
True
(True/False) The POP instruction can have an immediate operand.
False
What directives are used to bracket a procedure?
PROC and ENDP
(True/False) If RET was left out of a procedure, execution would stop at the ENDP directive.
False
RET updates EIP to return to the calling procedure. Without it, execution will run right over the ENDP and continue to the next address in memory immediately after the procedure.
What does CALL push to the stack?
The address of the instruction immediately following the CALL instruction.
Which parameter-passing method does Irvine Library procedure ReadString use? What are the pre/postconditions, receives/returns?
Parameters are passed in registers.
Preconditions: Array is type BYTE, buffer size large enough to accommodate user input.
Postconditions: Registers changed EDX, EAX
Receives EDX (address of string buffer) and ECX (buffer size, allows user input size ECX-1).
Returns EDX (address of user string) and EAX (number of characters stored)
What does PUSH OFFSET myVar, where myVar is a data-segment variable, put on the stack?
The address of (pointer to) the memory location where the value of myVar is stored.
What does PUSH myVar, where myVar is a data-segment variable, put on the stack?
The current value in memory at the location myVar refers to.
What are some disadvantages of passing parameters using globals?
Modifying a global in a procedure modifies it outside the procedure.Use of globals makes a procedure far less modular.
Which parameter-passing method is commonly used by compilers?
Passing parameters on the stack.
If you're passing a pointer, which of the three parameter types might your parameter be classified as?
May be either an output parameter or an input-output parameter. In fact, it may even be an input parameter (for example with Irvine's WriteString).
What single instruction would I use to save all general purpose registers?
PUSHAD
(True/False) In the IA32 architecture, ESP (the stack pointer) is incremented each time data is pushed onto the stack.
False
What instruction would I use to save the current value of the flags register?
PUSHF
PUSHF is used to preserve all general purpose register contents on the stack.
False
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).
The CALL instruction functions similarly to which of the following?
Push, then Jump
ng instructions always modify the ESP register? (Check all that apply)
A stack frame is _____
The area of the stack set aside for passed arguments, return address, local variables, and saved registers.
A/An ________ procedure call occurs when a called procedure calls another procedure before the first procedure returns.
nested
(True/False) A subprocedure's stack frame contains the return address and its local variables.
True
(True/False) An input parameter may be passed by reference.
True
(True/False) Passing by reference requires accessing a parameter's offset from inside the called procedure.
True
When values are received by a called subroutine, they are called __________.
parameters
(True/False) High-level languages always pass arrays to subroutines by value.
False
(True/False) Arrays are passed by reference to avoid copying each element into the stack/registers.
True
Which offers a more flexible approach, passing arguments to procedures in registers, or on the stack?
on the stack
Where is the runtime stack located in memory?
It is located in the Stack Segment of the program's memory space (Main Memory/RAM).
Instructions that utilize the runtime stack
PUSH, POP, CALL, and RET. They all modify the ESP (Stack Pointer) register.
Consequence of improper runtime stack management
Stack overflow (running out of stack space), stack underflow (popping too many times), or corrupting the return address, which leads to program crashes.
A copy of the actual data is passed to the procedure. Changes made inside the procedure do not affect the original variable in the caller.
Passing by Value
The memory address of the variable is passed. Changes made inside the procedure do affect the original variable in the caller.
Passing by Reference/Address