# Do Stack frames grow upwards?

I am currently learning RE and I came upon this piece of code which made me question whether stack frames grow upward:

``````0x080483f4 <main+0>:    push   ebp
0x080483f5 <main+1>:    mov    ebp,esp
0x080483f7 <main+3>:    and    esp,0xfffffff0
0x080483fa <main+6>:    sub    esp,0x60
0x080483fd <main+9>:    mov    DWORD PTR [esp+0x5c],0x0
``````

So I understand that from `<main+0>` until `<main+6>`, we're setting up the stack frame. Being that the stack grows downwards, it makes sense that we `sub esp,0x60` thereby allocating 96 bytes for the main function's stack frame.

My confusion/doubts, however start on `<main+9>` `mov DWORD PTR [esp+0x5c],0x0` which from what I understood stores the value `0` in a location 4 bytes above the stack pointer and we know that the stack grows downwards, but this operation seems to indicate that the data in the stack frame is stored bottom up.

So my question is, does that mean that while the stack as a whole grows downwards individual stack frames actually grow upwards?

In order to see what is going on, let's use the value of `0x1080` for the initial `sp`.

The stack pointer at the beginning:

``````esp -> 0x1080
``````

after `sub esp,0x60`:

``````esp -> 0x1020
``````

So the stack frame of the function is between `0x1080` and `0x1020`.

The stack grew from `0x1080` to `0x1020`, that why it grows under - from the higher value to the lower.

Then, `esp+0x5c` is: `0x107c`.

`0x107c` Is within the stack frame of the function.

• Thank you, I understand that it is within the stack frame, but what I actually want to understand is if the "Stack frame itself or the data in it" grows upwards(from lower next to the stack pointer to higher). Say two variables 'a' and 'b' are created which one will be closer to the stack pointer the first or the second variable? Mar 4 at 19:18