Assembly Language for x86 Processors - Chapter 5: Procedures

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/22

flashcard set

Earn XP

Description and Tags

Flashcard collection reviewing CPU runtime stack operations, procedure creation, register management, external linking, Irvine32/Irvine64 library calls, and the x64 calling convention.

Last updated 12:45 PM on 9/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

23 Terms

1
New cards

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.

2
New cards

Which CPU registers manage the runtime stack in 32-bit protected mode?

SS (stack segment) and ESP (stack pointer).

3
New cards

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.

4
New cards

In which direction does the x86 runtime stack grow in memory?

The stack grows downward toward lower memory addresses.

5
New cards

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.

6
New cards

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.

7
New cards

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.

8
New cards

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.

9
New cards

Which assembly instructions are used to push and pop the EFLAGS register?

PUSHFD and POPFD.

10
New cards

In what order does the PUSHAD instruction save the general-purpose registers onto the stack?

EAX, ECX, EDX, EBX, ESP, EBP, ESI, and EDI.

11
New cards

What directives mark the beginning and ending of a procedure in MASM assembly?

PROC marks the beginning and ENDP marks the end.

12
New cards

What four standard documentation fields are recommended in a procedure header comment block?

Description, Receives, Returns, and Requires (preconditions).

13
New cards

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.

14
New cards

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.

15
New cards

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.

16
New cards

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.

17
New cards

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.

18
New cards

Which Irvine32 library procedure pauses execution for a specified duration in milliseconds?

Delay.

19
New cards

Which Irvine32 library procedure displays all general-purpose registers and flags in hexadecimal format?

DumpRegs.

20
New cards

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.

21
New cards

In 64-bit assembly programming, which register receives the returned length when calling Str_length from Irvine64?

RAX.

22
New cards

Which registers are used to pass the first four integer or pointer arguments in the x64 Calling Convention?

RCX, RDX, R8, and R9.

23
New cards

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.