Originally Posted by
rplantz
I've taught this material since 1999 and have even written a book on it. I still have not figured out all the things that the compiler does with esp at the beginning of a function. Some of them are intended to keep the stack at certain address boundaries. And it's getting much more complex with newer versions of gcc.
That makes me feel somewhat better, because this kind of thing makes me say WTF:
Code:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $0, %eax
addl $15, %eax
addl $15, %eax
shrl $4, %eax
sall $4, %eax
subl %eax, %esp
The green code makes sense to me: saving the frame pointer, reserving stack space, and aligning the stack pointer, but why the fancy footwork afterward?
Bookmarks