Suppose I have a very simple C program that just does this:
int i = 6;
int j = 4;
int k = 5;
int a = i + j + k;
Since i
, j
, and k
are on the stack, they will be located relative to the stack pointer. I am told the compiler determines these relative locations; my guess is the compiler translates int a = i + j + k
into "Add the values located at (stack pointer - 3x), (stack pointer - 2x), and (stack pointer - x) and push the result to the stack." Am I correct?