Schilive
Schilive

Reputation: 284

Is increasing stack and moving faster than pushing, in x86 assembly?

I heard the x86 instruction push <value> does two things: increase the stack's size for the value's size, and put the value on the stack. I understand this to be identical to

subl $4, %esp
movl $1, (%esp)

Looking in some GCC compiled code to assembly, the compiler manually increased the stack and then moved the values to the stack, as

subl $12, %esp
movl $1, 8(%esp)
movl $2, 4(%esp)
movl $3, (%esp)

Which method is better for pushing to the stack? Manually increasing the stack's size (sub) and then moving it to the stack (mov)? Or is push better?

Upvotes: 1

Views: 105

Answers (0)

Related Questions