We're going to focus on x86 because it's the easiest to understand. I'll then explain how x86_64 is more efficient.
So the stack is where local variables are stored. It is just a chunk of memory available for the program. The top of the stack is stored in a special register called the stack pointer, or esp on x86. It grows from higher addresses to lower addresses. To put a value on the stack you can