Skip to main content
2 of 4
deleted 320 characters in body
moonman239
  • 2.1k
  • 4
  • 19
  • 26

In x86, where are the memory addresses of the values on the stack located?

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 that to the stack."

moonman239
  • 2.1k
  • 4
  • 19
  • 26