Reputation: 1719
ATT syntax.
I've noticed that library routines in C often use the following snippet of assembly code:
call next
next:
popl %eax
Upvotes: 1
Views: 444
Reputation: 8028
What is the value of %eax after this sequence of instructions?
call next
next: popl %eax
Whatever the address of next is
(the memory address where popl instruction is) Note: this is NOT the PC, but it is related to it
– PC is the address of the next instruction to be executed; %eax now has address of most recently executed instruction (the popl)
Upvotes: 1
Reputation: 6017
It gives you the current value of the program counter (PC). That is, you get the address of the current instruction that is executing.
Here's an interesting article that talks about using that snippet vs doing it with C: http://blogs.msdn.com/b/oldnewthing/archive/2004/12/16/317157.aspx
Upvotes: 2