Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why pop takes a parameter in assembly?

popl   %ebp

It seems the %ebp is unnecessary because the pop operation of stack doesn't need a parameter.

Why does it make sense?

like image 545
Mask Avatar asked Mar 31 '10 15:03

Mask


1 Answers

From http://www.cs.virginia.edu/~evans/cs216/guides/x86.html

pop — Pop stack

The pop instruction removes the 4-byte data element from the top of the hardware-supported stack into the specified operand (i.e. register or memory location). It first moves the 4 bytes located at memory location [SP] into the specified register or memory location, and then increments SP by 4.

Syntax
pop <reg32>
pop <mem>

Examples
pop edi — pop the top element of the stack into EDI.
pop [ebx] — pop the top element of the stack into memory at the four bytes starting at location EBX.

Another good reference is http://en.wikibooks.org/wiki/X86_Assembly and it is available in PDF form.

like image 69
jschmier Avatar answered Sep 19 '22 20:09

jschmier