Neccessity of push and pop operands on CPUs

Posted by Hawken on Stack Overflow See other posts from Stack Overflow or by Hawken
Published on 2012-04-14T17:23:52Z Indexed on 2012/04/14 17:29 UTC
Read the original article Hit count: 226

Filed under:
|
|
|
|

Why do we have commands like push and pop?

From what I understand pop and push are basically the same as doing a (mov then add) and (sub then mov) on esp respectively.


For example wouldn't:

pushl %eax

be equivalent to:

subl $4, %esp
movl %eax, (%esp-4)

please correct me if stack access is not (%esp-4), I'm still learning assembly


The only true benefit I can see is if doing both operation simultaneously offers some advantage; however I don't see how it could.

© Stack Overflow or respective owner

Related posts about assembly

Related posts about stack