In x64 assembly, the stack frame, according to Microsoft, should be 16-byte aligned
The stack will always be maintained 16-byte aligned, except within the prolog (for example, after the return address is pushed), and except where indicated in Function Types for a certain class of frame functions.
Assume we have the following function:
void foo() {
long long int foo;
long long int bar;
}
The stack would look something like this:
|-----------|
| rbp |
|-----------|
| foo |
|-----------|
| bar |
|-----------|
| undefined |
|-----------|
So, the stack would need to allocate 20h bytes. And the assembly instruction would look like:
push rbp
mov rbp, rsp
sub 20h ; 32 bytes needed to fulfill alignment requirements
Is my understanding of this correct, or am I way off? I'm also assuming no optimizations.