سؤال

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