Spare bytes on the stack: x86 Assembly (64 bit)
pushq %rbp movq %rsp, %rbp subq $32, %rsp
I have a big question regarding the explanation for "$ 32" in the third instruction. Information from searches and blogs indicates that in the third third instruction, we reserve certain "bytes" of stack space. From doc% rsp is 64 bit register and% esp is 32 bit.
"$ 32" means 32 bytes? (Does $ number mean a constant?) If so, how do we allocate 32 bytes in a 64-bit register? The instructions above were created from "otool". I am using macbook pro.
I'm just trying to learn a little about assembly.
Thank.
source to share
"$ 32" means 32 bytes? (Does $ number mean a constant?) If so, how do we allocate 32 bytes in a 64-bit register?
These 32 bytes are not allocated in a 64-bit register. They are allocated on the stack. By dropping the stack pointer (which is in% rsp), the address range from% rsp to% rsp + 31 is at our disposal for storing data.
source to share
In 64-bit code, 128 bytes are already reserved for you, so in many cases you don't need to mess with the stack pointer, which therefore means you probably don't need to hit / pop% rbp. Just use% rsp-128 for% rsp for your data.
This reserved area is called the "red zone":
http://eli.thegreenplace.net/2011/09/06/stack-frame-layout-on-x86-64/
source to share