문제

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