1/21
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Calling a Sequence
The set of actions taken by a program to transfer control to a subroutine and back.
Function Arguments
Return Values
Call Stack
Calling a sequence includes managing ________, ________, and ________.
Caller Responsibilities
Callee Responsibilities
Steps in a Calling Sequence.
Caller Responsibilities
The function that requests another function to execute.
Save necessary registers and program state.
Push arguments onto the stack or into registers.
Jump to the function's address.
Caller is responsible for
Save necessary registers and program state.
Registers are small, fast storage locations inside the CPU.
Push arguments onto the stack or into registers.
The caller prepares the information required by the function.
Jump to the function's address.
The program transfers control to the function being called.
Callee Responsibilities
The function being called.
Allocate space for local variables.
Execute the function body.
Store the return value.
Restore the caller's state and return control.
The callee is responsible for.
Allocate space for local variables.
The function may need temporary memory for its own variables.
Execute the function body.
The instructions inside the function are performed.
Store the return value.
If the function produces a result, it prepares that result for the caller.
Restore the caller's state and return control.
The function completes its work and transfers control back to the caller.
Call Stack
A memory structure used to manage active function calls.
Last In, First Out (LIFO)
Call stack follows this principle.
Stack Frame
Each active function call generally has a _________, which may contain its return address, saved registers, local variables, and other information.
Calling Conventions
Specifies how arguments are passed, return values are handled, and the stack is managed.
CDECL
STDCALL
FASTCALL
Three common calling conventions.
CDECL
In the traditional 32-bit x86 CDECL convention, the caller cleans up the arguments it placed on the stack.
STDCALL
n traditional 32-bit x86 STDCALL, the callee cleans up its stack arguments.
FASTCALL
Passes some function arguments through CPU registers rather than relying entirely on the stack.