Function Parameters and Stack

Learn about function parameters and stack structure.

Function parameters example

This lesson discusses how a caller function passes its parameters via registers and how a callee (the called function) accesses them.

Here is the source code for the example:

Press + to interact
// FunctionParameters.cpp
int arithmetic (int a, int b);
int main(int argc, char* argv[])
{
int result = arithmetic (1, 1);
return 0;
}
// Arithmetic.cpp
int arithmetic (int a, int b)
{
b = b + a;
++a;
b = b * a;
return b;
}

Stack structure

The registers, x0x29, are used to address stack memory locations. Here, we provide a typical example of the stack memory layout for the following function where the x29 register is used: ...

Access this course and 1400+ top-rated courses and projects.