I need some help understanding why GCC is doing

main:
    pushl   %ebp
    movl    %esp, %ebp
    andl    $-16, %esp   # ???
    subl    $48, %esp    # ???
    movl    $8, 16(%esp)        
    movl    $4, 20(%esp)

Why does it first subtract 16 and then subtract 48 again? Wouldn't it be easier to do subl $64, %esp?

有帮助吗?

解决方案

andl    $-16, %esp   # ???

The above line is not subtracting 16 from esp but to align it to 16 byte boundary.
While the following one is to subtract, mostly for reserving some space on the stack.

subl    $48, %esp    # ???
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top