1/22
Flashcard collection reviewing CPU runtime stack operations, procedure creation, register management, external linking, Irvine32/Irvine64 library calls, and the x64 calling convention.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What fundamental data structure concept describes the behavior of the CPU runtime stack?
A Last-In, First-Out (LIFO) structure where elements are added to and removed from the top.
Which CPU registers manage the runtime stack in 32-bit protected mode?
SS (stack segment) and ESP (stack pointer).
How does a 32-bit PUSH operation affect the stack pointer (ESP)?
It decrements ESP by 4 and copies the source value into the memory location pointed to by ESP.
In which direction does the x86 runtime stack grow in memory?
The stack grows downward toward lower memory addresses.
How does a POP operation alter the stack pointer (ESP)?
It copies the value located at stack[ESP] into a destination register or variable, then adds 2 or 4 to ESP depending on operand size.
Why must character values be moved into EAX before being pushed onto the stack when reversing a string?
Because the stack only accepts word (16-bit) or doubleword (32-bit) values.
In what relative order must POP instructions be executed when restoring registers saved with PUSH instructions?
POP instructions must be executed in the exact opposite order of the PUSH instructions.
How is the loop counter preserved when implementing nested loops in x86 Assembly?
The outer loop counter in ECX is pushed onto the stack before starting the inner loop and popped back into ECX after the inner loop completes.
Which assembly instructions are used to push and pop the EFLAGS register?
PUSHFD and POPFD.
In what order does the PUSHAD instruction save the general-purpose registers onto the stack?
EAX, ECX, EDX, EBX, ESP, EBP, ESI, and EDI.
What directives mark the beginning and ending of a procedure in MASM assembly?
PROC marks the beginning and ENDP marks the end.
What four standard documentation fields are recommended in a procedure header comment block?
Description, Receives, Returns, and Requires (preconditions).
How do the CALL and RET instructions manipulate the Instruction Pointer (EIP)?
CALL pushes the return address (offset of the next instruction) onto the stack and loads the procedure's starting address into EIP; RET pops the return address off the stack back into EIP.
What happens to the stack when nested procedure calls take place (e.g., main calls Sub1, Sub1 calls Sub2, and Sub2 calls Sub3)?
The stack holds the return addresses of all active nested callers, with the most recent return address at the top pointed to by ESP.
What is the key difference between a local label and a global label inside a procedure?
A local label is visible only to code inside its own procedure, whereas a global label (defined with ::) is visible across the entire program.
How does the USES operator assist in register preservation inside a procedure definition?
It specifies registers to be saved and automatically generates PUSH instructions at the start of the procedure and reverse-order POP instructions before RET.
What sequence of steps creates a static link library (.LIB) file from assembly source files?
Assemble ASM source files into OBJ files, create an empty .LIB file, and add the OBJ files to the library using the Microsoft LIB utility.
Which Irvine32 library procedure pauses execution for a specified duration in milliseconds?
Delay.
Which Irvine32 library procedure displays all general-purpose registers and flags in hexadecimal format?
DumpRegs.
How is the color attribute calculated when using SetTextColor in the Irvine32 library?
The background color is multiplied by 16 and added to the foreground color.
In 64-bit assembly programming, which register receives the returned length when calling Str_length from Irvine64?
RAX.
Which registers are used to pass the first four integer or pointer arguments in the x64 Calling Convention?
RCX, RDX, R8, and R9.
What are the stack allocation and alignment requirements under the x64 Calling Convention?
The caller must allocate at least 32 bytes of shadow space on the stack, and the stack pointer must be aligned on a 16-byte boundary.