Reputation: 3425
What is the difference between the two lines
push eax
mov [esp], eax
Doesn't push eax on to the stack (where esp is pointing to just as mov [esp], eax does?)
Upvotes: 6
Views: 12009
Reputation: 58294
"push" will automatically bump the value of "esp" (your stack pointer). The "mov" won't. So i if you wanted to put multiple items on the stack, with push
, you just do:
push eax
push ebx
...
With mov
, to get the same results, you'd have:
sub esp,4
mov [esp], eax
sub esp,4
mov [esp], ebx
...
And the nice thing about push
is that there is the reverse operation, pop
which allows you to pull things back off in reverse order. Which is, of course, what a stack is all about. :)
Upvotes: 16