I've disassembled some C/C++ codes and realized the stack boundary is specified at beginning of a procedure, somehow like this :1. push ebp2. mov ebp , esp3. sub esp , <power> ; <power> is specified by mpreferred-stack-boundary=2^powerThe above code is used to create stack frames, But What I need to know is why this subtract is used, Cause the stack grows down (by using push for local variables) and such the subtract causes :---------------------------- ^by sub esp,<power> <---- esp |.                            |.                            |.                            |---------------------------- |esp <---- esp                |---------------------------- |ret address                  |---------------------------- |The above picture shows that.So when in the rest of code if you have such the following codes:push var1It should be taken at the top of it so it looks like this :-----------------------------var1 (4 byte)                -----------------------------^by sub esp,<power> <---- esp |.                            |.                            |.                            |---------------------------- |esp <---- esp                |---------------------------- |ret address                  |---------------------------- |So the space between esp and var1 is going to be free without any use ?that's what I want to know.
Stack frame boundary
memory;stack variables
So the space between esp and var1 is going to be free without any use  ? that's what I want to know.That stack space is used for the function's local variables (also known as stack variables).Here's a nice animated GIF that shows a function's stack frame being created and used to store local variables: