我正在使用gcc -S
玩耍,以了解内存和堆栈的工作原理。在这些玩耍中,我发现有几件事情不太清楚。您能帮助我理解原因吗?
When calling function sets arguments for a called one it uses
mov
toesp
insteadpush
. What is the advantage not usingpush
?Function which works with its stack located arguments points to them as
ebp + (N + offset)
(where N is a size reserved for return address). I expect to seeesp - offset
which is more understandable. What is the reason to useebp
as fundamental point everywhere? I know these ones are equal but anyway?What is this magic for in the beginning of
main
? Whyesp
must be initialized in this way only?and esp,0xfffffff0