Chapter 5 - Procedures Flashcards
(69 cards)
What are procedures also known as?
Subroutines and functions.
What is the structure of a stack?
LIFO (Last In, First Out).
Which registers manage the runtime stack?
SS (stack segment) and ESP (stack pointer).
What does the ESP register hold in 32-bit mode?
A 32-bit address in the stack.
What happens during a 32-bit push operation?
ESP is decremented by 4 and a value is copied into the location pointed by ESP.
What does a pop operation do?
Returns a copy of the value in the stack and increments the stack pointer.
What is the syntax for a 32-bit PUSH operation?
PUSH r/m32 or PUSH imm32.
What is the effect of a 16-bit operand in PUSH operation?
ESP is decremented by 2.
What is the purpose of the PUSHFD instruction?
To push the 32-bit EFLAGS register on the stack.
What is the structure of a procedure declaration in assembly?
PROC and ENDP directives with a name.
What does the CALL instruction do?
Pushes the return address on the stack and copies the called procedure’s address into EIP.
What does the RET instruction do?
Brings the processor back to the point where the procedure was called.
What is a nested procedure call?
When a called procedure calls another procedure before returning.
What is the difference between local and global labels?
Local labels are visible only inside the same procedure; global labels are visible everywhere.
What is the purpose of parameters in procedures?
To make procedures flexible and usable in different contexts.
What does the USES operator do?
Lists registers to be saved and restored within a procedure.
What is the structure of the ArraySum procedure?
Calculates the sum of an array of 32-bit integers.
What is a link library?
A file containing compiled procedures from one or more OBJ files.
What is the purpose of the INCLUDE directive?
To copy in procedure prototypes into the source code.
What does the Crlf procedure do?
Writes the end of line sequence to standard output.
Fill in the blank: The first instruction executed in a procedure is the _______.
CALL instruction.
True or False: The stack grows upward in memory.
False.
What does the DumpMem procedure do?
Writes block of memory to standard output in hex
What is the purpose of the GetCommandtail procedure?
Copies command-line args into array of bytes