Understanding Base Pointer and Stack Pointers: In Context with gcc Output

前端 未结 3 2383
时光说笑
时光说笑 2021-02-20 03:50

I have the following C program:

int main()
{
    int c[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2};
    return c[0];
}

and when compiled using the -S

3条回答
  •  独厮守ぢ
    2021-02-20 04:45

    Keep in mind that on x86 the stack grows downward. Pushing onto the stack will subtract from the stack pointer.

    %rbp <-- Highest memory address
    -12
    -16
    -20
    -24
    -28
    -32
    -36
    -40
    -44
    -48  <-- Address of array
    

提交回复
热议问题